Project

General

Profile

Actions

Bug #13844

closed

Toplevel returns should fire ensures

Added by headius (Charles Nutter) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:82492]

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.


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #14061: Top-level return does not execute ensure if the file is loaded pr requiredClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0