-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Treat return in block in class/module as LocalJumpError #2511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat return in block in class/module as LocalJumpError #2511
Conversation
return directly in class/module is an error, so return in proc in class/module should also be an error. I believe the previous behavior was an unintentional oversight during the addition of top-level return in 2.4.
|
@jeremyevans I was responsible for that current spec but I really think we should not leave in that specified behavior (for 2.4-2.6). Your new spec for 2.7 on seems like semantic behavior and good to be in ruby/spec. My original test just happens to verify something which the implementation happens to do. My recommendation is to remove the pre 2.7 spec because it specs what I consider to be an unintended behavior. |
|
I'm neutral on removing the spec for Ruby < 2.7, both are fine for me. |
|
I am fine either way as well other than having an opinion. We will just tag it out if it stays (until JRuby 9.3.x which will be 2.7.x). I just don't like seeing non-semantic behavior in ruby/spec (and I am to blame for adding it originally :) ). |
|
Let's remove the <2.7 spec then since it seems clearly unintended behavior. |
This becomes unspecified behavior on earlier Ruby versions.
|
|
... i agree it is unexpected behavior, too. |
|
I'm sorry. I thought it was a bug, since we do not allow class Foo
class << self
alias proc lambda if ARGV.first == 'lambda'
end
proc { return }.call
endI can definitely revert and wait for matz's decision if you think it is best. |
|
I agree, too. Wow! |
|
@ko1 do you still think Matz needs to check this? It feels like this is just accidental behavior and not intended. |
|
Now I don't think we need to ask Matz. I'll ask Matz when I meet him if I remember :) |
return directly in class/module is an error, so return in
proc in class/module should also be an error. I believe the
previous behavior was an unintentional oversight during the
addition of top-level return in 2.4.