Actions
Bug #15525
closedComplex(nil, exception: false) and Rational(nil, exception: false) raises an error
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
Description
Each line below raises an error
Complex(:sym, 0, exception: false) # TypeError (not a real)
Complex(nil, exception: false) # TypeError (can't convert nil into Complex)
Complex(0, nil, exception: false) # TypeError (can't convert nil into Complex)
Complex(nil, 0, exception: false) # TypeError (can't convert nil into Complex)
Rational(nil, exception: false) # TypeError (can't convert nil into Rational)
Rational(nil, nil, exception: false) # TypeError (can't convert nil into Rational)
Looks like a bug, Integer(nil, exception: false)
and Float(nil, exception: false)
are not affected, both return nil
Also Integer(arg, exception: false)
raises an error for:
Integer(Float::NAN, exception: false) # FloatDomainError (NaN)
Integer(Float::INFINITY, exception: false) # FloatDomainError (Infinity)
Integer(-Float::INFINITY, exception: false) # FloatDomainError (-Infinity)
Updated by Eregon (Benoit Daloze) over 5 years ago
Found by specs added in https://github.com/ruby/spec/pull/648
Updated by nobu (Nobuyoshi Nakada) over 5 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r66796.
No TypeError at nil if exception: false
[ruby-core:91021] [Bug #15525]
Updated by nagachika (Tomoyuki Chikanaga) over 5 years ago
- Backport changed from 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN to 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED
Updated by naruse (Yui NARUSE) over 5 years ago
- Backport changed from 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED to 2.4: DONTNEED, 2.5: DONTNEED, 2.6: DONE
ruby_2_6 r66862 merged revision(s) 66796,66797.
Actions
Like0
Like0Like0Like0Like0