summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
author卜部昌平 <[email protected]>2021-05-07 11:07:11 +0900
committer卜部昌平 <[email protected]>2021-05-12 10:30:46 +0900
commitd0e6c6e682b9ba2b0309a5177933a0628e8ef316 (patch)
treea37b7f7d973b2782687786e41817825a41fefc32 /compile.c
parent2bc293e899c9d32dcd794a73de8925c49ecf8f15 (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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index 9001fd14ff..341361dc78 100644
--- a/compile.c
+++ b/compile.c
@@ -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);