peon/tests/generics2.pn

15 lines
304 B
Plaintext

# Tests more stuff about generics. This test should fail to compile
import std;
fn identity(x: int32): int32 {
return x;
}
# 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);
}