From 62c17a2f21b47243071075cbef37fe72b6ecd0ff Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 12 Jan 2019 05:02:58 +0000 Subject: No TypeError at nil if exception: false [ruby-core:91021] [Bug #15525] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'rational.c') diff --git a/rational.c b/rational.c index 1642bc3a7d..207c4c46b3 100644 --- a/rational.c +++ b/rational.c @@ -2559,8 +2559,10 @@ nurat_convert(VALUE klass, VALUE numv, VALUE denv, int raise) VALUE a1 = numv, a2 = denv; int state; - if (NIL_P(a1) || NIL_P(a2)) + if (NIL_P(a1) || NIL_P(a2)) { + if (!raise) return Qnil; rb_raise(rb_eTypeError, "can't convert nil into Rational"); + } if (RB_TYPE_P(a1, T_COMPLEX)) { if (k_exact_zero_p(RCOMPLEX(a1)->imag)) -- cgit v1.2.3