Range#new breaks when 3rd parameter is not boolean
--------------------------------------------------

                 Key: JRUBY-1594
                 URL: http://jira.codehaus.org/browse/JRUBY-1594
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.x
         Environment: Ubuntu Linux 7.10,
ruby 1.8.5 (2007-11-20 rev 4842) [i386-jruby1.1b1]

            Reporter: Vladimir Sizikov


MRI:

Range.new(1, 3, nil), Range.new(1, 3, 1), Range.new(1, 3, 0) work, returning
1..3, 1...3, 1...3 respectively.

JRuby:

All three invocation break heavily with long exception:

NativeException: java.lang.ClassCastException: org.jruby.RubyFixnum cannot be 
cast to org.jruby.RubyBoolean
        from RubyRange.java:269:in `org.jruby.RubyRange.initialize'
        from null:-1:in `org.jruby.RubyRangeInvoker$initialize_method_2_1.call'
        from RubyObject.java:530:in `org.jruby.RubyObject.callMethod'
        from RubyObject.java:486:in `org.jruby.RubyObject.callMethod'
        from RubyClass.java:206:in `org.jruby.RubyClass.newInstance'
        from null:-1:in `org.jruby.RubyClassInvoker$newInstance_opt.call'
        from InvocationCallback.java:67:in 
`org.jruby.runtime.callback.InvocationCallback.execute'
        from FullFunctionCallbackMethod.java:73:in 
`org.jruby.internal.runtime.methods.FullFunctionCallbackMethod.call'
        from CallSite.java:158:in 
`org.jruby.runtime.CallSite$InlineCachingCallSite.call'
        from CallSite.java:103:in 
`org.jruby.runtime.CallSite$ArgumentBoxingCallSite.call'
        from ASTInterpreter.java:562:in 
`org.jruby.evaluator.ASTInterpreter.callNode'
        from ASTInterpreter.java:209:in 
`org.jruby.evaluator.ASTInterpreter.evalInternal'
        from ASTInterpreter.java:1534:in 
`org.jruby.evaluator.ASTInterpreter.rootNode'
        from ASTInterpreter.java:358:in 
`org.jruby.evaluator.ASTInterpreter.evalInternal'
        from ASTInterpreter.java:166:in 
`org.jruby.evaluator.ASTInterpreter.eval'
        from RubyObject.java:781:in `org.jruby.RubyObject.evalWithBinding'
... 95 levels...
        from ASTInterpreter.java:203:in 
`org.jruby.evaluator.ASTInterpreter.evalInternal'
        from ASTInterpreter.java:166:in 
`org.jruby.evaluator.ASTInterpreter.eval'
        from DefaultMethod.java:146:in 
`org.jruby.internal.runtime.methods.DefaultMethod.call'
        from CallSite.java:158:in 
`org.jruby.runtime.CallSite$InlineCachingCallSite.call'
        from CallSite.java:103:in 
`org.jruby.runtime.CallSite$ArgumentBoxingCallSite.call'
        from /opt/work/jruby/bin/jirb:13:in `opt.work.jruby.bin.j.__file__'
        from /opt/work/jruby/bin/jirb:-1:in `opt.work.jruby.bin.j.load'
        from Ruby.java:588:in `org.jruby.Ruby.runScript'
        from Ruby.java:510:in `org.jruby.Ruby.runNormally'
        from Ruby.java:433:in `org.jruby.Ruby.runFromMain'
        from Main.java:227:in `org.jruby.Main.runInterpreter'
        from Main.java:183:in `org.jruby.Main.runInterpreter'
        from Main.java:116:in `org.jruby.Main.run'
        from Main.java:93:in `org.jruby.Main.run'
        from Main.java:84:in `org.jruby.Main.main'
        from (irb):1:in `binding'irb(main):002:0>

This problem triggers a Rubinius spec test failure:

#> bin/mspec -t jruby spec/core/range

