summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compile.c3
-rw-r--r--test/ruby/test_case.rb12
2 files changed, 15 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 2e10659afa..a9c2f96781 100644
--- a/compile.c
+++ b/compile.c
@@ -4537,6 +4537,9 @@ rb_node_case_when_optimizable_literal(const NODE *const node)
modf(RFLOAT_VALUE(v), &ival) == 0.0) {
return FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival);
}
+ if (RB_TYPE_P(v, T_RATIONAL) || RB_TYPE_P(v, T_COMPLEX)) {
+ return Qundef;
+ }
if (SYMBOL_P(v) || rb_obj_is_kind_of(v, rb_cNumeric)) {
return v;
}
diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb
index 77612a8945..4a0f1bf78d 100644
--- a/test/ruby/test_case.rb
+++ b/test/ruby/test_case.rb
@@ -102,6 +102,18 @@ class TestCase < Test::Unit::TestCase
else
assert(false)
end
+ case 0
+ when 0r
+ assert(true)
+ else
+ assert(false)
+ end
+ case 0
+ when 0i
+ assert(true)
+ else
+ assert(false)
+ end
end
def test_method_missing