diff options
author | 卜部昌平 <[email protected]> | 2021-05-07 11:07:11 +0900 |
---|---|---|
committer | 卜部昌平 <[email protected]> | 2021-05-12 10:30:46 +0900 |
commit | d0e6c6e682b9ba2b0309a5177933a0628e8ef316 (patch) | |
tree | a37b7f7d973b2782687786e41817825a41fefc32 /compile.c | |
parent | 2bc293e899c9d32dcd794a73de8925c49ecf8f15 (diff) |
cdhash_cmp: rational literals with fractions
Nobu kindly pointed out that rational literals can have fractions.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4469
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -2006,8 +2006,9 @@ cdhash_cmp(VALUE val, VALUE lit) return rb_float_cmp(lit, val); } else if (tlit == T_RATIONAL) { - /* Rational literals don't have fractions. */ - return cdhash_cmp(val, rb_rational_num(lit)); + const struct RRational *dat1 = RRATIONAL(val); + const struct RRational *dat2 = RRATIONAL(lit); + return (dat1->num == dat2->num) && (dat1->den == dat2->den); } else { UNREACHABLE_RETURN(-1); |