2022-11-28 18:21:38 +01:00
|
|
|
# Tests more stuff about generics. This test should fail to compile
|
2022-12-01 22:04:10 +01:00
|
|
|
import std;
|
|
|
|
|
2022-11-28 18:21:38 +01:00
|
|
|
|
|
|
|
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!
|
2022-11-28 19:03:08 +01:00
|
|
|
fn nope[T: int32 | int16](x: T): T {
|
2022-11-28 18:21:38 +01:00
|
|
|
return identity(x);
|
|
|
|
}
|