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

while and until don't restrict variables after them #4242

Closed
asterite opened this issue Apr 5, 2017 · 0 comments
Closed

while and until don't restrict variables after them #4242

asterite opened this issue Apr 5, 2017 · 0 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Milestone

Comments

@asterite
Copy link
Member

asterite commented Apr 5, 2017

For example:

a = nil
while a.nil?
  a = 1
end

# This currently is (Int32 | Nil) but should be Int32
p typeof(a) # => (Int32 | Nil)

The workaround is to put a = a.nil! until this is implemented.

The same happens with until:

a = nil
until a
  a = 1
end

p typeof(a) # => (Int32 | Nil)

Extracted from #4239

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Apr 5, 2017
@asterite asterite added this to the Next milestone Apr 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Projects
None yet
Development

No branches or pull requests

1 participant