Project

General

Profile

Bug #2776

can't return from lambda with outer block

Added by wanabe (_ wanabe) about 10 years ago. Updated almost 9 years ago.

Status:
Rejected
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.2dev (2010-02-21 trunk 26722) [i686-linux]
Backport:
[ruby-dev:40453]

Description

=begin
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
'
=end


Related issues

Related to Ruby master - Bug #1018: return in an eigenclass definitionClosed01/16/2009ko1 (Koichi Sasada)Actions

Also available in: Atom PDF