aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/bigdecimal/bigdecimal.c2
-rw-r--r--test/bigdecimal/test_bigdecimal.rb7
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index efc41ca39e..2813951efa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Feb 27 17:03:20 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): since methods
+ can be overridden, so should not make an assumption on the type
+ of results. [ruby-core:42969][Bug #6093]
+
Mon Feb 27 10:54:20 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): replace the
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 17461cd341..3fbb9a8883 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -209,7 +209,7 @@ again:
if (prec < 0) goto unable_to_coerce_without_prec;
if (prec > DBL_DIG+1)goto SomeOneMayDoIt;
v = rb_funcall(v, id_to_r, 0);
- /* fall through */
+ goto again;
case T_RATIONAL:
if (prec < 0) goto unable_to_coerce_without_prec;
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 51dcb8e29b..deb2fa9a57 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -1,4 +1,5 @@
require_relative "testbase"
+require_relative "../ruby/envutil"
require 'thread'
@@ -1303,4 +1304,10 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(1, y)
assert_kind_of(c, y)
end
+
+ def test_to_d
+ bug6093 = '[ruby-core:42969]'
+ code = "exit(BigDecimal.new('10.0') == 10.0.to_d)"
+ assert_ruby_status(%w[-rbigdecimal -rbigdecimal/util -rmathn -], code, bug6093)
+ end
end