END not working as in MRI #3522
Closed
Milestone
Comments
An update with minor analysis. JRuby 1.7 is EOL and on 9k we now work as expected for BEGIN. END is not specific to -n at all. Each time we execute code which contains and END we just push it onto the end stack. So: 10.times { END { p :end } } It should print out once but we print out 10 times. We do correctly run the following at_exit 10 times. 10.times { at_exit { p :end } } So we need some special code for END. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BEGIN
andEND
does not work as in MRI, at least not when used with-n
and-e
. The behavior differs from 1.7.23 to 9.0.4.0, but neither version does what MRI does. I'll give a few examples to try to explain what I expected, and what I got:MRI (expected behavior):
JRuby 9.0.4.0:
JRuby 1.7.23:
It appears as if the
END
-block gets registered once per input line in both JRuby versions, and theBEGIN
-block never in 9.0.4.0 and once per input line in 1.7.23. And if that isn't enough, if I pass--debug
to 9.0.4.0, it runs theBEFORE
-block once but theEND
-block twice.This is not a feature I rely on in any way, and I just happened to stumble upon it and thought I'd report it.
The text was updated successfully, but these errors were encountered: