This issue tracks unimplemented top-level
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:
return; raise begin return; rescue SystemExit; exit false; end begin return; ensure exit false; end begin ensure return; end begin raise; ensure; return; end begin raise; rescue; return; end return false; raise return 1; raise
Each of these lines in a
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: