diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-08-22 12:21:47 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-08-22 12:26:43 +0900 |
commit | d5f50463c2b5c5263aa45c58f3f4ec73de8868d5 (patch) | |
tree | 34b9190f6aef057003dc7e02b1040a7596965d4f /complex.c | |
parent | d0b17a4d203b0838e2290bcc52a647e045596b59 (diff) |
[Bug #18937] Coerce non-Numeric into Complex at comparisons
Diffstat (limited to 'complex.c')
-rw-r--r-- | complex.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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); |