Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler doesn't infer type of loop variable for while loops #1815

Open
floitsch opened this issue Sep 18, 2023 · 1 comment
Open

Compiler doesn't infer type of loop variable for while loops #1815

floitsch opened this issue Sep 18, 2023 · 1 comment

Comments

@floitsch
Copy link
Member

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

floitsch added a commit that referenced this issue Sep 18, 2023
Doesn't work because it loses track of `while foo/any := ...:`

See #1815
@floitsch
Copy link
Member Author

This has also implications for warnings that loops are infinite:

while x/int := foo:  // <= should warn that the condition is always true.
  ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant