temperlang / temper

3 stars 0 forks source link

Support generic types in `match` cases #83

Closed tjpalmer closed 8 months ago

tjpalmer commented 9 months ago

These should work:

$ let hi(a: ListBuilder<Int> | Null): Int { match (a) { is ListBuilder<Int> -> a[0]; else -> 0 } }
1: nt { match (a) { is ListBuilder<Int> -> a[0]; else -> 0
                       ┗━━━━━━━━━━━━━━┛
[interactive#0:1+57-73]@D: Invalid case condition
interactive#0: void
$ let hi<T>(a: ListBuilder<T> | Null): T | Null { match (a) { is ListBuilder<T> -> a[0]; else -> null } }
1: ll { match (a) { is ListBuilder<T> -> a[0]; else -> nu
                       ┗━━━━━━━━━━━━┛
[interactive#1:1+63-77]@D: Invalid case condition
interactive#1: void