5)
Range.new includes the end object when the third parameter is omitted or false 
FAILED
java.lang.ClassCastException: org.jruby.RubyFixnum cannot be cast to 
org.jruby.RubyBoolean:
RubyRange.java:269:in `org.jruby.RubyRange.initialize'
null:-1:in `org.jruby.RubyRangeInvoker$initialize_method_2_1.call'
RubyObject.java:530:in `org.jruby.RubyObject.callMethod'
RubyObject.java:486:in `org.jruby.RubyObject.callMethod'
RubyClass.java:206:in `org.jruby.RubyClass.newInstance'
null:-1:in `org.jruby.RubyClassInvoker$newInstance_opt.call'
InvocationCallback.java:67:in 
`org.jruby.runtime.callback.InvocationCallback.execute'
FullFunctionCallbackMethod.java:73:in 
`org.jruby.internal.runtime.methods.FullFunctionCallbackMethod.call'
CallSite.java:158:in `org.jruby.runtime.CallSite$InlineCachingCallSite.call'
CallSite.java:103:in `org.jruby.runtime.CallSite$ArgumentBoxingCallSite.call'
ASTInterpreter.java:562:in `org.jruby.evaluator.ASTInterpreter.callNode'
ASTInterpreter.java:209:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:553:in `org.jruby.evaluator.ASTInterpreter.callNode'
ASTInterpreter.java:209:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:553:in `org.jruby.evaluator.ASTInterpreter.callNode'
ASTInterpreter.java:209:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:553:in `org.jruby.evaluator.ASTInterpreter.callNode'
ASTInterpreter.java:209:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:536:in `org.jruby.evaluator.ASTInterpreter.blockNode'
ASTInterpreter.java:203:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:166:in `org.jruby.evaluator.ASTInterpreter.eval'
InterpretedBlock.java:175:in `org.jruby.runtime.InterpretedBlock.yield'
Block.java:116:in `org.jruby.runtime.Block.yield'
/opt/work/rubinius/spec/mini_rspec.rb:356:in `it21854021_11652231.__rescue_2'
/opt/work/rubinius/spec/mini_rspec.rb:355:in `it21854021_11652231.__ensure_1'
/opt/work/rubinius/spec/mini_rspec.rb:355:in `it21854021_11652231.__rescue_1'
/opt/work/rubinius/spec/mini_rspec.rb:354:in `it21854021_11652231.__file__'
/opt/work/rubinius/spec/mini_rspec.rb:-1:in `it21854021_11652231.run'
DefaultMethod.java:114:in 
`org.jruby.internal.runtime.methods.DefaultMethod.call'
CallSite.java:144:in `org.jruby.runtime.CallSite$InlineCachingCallSite.call'
/opt/work/rubinius/spec/mini_rspec.rb:403:in `it16988783_11652231.__file__'
/opt/work/rubinius/spec/mini_rspec.rb:-1:in `it16988783_11652231.run'
DefaultMethod.java:114:in 
`org.jruby.internal.runtime.methods.DefaultMethod.call'
CallSite.java:158:in `org.jruby.runtime.CallSite$InlineCachingCallSite.call'
ASTInterpreter.java:1017:in `org.jruby.evaluator.ASTInterpreter.fCallNode'
ASTInterpreter.java:255:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:536:in `org.jruby.evaluator.ASTInterpreter.blockNode'
ASTInterpreter.java:203:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:166:in `org.jruby.evaluator.ASTInterpreter.eval'
InterpretedBlock.java:175:in `org.jruby.runtime.InterpretedBlock.yield'
Block.java:116:in `org.jruby.runtime.Block.yield'
/opt/work/rubinius/spec/mini_rspec.rb:377:in `describe926353_11652231.__file__'
/opt/work/rubinius/spec/mini_rspec.rb:-1:in `describe926353_11652231.run'
DefaultMethod.java:114:in 
`org.jruby.internal.runtime.methods.DefaultMethod.call'
CallSite.java:144:in `org.jruby.runtime.CallSite$InlineCachingCallSite.call'
/opt/work/rubinius/spec/mini_rspec.rb:399:in 
`describe11608737_11652231.__file__'
/opt/work/rubinius/spec/mini_rspec.rb:-1:in `describe11608737_11652231.run'
DefaultMethod.java:114:in 
`org.jruby.internal.runtime.methods.DefaultMethod.call'
CallSite.java:158:in `org.jruby.runtime.CallSite$InlineCachingCallSite.call'
ASTInterpreter.java:1017:in `org.jruby.evaluator.ASTInterpreter.fCallNode'
ASTInterpreter.java:255:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:536:in `org.jruby.evaluator.ASTInterpreter.blockNode'
ASTInterpreter.java:203:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:1534:in `org.jruby.evaluator.ASTInterpreter.rootNode'
ASTInterpreter.java:358:in `org.jruby.evaluator.ASTInterpreter.evalInternal'
ASTInterpreter.java:166:in `org.jruby.evaluator.ASTInterpreter.eval'
Ruby.java:1818:in `org.jruby.Ruby.loadFile'
ExternalScript.java:52:in `org.jruby.runtime.load.ExternalScript.load'
LoadService.java:214:in `org.jruby.runtime.load.LoadService.load'
RubyKernel.java:681:in `org.jruby.RubyKernel.load'
null:-1:in `org.jruby.RubyKernelInvoker$load_method_1_0.call'
CallSite.java:144:in `org.jruby.runtime.CallSite$InlineCachingCallSite.call'
CallSite.java:103:in `org.jruby.runtime.CallSite$ArgumentBoxingCallSite.call'
last_mspec.rb:11:in `last_mspec.closure0___rescue_1'
last_mspec.rb:11:in `last_mspec.closure0'
null:-1:in `last_mspecBlockclosure0xx1.call'
CompiledBlock.java:124:in `org.jruby.runtime.CompiledBlock.yield'
CompiledBlock.java:105:in `org.jruby.runtime.CompiledBlock.yield'
Block.java:111:in `org.jruby.runtime.Block.yield'
RubyArray.java:1173:in `org.jruby.RubyArray.each'
null:-1:in `org.jruby.RubyArrayInvoker$each_method_0_0.call'
CallSite.java:158:in `org.jruby.runtime.CallSite$InlineCachingCallSite.call'
CallSite.java:109:in `org.jruby.runtime.CallSite$ArgumentBoxingCallSite.call'
last_mspec.rb:6:in `last_mspec.__file__'
last_mspec.rb:-1:in `last_mspec.load'
Ruby.java:588:in `org.jruby.Ruby.runScript'
Ruby.java:510:in `org.jruby.Ruby.runNormally'
Ruby.java:433:in `org.jruby.Ruby.runFromMain'
Main.java:227:in `org.jruby.Main.runInterpreter'
Main.java:183:in `org.jruby.Main.runInterpreter'
Main.java:116:in `org.jruby.Main.run'
Main.java:93:in `org.jruby.Main.run'
Main.java:84:in `org.jruby.Main.main'
/opt/work/rubinius/./spec/core/range/new_spec.rb:20:in `new'
/opt/work/rubinius/./spec/core/range/new_spec.rb:12:in `it'
/opt/work/rubinius/spec/mini_rspec.rb:403:in `it'
/opt/work/rubinius/./spec/core/range/new_spec.rb:12:in `it'
/opt/work/rubinius/./spec/core/range/new_spec.rb:12:in `describe'
/opt/work/rubinius/spec/mini_rspec.rb:399:in `describe'
/opt/work/rubinius/./spec/core/range/new_spec.rb:3:in `describe'
/opt/work/rubinius/./spec/core/range/new_spec.rb:3:in `load'
last_mspec.rb:11:in `load'
last_mspec.rb:1:in `each'
last_mspec.rb:6:in `each'


-- 
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