Bug #2776: can't return from lambda with outer block
http://redmine.ruby-lang.org/issues/show/2776

起票者: _ wanabe
ステータス: Open, 優先度: Low
担当者: Koichi Sasada, カテゴリ: core, Target version: 1.9.x
ruby -v: ruby 1.9.2dev (2010-02-21 trunk 26722) [i686-linux]

http://pc12.2ch.net/test/read.cgi/tech/1264635554/685 で質問されていたのですが
1.8 と 1.9 で lambda の挙動が異なっています。

----------------------------------------
# test.rb
class Foo
  def initialize(&func)
    @func = lambda(&func)
  end
  def bar(x)
    @func.call(x)
  end
end
foo = Foo.new{ |x| return x**2 }
p foo.bar(2)
----------------------------------------

$ ruby1.8 -v test.rb
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
4

$ ./ruby -v test.rb
ruby 1.9.2dev (2010-02-21 trunk 26722) [i686-linux]
test.rb:9:in `block in <main>': unexpected return (LocalJumpError)
        from test.rb:6:in `call'
        from test.rb:6:in `bar'
        from test.rb:10:in `<main>'


----------------------------------------
http://redmine.ruby-lang.org