From: tom.enebo@... Date: 2019-09-30T20:11:18+00:00 Subject: [ruby-core:95159] [Ruby master Bug#16181] return from a proc in a module/class body returns out of script. Should be LJE. Issue #16181 has been updated by enebo (Thomas Enebo). Ok cool. Let's hope we get some more consensus on this. I don't like deviating from MRI in behavior so I hope to see more come to the same conclusion. ---------------------------------------- Bug #16181: return from a proc in a module/class body returns out of script. Should be LJE. https://bugs.ruby-lang.org/issues/16181#change-81798 * Author: enebo (Thomas Enebo) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- 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). -- https://bugs.ruby-lang.org/ Unsubscribe: