summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-18 04:19:32 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-18 04:19:32 +0000
commit283b3d8f99c01a13e727b2edf0a7643a67d16361 (patch)
treef1e2753826bda61aa0e0f259163dd0641c813434 /complex.c
parentb9289589d66efec4a5953e8a964019201aaeca9e (diff)
merge revision(s) 66796,66797: [Backport #15525]
No TypeError at nil if exception: false [ruby-core:91021] [Bug #15525] No FloatDomainError at non-finitive number if exception: false [ruby-core:91021] [Bug #15525] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@66862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/complex.c b/complex.c
index ab50daabaf..cc798cccca 100644
--- a/complex.c
+++ b/complex.c
@@ -1939,8 +1939,10 @@ to_complex(VALUE val)
static VALUE
nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise)
{
- 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 Complex");
+ }
if (RB_TYPE_P(a1, T_STRING)) {
a1 = string_to_c_strict(a1, raise);