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

if + var does not properly restrict type when used in closure #5596

Closed
straight-shoota opened this issue Jan 16, 2018 · 1 comment
Closed

Comments

@straight-shoota
Copy link
Member

def foo(&block : -> )
  block.call
end

base = nil
foo do
  if base
    base.upcase # Error: undefined method 'upcase' for Nil
  end
end

The same code works if base is assigned to a fresh variable inside the block or the block is inlined (yield instead of block.call).

@asterite
Copy link
Member

Duplicate #3093

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

No branches or pull requests

2 participants