Project

General

Profile

Actions

Bug #14061

closed

Top-level return does not execute ensure if the file is loaded pr required

Added by Eregon (Benoit Daloze) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-10-26 trunk 60450) [x86_64-linux]
[ruby-core:83589]

Description

While writing specs for top-level return in https://github.com/ruby/spec/pull/530,
we found an inconsistent behavior:

puts "before begin"
begin
  return
ensure
  puts "within ensure"
end
puts "after begin"
$ ruby test.rb
before begin
within ensure

$ ruby -r./test.rb -e0
before begin

$ ruby -e 'load "test.rb"'
before begin

This is inconsistent, I believe ensure should be executed in both cases.
The semantics of top-level return are like raising an exception implicitly caught by load/require and the top-level exception handler, except for this case.


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #13844: Toplevel returns should fire ensuresClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0