We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
$ jruby -v jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.161-b12 on 1.8.0_161-b12 +jit [darwin-x86_64]
Also can be replicated on 9.1.17.0 and 1.7.27
$ uname -a Darwin [redacted] 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
Issue also present on Windows 7
C:\Users\Sean Mccarthy>jruby -v jruby 9.1.17.0 (2.3.3) 2018-04-20 d8b1ff9 Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [mswin32-x86_64]
Here's a test case:
require 'bigdecimal' class NullValue def nil? true end def coerce(other) case other when Numeric [other, BigDecimal(0)] end end def method_missing(method_name, *arguments, &block) BigDecimal(0).send(method_name, *arguments, &block) end end puts "Trying addition:" puts BigDecimal(100) + NullValue.new puts "Trying multiplication:" puts BigDecimal(100) * NullValue.new puts "Trying division:" puts BigDecimal(100) / NullValue.new puts "Trying subtraction:" puts BigDecimal(100) - NullValue.new
Output from MRI/CRuby 2.3.x
$ ruby -v ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-darwin17] $ ruby null_value.rb Trying addition: 0.1E3 Trying multiplication: 0.0 Trying division: Infinity Trying subtraction: 0.1E3
$ ruby -v jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.161-b12 on 1.8.0_161-b12 +jit [darwin-x86_64] $ ruby null_value.rb Trying addition: 0.1e3 Trying multiplication: 0.0 Trying division: Infinity Trying subtraction: TypeError: NullValue can't be coerced into BigDecimal - at org/jruby/ext/bigdecimal/RubyBigDecimal.java:1134 <main> at null_value.rb:27
The text was updated successfully, but these errors were encountered:
I think the issue is here:
jruby/core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java
Line 1134 in 4e8bb26
The 3rd parameter to getVpValueWithPrec (the must value) is true, but in similar contexts, e.g.
getVpValueWithPrec
must
true
Line 1039 in 4e8bb26
the must value is false.
false
This means that the cannotBeCoerced method immediately throws an exception rather than returning null and letting the coercion behaviour occur later.
cannotBeCoerced
null
Lines 421 to 428 in 4e8bb26
Sorry, something went wrong.
Fixing coercion case for subtraction from BigDecimal. Fixes jruby#5386.
ce30277
f7ef0fb
No branches or pull requests
Environment
$ jruby -v jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.161-b12 on 1.8.0_161-b12 +jit [darwin-x86_64]
Also can be replicated on 9.1.17.0 and 1.7.27
$ uname -a Darwin [redacted] 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
Issue also present on Windows 7
C:\Users\Sean Mccarthy>jruby -v jruby 9.1.17.0 (2.3.3) 2018-04-20 d8b1ff9 Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [mswin32-x86_64]
Expected Behavior
Here's a test case:
Output from MRI/CRuby 2.3.x
Actual Behavior
The text was updated successfully, but these errors were encountered: