Actions
Bug #13844
closedToplevel returns should fire ensures
Bug #13844:
Toplevel returns should fire ensures
Description
In the following contexts, a return always fires the ensure that wraps it:
[] ~/projects/ruby $ ruby -e 'def foo; return; ensure; p :x; end; foo'
:x
[] ~/projects/ruby $ ruby -e 'def foo; 1.times { begin; return; ensure; p :x; end }; end; foo'
:x
However the new 2.4 support for toplevel returns does not fire ensures:
$ ruby -e 'begin; return; ensure; p :x; end'
<no output>
I believe this is inconsistent with how returns work everywhere else (both valid and invalid returns always fire ensure) and it should be changed to match.
Actions