peon/tests/generics2.pn

15 lines
304 B
Plaintext
Raw Permalink Normal View History

# Tests more stuff about generics. This test should fail to compile
2022-12-01 22:04:10 +01:00
import std;
fn identity(x: int32): int32 {
return x;
}
2022-11-28 18:27:04 +01:00
# No call is necessary for the compiler to detect the error:
# generics are type checked at declaration time!
fn nope[T: int32 | int16](x: T): T {
return identity(x);
}