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

END doesn't capture the environment #4257

Open
chrisseaton opened this issue Oct 30, 2016 · 4 comments
Open

END doesn't capture the environment #4257

chrisseaton opened this issue Oct 30, 2016 · 4 comments

Comments

@chrisseaton
Copy link
Contributor

$ ruby -e 'x = 14 ; END { p x }'
14
$ bin/jruby -e 'x = 14 ; END { p x }'
nil
$ ~/.rbenv/versions/rbx-2.11/bin/ruby -e 'x = 14 ; END { p x }'
14

PostExeParseNode#getScope() is null when it comes out of the parser. It should be the top level scope I think.

There's some musings here about the limitations of the implementation of END that might relevant.

// for END blocks altogether or only support them in the toplevel. Not worth the pain.

I don't think dropping support for END is a good idea though - it's used at least in mkmf and profile.

@chrisseaton
Copy link
Contributor Author

See 1c18c37

@enebo
Copy link
Member

enebo commented Oct 31, 2016

@chrisseaton yeah don't take that musing seriously. You are also correct END does not make it's own variable scope (you can tell too if you invoke local_variables in script and in END. I want to mention one other not well known thing:

END { p 1 }
END { p 2 }

This will print 2 then 1 since end blocks are executed last to first.

@chrisseaton
Copy link
Contributor Author

Closing due to inactivity.

@enebo
Copy link
Member

enebo commented Feb 17, 2020

This is clearly still not fixed. Re-opening.

@enebo enebo reopened this Feb 17, 2020
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