temperlang / temper

3 stars 0 forks source link

Need static error message for forward function reference #158

Open tjpalmer opened 2 months ago

tjpalmer commented 2 months ago

Some examples:

$ let c(): Int { let i = a(1); let a(i: Int): Int { i + 1 }; i }
1: c(): Int { let i = a(1); let a(i: Int):
                      ⇧
[interactive#5:1+23-24]@T: a__3 is not initialized along branches at [:1+15]
1: let c(): Int { let i = a(1); let a(
                  ⇧
interactive#5: void
$ let d(): Int { let b(i: Int): Int { a(i) * 2 }; let i = b(1); let a(i: Int): Int { i + 1 }; i }
interactive#6: void
$ let e(): Int { let b(i: Int): Int { a(i) * 2 }; let a(i: Int): Int { i + 1 }; b(1) }
interactive#7: void
$ c()
1: c(): Int { let i = a(1); let a(i: Int):
                      ⇧
[interactive#5:1+23-24]@R: Interpreter encountered error()
Interpretation ended due to runtime panic
interactive#8: fail
$ d()
interactive#9: fail
$ e()
interactive#10: 4

Cases above:

  1. Static and dynamic errors with messages
  2. Missing static error; dynamic error without message
  3. Working because things aren't out of order

We really should have a static error message for case 2. A runtime error message would also be nice.