summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2021-05-07 13:31:15 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2021-05-12 10:30:46 +0900
commite1eff837cf12a8e813de9d4ff2db50c9b68b86b5 (patch)
treed49f7038d6a1b8d87bfe282186c9e02c0a95c32e /compile.c
parentcc0dc67bbbe1951ff90004bc987f78545625d772 (diff)
cdhash_cmp: recursively apply
For instance a rational's numerator can be a bignum. Comparison using C's == can be insufficient.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4469
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index d9894d27d8..056b487803 100644
--- a/compile.c
+++ b/compile.c
@@ -2008,12 +2008,12 @@ cdhash_cmp(VALUE val, VALUE lit)
else if (tlit == T_RATIONAL) {
const struct RRational *rat1 = RRATIONAL(val);
const struct RRational *rat2 = RRATIONAL(lit);
- return (rat1->num == rat2->num) && (rat1->den == rat2->den);
+ return cdhash_cmp(rat1->num, rat2->num) && cdhash_cmp(rat1->den, rat2->den);
}
else if (tlit == T_COMPLEX) {
const struct RComplex *comp1 = RCOMPLEX(val);
const struct RComplex *comp2 = RCOMPLEX(lit);
- return (comp1->real == comp2->real) && (comp1->imag == comp2->imag);
+ return cdhash_cmp(comp1->real, comp2->real) && cdhash_cmp(comp1->imag, comp2->imag);
}
else {
UNREACHABLE_RETURN(-1);