temperlang / temper

3 stars 0 forks source link

Bad generic callback parameter type inference #78

Open tjpalmer opened 9 months ago

tjpalmer commented 9 months ago

This ought to work without the explicit parameter type on the callback block.

$ let hi<T>(a: List<T>, action: fn (T): Void): Void { action(a[0]) }
interactive#4: void
$ hi(["there"]) { (it);; console.log(it); }
1: (it);; console.log(it); }
                      ┗┛
[interactive#5:1+35-37]@G: Expected subtype of String, but got T__0
1: (it);; console.log(it); }
                      ┗┛
[interactive#5:1+35-37]@G: Expected subtype of String, but got T__0
1: (it);; console.log(it); }
                      ┗┛
[interactive#5:1+35-37]@G: Expected subtype of String, but got T__0
1: hi(["there"]) { (it);; console.log(it); }
      ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
[interactive#5:1+3-41]@G: Expected subtype of T__0, but got String
1: hi(["there"]) { (it);; console.l
      ┗━━━━━━━┛
[interactive#5:1+3-12]@G: Expected subtype of List<T__0>, but got List<String>
there
interactive#5: void
$ hi(["there"]) { (it: String);; console.log(it); }
there
interactive#6: void