Project

General

Profile

Actions

Bug #1730

closed

Returning inside for loop inside lambda crashes

Added by bugmenot (bugmenot bugmenot) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
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

Actions #1

Updated by ujihisa (Tatsuhiro Ujihisa) over 14 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

Actions

Also available in: Atom PDF

Like0
Like0