-
Notifications
You must be signed in to change notification settings - Fork 103
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
Assertions don't change type of vars #564
Comments
Yes, flow typing doesn't affect the type of mutable variables, as you could have:
to make it work we'd have to modify the type of
It might be worth thinking about whether we want to do something smarter, because I have also noticed it makes loop variables quite awkward. |
This works:
But this doesn't:
I assume this is because
b
gets the inferred typerange(0, 1)
and then the assert essentially creates a new variable with the inferred typeint(0)
... but you can't make a new variable forvar
since it's mutable? So theassert
doesn't change its type?Not a big deal tbh (
var
is quite uncommon); I'd probably only fix it if it's easy. Here's the motivating example:I think you could probably do that recursively with no assertions tbf.
The text was updated successfully, but these errors were encountered: