Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous BigDecimal operations #1633

Closed
nmk opened this Issue Apr 15, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@nmk
Copy link

nmk commented Apr 15, 2014

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 >

sh286 added a commit that referenced this issue Apr 20, 2014

sh286 added a commit that referenced this issue Apr 21, 2014

GH-1633 - Fixing issue created by the last commit.
BigDecimal operation were throwing a TypeError when the first argument is another BigDecimal.
@sh286

This comment has been minimized.

Copy link
Member

sh286 commented Apr 21, 2014

Fixed by #1648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.