summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-30 02:58:36 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-30 02:58:36 +0000
commitee1519777bbd4f57463e23b267653f8f37d7afaa (patch)
treeeb05966a8c66192512e534bc56cd8868e0362011
parent61f3baeef9003de4651419fa27ee97c18c8ce170 (diff)
merge revision(s) 49224,49225,49234,49235: [Backport #10711]
* numeric.c (bit_coerce): use original value for error message [ruby-core:67405] [Bug #10711] * test/ruby/test_numeric.rb (test_coerce): check error message git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--compar.c2
-rw-r--r--numeric.c3
-rw-r--r--test/ruby/test_numeric.rb4
-rw-r--r--version.h6
5 files changed, 16 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 13c776e13d..fca0c652c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Jun 30 11:56:24 2015 Eric Wong <e@80x24.org>
+
+ * numeric.c (bit_coerce): use original value for error message
+ [ruby-core:67405] [Bug #10711]
+ * test/ruby/test_numeric.rb (test_coerce): check error message
+
Mon Jun 29 13:22:14 2015 Shota Fukumori <her@sorah.jp>
* ext/objspace/objspace_dump.c(dump_object): Return empty JSON object when
diff --git a/compar.c b/compar.c
index 2f4db291a4..0cfce8f4ed 100644
--- a/compar.c
+++ b/compar.c
@@ -20,7 +20,7 @@ rb_cmperr(VALUE x, VALUE y)
{
const char *classname;
- if (SPECIAL_CONST_P(y)) {
+ if (SPECIAL_CONST_P(y) || BUILTIN_TYPE(y) == T_FLOAT) {
y = rb_inspect(y);
classname = StringValuePtr(y);
}
diff --git a/numeric.c b/numeric.c
index c463732c08..7c9aef1e41 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3299,11 +3299,12 @@ static int
bit_coerce(VALUE *x, VALUE *y, int err)
{
if (!FIXNUM_P(*y) && !RB_TYPE_P(*y, T_BIGNUM)) {
+ VALUE orig = *x;
do_coerce(x, y, err);
if (!FIXNUM_P(*x) && !RB_TYPE_P(*x, T_BIGNUM)
&& !FIXNUM_P(*y) && !RB_TYPE_P(*y, T_BIGNUM)) {
if (!err) return FALSE;
- coerce_failed(*x, *y);
+ coerce_failed(orig, *y);
}
}
return TRUE;
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index 0e70078bad..98fabc4e13 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -28,6 +28,10 @@ class TestNumeric < Test::Unit::TestCase
assert_raise_with_message(TypeError, /:"\\u3042"/) {1|:"\u{3042}"}
assert_raise_with_message(TypeError, /:"\\u3042"/) {1^:"\u{3042}"}
end
+
+ bug10711 = '[ruby-core:67405] [Bug #10711]'
+ exp = "1.2 can't be coerced into Fixnum"
+ assert_raise_with_message(TypeError, exp, bug10711) { 1 & 1.2 }
end
def test_dummynumeric
diff --git a/version.h b/version.h
index ba1d4a4425..1374e308c3 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.1.7"
-#define RUBY_RELEASE_DATE "2015-06-29"
-#define RUBY_PATCHLEVEL 368
+#define RUBY_RELEASE_DATE "2015-06-30"
+#define RUBY_PATCHLEVEL 369
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 29
+#define RUBY_RELEASE_DAY 30
#include "ruby/version.h"