erg/tests/should_ok/subtyping.er
2024-04-04 23:24:07 +09:00

22 lines
596 B
Python

higher(f: (Nat -> Nat)): Nat = f(1)
_abs(x: Int): Nat = x.abs()
print! higher _abs # OK
higher2(f: ((g: Nat -> Nat) -> Nat)): Nat = f((x: Nat) -> x + 1)
f(g: Bool -> Nat): Nat = g(False)
print! higher2 f # OK
str_to_int_or_rec(_: {Str: Int or Record}) = None
str_to_int_or_rec { "a": 1 }
str_to_int_or_rec { "a": {.a = 1} }
str_to_int_or_rec { "a": {.a = 1}, "b": 1 }
_ as List(List(Int)) = ![![1]]
_ as List(List(Int, 1), 1) = ![![1]]
_ as List(List!(Int, 1), 1) = ![![1]]
_ as List!(List(Int, 1), 1) = ![![1]]
_ as List!(List!(Int, 1), 1) = ![![1]]
_ as List!(List!({1}, 1), 1) = ![![1]]