diff options
author | Jeremy Evans <[email protected]> | 2021-05-12 15:06:12 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2021-05-12 19:30:05 -0700 |
commit | 9ce29c94d82c6bf278b1be088435726a9c47e225 (patch) | |
tree | 56bc4e69a023a2576a12b72a097dd9b50b057e0a /compile.c | |
parent | 11ae581a4a7f5d5f5ec6378872eab8f25381b1b9 (diff) |
Avoid improper optimization of case statements mixed integer/rational/complex
Fixes [Bug #17857]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4496
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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; } |