LocalJumpError not thrown
-------------------------

                 Key: JRUBY-4239
                 URL: http://jira.codehaus.org/browse/JRUBY-4239
             Project: JRuby
          Issue Type: Bug
    Affects Versions: JRuby 1.4
            Reporter: John Firebaugh
            Assignee: Thomas E Enebo


MRI:

irb(main):001:0> return
LocalJumpError: unexpected return
        from (irb):1
irb(main):002:0> [4,5,6].map {|a| return a*a}
LocalJumpError: unexpected return
        from (irb):2
        from (irb):2:in `map'
        from (irb):2

In JRuby, both of those just exit the interpreter immediately.

This can lead to significant behavioral differences that are difficult to 
diagnose.

class Test
  def later(&block)
    @later = block
  end

  def do_later
    result = @later.call
    puts "bar"
    result
  end

  def test_block
    later do
      return "foo"
    end
  end
end

t = Test.new
t.test_block
puts t.do_later

In JRuby, this prints "foo" but not "bar". In MRI it raises LocalJumpError and 
the problem is obvious.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to