Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.7.0.pre1
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Compiler
-
Labels:None
-
Environment:Java 7
-
Number of attachments :
Description
Again this testcase seems to be part of the one that is shipped with ruby 1.7.0 source .
require 'test/unit'
class TestLoop19 < Test::Unit::TestCase
def test_loop_catches_rescues_iteration_and_does_not_export_scope
loop do
n = 1
raise StopIteration
end
assert_raises NameError do n end <--------------------------------
end
end
While running this against Java 7 SR1 , I get the following error
test_loop_catches_rescues_iteration_and_does_not_export_scope(TestLoop19):
NoMethodError: undefined method `foo' for #<TestLoop19:0xcf5a8ceb> <--------------------------------------------------
/home/vinunaya/ruby/test/test_loop_1_9.rb:6:in `test_loop_catches_rescues_iteration_and_does_not_export_scope'
org/jruby/RubyKernel.java:1342:in `loop'
/home/vinunaya/ruby/test/test_loop_1_9.rb:5:in `test_loop_catches_rescues_iteration_and_does_not_export_scope'
org/jruby/RubyKernel.java:1944:in `send'
org/jruby/RubyArray.java:1603:in `each'
org/jruby/RubyArray.java:1603:in `each'
So if we observed the lines pointed out in the above failure message , it is basically getting a "NoMethodError" from the "do...end" block rather than the "NameError" expected.
So further looking into the issue , the above can be recreated even with a simple change to testcase .
class TestLoop19 < Test::Unit::TestCase
def test_loop_catches_rescues_iteration_and_does_not_export_scope
loop do
puts foo <--------------------------
raise StopIteration
end
end
So here I have removed the assertion and added a "puts " statement instead. If I run this with Java 7 SR1 , I get the error as mentioned above where as with Java 6 I get "NameError" as expected .
As per http://www.ruby-doc.org/core-1.9.3/NameError.html documentation we should be getting the "NameError" error itself .
Again here also ,when I tried running jruby with "--debug" option ( on Java7 SR1 line) I see the testcase passes .
I have raised JRUBY-6300 which was for slightly different issue but there too with "--debug" option it was passing . So I am not sure if these are related . If yes can you please let me know the build number where this is fixed . If not , can you please help with this issue . ?
Note that the test script works fine in the interpreted mode. I am assigning this to Charlie, since this is most likely a compiler issue.