Bug #5071

Inconsistent non-local return behavior inside a lambda

Added by Charles Nutter almost 3 years ago. Updated about 1 year ago.

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"

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

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.)


#1 Updated by Charles Nutter over 1 year ago

This should be fixed if 1.8 is open or closed if it is not.

#2 Updated by Motohiro KOSAKI about 1 year ago

  • Status changed from Open to Closed

1.8 is dead.

Also available in: Atom PDF