Project

General

Profile

Actions

Bug #16181

closed

return from a proc in a module/class body returns out of script. Should be LJE.

Added by enebo (Thomas Enebo) over 4 years ago. Updated over 4 years ago.

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

Description

return is not allowed from class/module body. But if we insert a return into a block then we can invoke the block then it returns all the way out of the script. This has to be accidental behavior doesn't it? I believe the case below should end up as a LocalJumpError:

class Foo
  proc { return }.call
end
puts "NEVER SEEN"

This behavior started some time in 2.5 (it used to be an LJE).

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0