Forum: Ruby-core [Ruby 1.8 - Bug #5071][Open] Inconsistent non-local return behavior inside a lambda

Posted by Charles Nutter (headius)
on 2011-07-22 00:04
(Received via mailing list)
Issue #5071 has been reported by Charles Nutter.

----------------------------------------
Bug #5071: Inconsistent non-local return behavior inside a lambda
http://redmine.ruby-lang.org/issues/5071

Author: Charles Nutter
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]


These two cases should be the same:

    ~/projects/jruby $ rvm use ruby-1.8.7
    Using /Users/headius/.rvm/gems/ruby-1.8.7-p352

    ~/projects/jruby $ ruby -e "def foo; l = lambda { return 1 }; p 
l.call; 'ok'; end; p foo"
    1
    "ok"

    ~/projects/jruby $ ruby -e "def foo; l = lambda { 1.times { return 1 
} }; p l.call; 'ok'; end; p foo"
    1

They are the same when running under 1.9.2 or any mode of JRuby. I file 
this bug because we encountered the difference and feel like 1.8.7 is 
wrong here. The return is contained within a lambda, and it should 
return to that level. Wrapping the return in another block should not 
cause it to suddenly start propagating all the way out of the method.

I would be satisfied to know this is a bug in 1.8.7, whether it will be 
fixed or not, so we know not to implement the broken behavior in JRuby 
(we probably won't anyway, but I'd feel better about that decision.)
Posted by Charles Nutter (headius)
on 2012-11-16 17:34
(Received via mailing list)
Issue #5071 has been updated by headius (Charles Nutter).


This should be fixed if 1.8 is open or closed if it is not.
----------------------------------------
Bug #5071: Inconsistent non-local return behavior inside a lambda
https://bugs.ruby-lang.org/issues/5071#change-32979

Author: headius (Charles Nutter)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]


These two cases should be the same:

    ~/projects/jruby $ rvm use ruby-1.8.7
    Using /Users/headius/.rvm/gems/ruby-1.8.7-p352

    ~/projects/jruby $ ruby -e "def foo; l = lambda { return 1 }; p 
l.call; 'ok'; end; p foo"
    1
    "ok"

    ~/projects/jruby $ ruby -e "def foo; l = lambda { 1.times { return 1 
} }; p l.call; 'ok'; end; p foo"
    1

They are the same when running under 1.9.2 or any mode of JRuby. I file 
this bug because we encountered the difference and feel like 1.8.7 is 
wrong here. The return is contained within a lambda, and it should 
return to that level. Wrapping the return in another block should not 
cause it to suddenly start propagating all the way out of the method.

I would be satisfied to know this is a bug in 1.8.7, whether it will be 
fixed or not, so we know not to implement the broken behavior in JRuby 
(we probably won't anyway, but I'd feel better about that decision.)
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2013-03-15 19:20
(Received via mailing list)
Issue #5071 has been updated by kosaki (Motohiro KOSAKI).

Status changed from Open to Closed

1.8 is dead.
----------------------------------------
Bug #5071: Inconsistent non-local return behavior inside a lambda
https://bugs.ruby-lang.org/issues/5071#change-37639

Author: headius (Charles Nutter)
Status: Closed
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]


These two cases should be the same:

    ~/projects/jruby $ rvm use ruby-1.8.7
    Using /Users/headius/.rvm/gems/ruby-1.8.7-p352

    ~/projects/jruby $ ruby -e "def foo; l = lambda { return 1 }; p 
l.call; 'ok'; end; p foo"
    1
    "ok"

    ~/projects/jruby $ ruby -e "def foo; l = lambda { 1.times { return 1 
} }; p l.call; 'ok'; end; p foo"
    1

They are the same when running under 1.9.2 or any mode of JRuby. I file 
this bug because we encountered the difference and feel like 1.8.7 is 
wrong here. The return is contained within a lambda, and it should 
return to that level. Wrapping the return in another block should not 
cause it to suddenly start propagating all the way out of the method.

I would be satisfied to know this is a bug in 1.8.7, whether it will be 
fixed or not, so we know not to implement the broken behavior in JRuby 
(we probably won't anyway, but I'd feel better about that decision.)
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.