Skip to content

Commit

Permalink
Inspect dynamic symbol as well as static symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Aug 25, 2019
1 parent b341e98 commit 5decf66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numeric.c
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions test/ruby/test_numeric.rb
Expand Up @@ -26,6 +26,10 @@ def test_coerce
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"
Expand Down

0 comments on commit 5decf66

Please sign in to comment.