You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each of these lines in a -e should exit the process cleanly. The rescue-based cases expect the return to immediately exit the script body without firing ensures or rescues (more in this later). The remaining cases just check that the return does not execute any more lines in the script.
JRuby never implemented a top-level error when a return occurs outside of a method or block at toplevel, so some of these pass already. However the cases that check for ensures not running fail, since we implement those to the letter of the law in JRuby by using Java try/finally logic.
I am going to open an issue with MRI to clarify whether ensures should fire or not. I believe they should, since they do in all other contexts.
The text was updated successfully, but these errors were encountered:
This issue tracks unimplemented top-level
return
behavior added in Ruby 2.4.In MRI this feature was tracked in https://bugs.ruby-lang.org/issues/4840
The relevant tests, from test/mri/ruby/test_syntax.rb:test_return_toplevel, are copied here:
Each of these lines in a
-e
should exit the process cleanly. The rescue-based cases expect the return to immediately exit the script body without firing ensures or rescues (more in this later). The remaining cases just check that the return does not execute any more lines in the script.JRuby never implemented a top-level error when a return occurs outside of a method or block at toplevel, so some of these pass already. However the cases that check for ensures not running fail, since we implement those to the letter of the law in JRuby by using Java try/finally logic.
I am going to open an issue with MRI to clarify whether ensures should fire or not. I believe they should, since they do in all other contexts.
The text was updated successfully, but these errors were encountered: