toit
toit copied to clipboard
Compiler doesn't infer type of loop variable for while loops
foo_int -> int?: return 499
foo_string -> string?: return "hello"
main:
while x := foo_int:
x = foo_string
while x/any := foo_int:
x = foo_string
In the first loop it should infer the type as int and then complain about the foo_string assignment.
In the second loop it shouldn't
This has also implications for warnings that loops are infinite:
while x/int := foo: // <= should warn that the condition is always true.
...