Skip to content

[PRISM] Correct depth offset for block local vars #9144

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

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

eightbitraptor
Copy link
Contributor

Blocks should always look at their own local table first, even when defined inside an ensure/rescue or something else that uses depth offset. We can ignore the depth offset if we're doing local lookups inside a block

Blocks should always look at their own local table first, even when
defined inside an ensure/rescue or something else that uses depth
offset. We can ignore the depth offset if we're doing local lookups
inside a block
@eightbitraptor eightbitraptor merged commit c8b60c8 into ruby:master Dec 6, 2023
@tenderlove
Copy link
Member

I'm not 100% sure the issue, but reverting this PR fixes this case:

begin
  foo = 1
  m = nil
rescue
  tap { p foo }
end

We need foo to look up 2 environments, and clearing the local offset seems to break the math

@tenderlove
Copy link
Member

Related to this bug: ruby/prism#2053

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

Successfully merging this pull request may close these issues.

3 participants