Project

General

Profile

Bug #1730

Returning inside for loop inside lambda crashes

Added by bugmenot (bugmenot bugmenot) about 10 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]
[ruby-core:24148]

Description

=begin
This code:

foo = lambda do
for j in 1..2
return
end
end
foo.call

crashes with a LocalJumpError:

test.rb:3: unexpected return (LocalJumpError)
from test.rb:2:in each'
from test.rb:2
from test.rb:6:in
call'
from test.rb:6

Why does it do this? However, it seems to run fine on Ruby 1.9.

It's not just an issue of returning inside a lambda; without the for-loop it runs fine:

foo = lambda do
return
end
foo.call
=end

History

#1

Updated by ujihisa (Tatsuhiro Ujihisa) over 9 years ago

  • Status changed from Open to Closed

=begin
This change is intentional. The return behaviours are different between 1.8 and 1.9.
=end

Also available in: Atom PDF