summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-24 22:39:57 (GMT)
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-25 02:39:20 (GMT)
commit5decf66ab3395193160673ddd80395a5b3b86223 (patch)
tree214d6a47118cf2c47e26f0e6da07dda77c3c25ef
parentb341e98b041e5e0f1fd2f40145b0b3d9cd8fdc3f (diff)
Inspect dynamic symbol as well as static symbol
-rw-r--r--numeric.c2
-rw-r--r--test/ruby/test_numeric.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index 724a7f3..5bf87bd 100644
--- a/numeric.c
+++ b/numeric.c
@@ -410,7 +410,7 @@ NORETURN(static void coerce_failed(VALUE x, VALUE y));
static void
coerce_failed(VALUE x, VALUE y)
{
- if (SPECIAL_CONST_P(y) || BUILTIN_TYPE(y) == T_FLOAT) {
+ if (SPECIAL_CONST_P(y) || SYMBOL_P(y) || RB_FLOAT_TYPE_P(y)) {
y = rb_inspect(y);
}
else {
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index 4e5404a..6073ec1 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -26,6 +26,10 @@ class TestNumeric < Test::Unit::TestCase
assert_raise_with_message(TypeError, /:"\\u3042"/) {1&:"\u{3042}"}
assert_raise_with_message(TypeError, /:"\\u3042"/) {1|:"\u{3042}"}
assert_raise_with_message(TypeError, /:"\\u3042"/) {1^:"\u{3042}"}
+ assert_raise_with_message(TypeError, /:\u{3044}/) {1+"\u{3044}".to_sym}
+ assert_raise_with_message(TypeError, /:\u{3044}/) {1&"\u{3044}".to_sym}
+ assert_raise_with_message(TypeError, /:\u{3044}/) {1|"\u{3044}".to_sym}
+ assert_raise_with_message(TypeError, /:\u{3044}/) {1^"\u{3044}".to_sym}
bug10711 = '[ruby-core:67405] [Bug #10711]'
exp = "1.2 can't be coerced into Integer"