Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Erroneous BigDecimal operations #1633

Closed
nmk opened this Issue · 1 comment

3 participants

@nmk

This is related to #1441.

BigDecimal#* and BigDecimal#mult differ in behaviour from MRI when passed nil as argument and BigDecimal#div throws a NullPointerException when the first argument is nil:

jruby-1.7.11 :011 > BigDecimal.new("10") * nil
 => nil
jruby-1.7.11 :012 > BigDecimal.new("10").mult(nil, 3)
 => nil
jruby-1.7.11 :013 > BigDecimal.new("10").div(nil, 3)
Java::JavaLang::NullPointerException:
        from org.jruby.ext.bigdecimal.RubyBigDecimal.op_div19(RubyBigDecimal.java:1205)
        from org.jruby.ext.bigdecimal.RubyBigDecimal$INVOKER$i$op_div19.call(RubyBigDecimal$INVOKER$i$op_div19.gen)
        from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346)
        from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:204)
        from org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59)
        from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
        from org.jruby.ast.RootNode.interpret(RootNode.java:129)
        from org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:95)
        from org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:184)
        from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1158)
        from org.jruby.RubyKernel.eval19(RubyKernel.java:1121)
        from org.jruby.RubyKernel$INVOKER$s$0$3$eval19.call(RubyKernel$INVOKER$s$0$3$eval19.gen)
        from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:180)
        from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:70)
        from org.jruby.ast.FCallManyArgsNode.interpret(FCallManyArgsNode.java:60)
        from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
... 114 levels...
        from org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
        from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
        from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:198)
        from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
        from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
        from Users.nmk.$_dot_rvm.rubies.jruby_minus_1_dot_7_dot_11.bin.irb.__file__(/Users/nmk/.rvm/rubies/jruby-1.7.11/bin/irb:13)
        from Users.nmk.$_dot_rvm.rubies.jruby_minus_1_dot_7_dot_11.bin.irb.load(/Users/nmk/.rvm/rubies/jruby-1.7.11/bin/irb)
        from org.jruby.Ruby.runScript(Ruby.java:811)
        from org.jruby.Ruby.runScript(Ruby.java:804)
        from org.jruby.Ruby.runNormally(Ruby.java:673)
        from org.jruby.Ruby.runFromMain(Ruby.java:522)
        from org.jruby.Main.doRunFromMain(Main.java:395)
        from org.jruby.Main.internalRun(Main.java:290)
        from org.jruby.Main.run(Main.java:217)
        from org.jruby.Main.main(Main.java:197)
jruby-1.7.11 :014 >
@lucasallan lucasallan referenced this issue from a commit
@lucasallan lucasallan GH-1633 - Fixing issue created by the last commit.
BigDecimal operation were throwing a TypeError when the first argument is another BigDecimal.
60cd120
@lucasallan
Collaborator

Fixed by #1648

@lucasallan lucasallan closed this
@atambo atambo added this to the JRuby 1.7.13 milestone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.