jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-895

eval 'return' not working and not failing exactly either...

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: JRuby 0.9.9
  • Fix Version/s: JRuby 1.x+
  • Component/s: Core Classes/Modules, HelpWanted
  • Labels:
    None

Description

No YAY printed in snippet below. Most interesting our testEval is returning out of main without error are the point where this code is only running about half the files test cases. I guess it is good we don't crash and bad that we return at the wrong level

begin
  eval 'return'
rescue LocalJumpError => e
  puts "YAY: #{e}"
end

Issue Links

is related to

Bug - A problem which impairs or prevents the functions of the product. JRUBY-966 Various issues with LocalJumpError not being created early enough

  • Blocker - Blocks development and/or testing work, production could not run
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Charles Oliver Nutter added a comment - 31/May/07 4:37 PM

Punting to post 1.0. Nontrivial, and no reported app bugs because of it.

Show
Charles Oliver Nutter added a comment - 31/May/07 4:37 PM Punting to post 1.0. Nontrivial, and no reported app bugs because of it.
Hide
Permalink
Charles Oliver Nutter added a comment - 30/Sep/07 11:17 AM

Fix for 1.1 along with JRUBY-966.

Show
Charles Oliver Nutter added a comment - 30/Sep/07 11:17 AM Fix for 1.1 along with JRUBY-966.
Hide
Permalink
Charles Oliver Nutter added a comment - 23/Oct/07 2:59 PM

This is going to require the long-awaited Jump/LocalJumpError unification. I think this should be in 1.1, but maybe not in the beta.

Show
Charles Oliver Nutter added a comment - 23/Oct/07 2:59 PM This is going to require the long-awaited Jump/LocalJumpError unification. I think this should be in 1.1, but maybe not in the beta.
Hide
Permalink
Charles Oliver Nutter added a comment - 15/Feb/08 12:58 PM

Punting issues from 1.1 RC2 to 1.1 final.

Show
Charles Oliver Nutter added a comment - 15/Feb/08 12:58 PM Punting issues from 1.1 RC2 to 1.1 final.
Hide
Permalink
Charles Oliver Nutter added a comment - 17/Mar/08 12:13 PM

Punting...this is another case never reported in the wild, and pretty weird to boot. Nontrivial fix, post 1.1.

Show
Charles Oliver Nutter added a comment - 17/Mar/08 12:13 PM Punting...this is another case never reported in the wild, and pretty weird to boot. Nontrivial fix, post 1.1.
Hide
Permalink
Martin Harriman added a comment - 05/Oct/11 5:09 PM

It appears that jruby 1.7.0(dev) and 1.6.4 do the right thing. eval('return') inside a lambda just plain returns, eval('return') inside a bare Proc raises LocalJumpError, as it should. See:
http://ruby-doc.org/docs/keywords/1.9/Object.html#method-i-return

This is indeed pretty weird, but it looks suspiciously as if it is no longer a bug, per se.

I will be submitting a pull request to rubyspec with a test for this (a test which both MRI and JRuby pass).

Show
Martin Harriman added a comment - 05/Oct/11 5:09 PM It appears that jruby 1.7.0(dev) and 1.6.4 do the right thing. eval('return') inside a lambda just plain returns, eval('return') inside a bare Proc raises LocalJumpError, as it should. See: http://ruby-doc.org/docs/keywords/1.9/Object.html#method-i-return This is indeed pretty weird, but it looks suspiciously as if it is no longer a bug, per se. I will be submitting a pull request to rubyspec with a test for this (a test which both MRI and JRuby pass).
Hide
Permalink
Hiro Asari added a comment - 05/Oct/11 8:14 PM

Martin,

I am not convinced. How did you come to that conclusion?

On my machine, the snippet shown in the description of this ticket still does not work the way MRI does.

