summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-22 12:21:47 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-22 12:26:43 +0900
commitd5f50463c2b5c5263aa45c58f3f4ec73de8868d5 (patch)
tree34b9190f6aef057003dc7e02b1040a7596965d4f /complex.c
parentd0b17a4d203b0838e2290bcc52a647e045596b59 (diff)
[Bug #18937] Coerce non-Numeric into Complex at comparisons
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/complex.c b/complex.c
index d625ced7fa..ae40fa7355 100644
--- a/complex.c
+++ b/complex.c
@@ -1121,7 +1121,10 @@ nucomp_real_p(VALUE self)
static VALUE
nucomp_cmp(VALUE self, VALUE other)
{
- if (nucomp_real_p(self) && k_numeric_p(other)) {
+ if (!k_numeric_p(other)) {
+ return rb_num_coerce_cmp(self, other, idCmp);
+ }
+ if (nucomp_real_p(self)) {
if (RB_TYPE_P(other, T_COMPLEX) && nucomp_real_p(other)) {
get_dat2(self, other);
return rb_funcall(adat->real, idCmp, 1, bdat->real);