From dc146babf47a84bbd1f176d766637d4a40327019 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 26 Feb 2024 10:48:54 +0900 Subject: [Bug #20296] Clear errinfo when `exception: false` --- complex.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 28d5b2058b..8c32c60523 100644 --- a/complex.c +++ b/complex.c @@ -2323,8 +2323,11 @@ nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise) return a1; /* should raise exception for consistency */ if (!k_numeric_p(a1)) { - if (!raise) - return rb_protect(to_complex, a1, NULL); + if (!raise) { + a1 = rb_protect(to_complex, a1, NULL); + rb_set_errinfo(Qnil); + return a1; + } return to_complex(a1); } } -- cgit v1.2.3