Show
Hiro Asari added a comment - 05/Oct/11 8:14 PM Martin, I am not convinced. How did you come to that conclusion? On my machine, the snippet shown in the description of this ticket still does not work the way MRI does.
Hide
Permalink
Martin Harriman added a comment - 06/Oct/11 2:15 AM - edited

The code snippet from the code I submitted to rubyspec looks like this:

293 foobar = false
294 begin
295 Proc.new { 296 eval("return 3") 297 }.call
298 rescue LocalJumpError
299 foobar = true
300 end
301 foobar.should == true

I just added this to the test:

foobar = false
begin
eval("return 3")
rescue LocalJumpError
foobar = true
end
foobar.should == true

and it looks as if it passes because it does indeed go flying off into space: the foobar.should == is never executed. Interesting. I will have to put on my thinking cap and try to figure out how to make this test fail for jruby.

So, to summarize: bug still valid (and disturbing), but only as a naked eval("return") in the begin...end block. Put it in a Proc, and it raises LocalJumpError as expected.

MRI raises LocalJumpError (at least for 1.8.7 and 1.9.2).

Show
Martin Harriman added a comment - 06/Oct/11 2:15 AM - edited The code snippet from the code I submitted to rubyspec looks like this: 293 foobar = false 294 begin 295 Proc.new { 296 eval("return 3") 297 }.call 298 rescue LocalJumpError 299 foobar = true 300 end 301 foobar.should == true I just added this to the test: foobar = false begin eval("return 3") rescue LocalJumpError foobar = true end foobar.should == true and it looks as if it passes because it does indeed go flying off into space: the foobar.should == is never executed. Interesting. I will have to put on my thinking cap and try to figure out how to make this test fail for jruby. So, to summarize: bug still valid (and disturbing), but only as a naked eval("return") in the begin...end block. Put it in a Proc, and it raises LocalJumpError as expected. MRI raises LocalJumpError (at least for 1.8.7 and 1.9.2).
Hide
Permalink
Martin Harriman added a comment - 06/Oct/11 3:36 AM - edited

This is not limited to eval.

This snippet:

begin
return
end

will fail with a LocalJumpError in MRI, but complete silently and happily in jruby 1.7.0(dev).

So should this be a "return" bug rather than an "eval" bug?

For that matter, the one-line ruby script:

return

behaves the same way. MRI raises the exception and (since there's no handler in that single line) issues the error message, JRuby does not.

Show
Martin Harriman added a comment - 06/Oct/11 3:36 AM - edited This is not limited to eval. This snippet: begin return end will fail with a LocalJumpError in MRI, but complete silently and happily in jruby 1.7.0(dev). So should this be a "return" bug rather than an "eval" bug? For that matter, the one-line ruby script: return behaves the same way. MRI raises the exception and (since there's no handler in that single line) issues the error message, JRuby does not.
Hide
Permalink
Martin Harriman added a comment - 06/Oct/11 3:07 PM

See JRUBY-2760. eval("return") is behaving exactly like a bare return here. JRuby "returns" from the top-level script rather than raising LocalJumpError when it sees a return in the top-level (outside a method). MRI raises LocalJumpError.

Show
Martin Harriman added a comment - 06/Oct/11 3:07 PM See JRUBY-2760. eval("return") is behaving exactly like a bare return here. JRuby "returns" from the top-level script rather than raising LocalJumpError when it sees a return in the top-level (outside a method). MRI raises LocalJumpError.
Hide
Permalink
Martin Harriman added a comment - 09/Oct/11 7:04 PM

rubyspec now includes a test for this behavior. The test fails as expected on JRuby, and passes on MRI Ruby.

Show
Martin Harriman added a comment - 09/Oct/11 7:04 PM rubyspec now includes a test for this behavior. The test fails as expected on JRuby, and passes on MRI Ruby.

People

  • Assignee:
    Unassigned
    Reporter:
    Thomas E Enebo
Vote (0)
Watch (1)

Dates

  • Created:
    27/Apr/07 6:39 PM
    Updated:
    09/Oct/11 7:04 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.