[ruby-core:91158] [Ruby trunk Bug#15525] Complex(nil, exception: false) and Rational(nil, exception: false) raises an error

From: naruse@...
Date: 2019-01-18 04:19:38 UTC
List: ruby-core #91158
Issue #15525 has been updated by naruse (Yui NARUSE).

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.

----------------------------------------
Bug #15525: Complex(nil, exception: false) and Rational(nil, exception: false) raises an error
https://bugs.ruby-lang.org/issues/15525#change-76389

* Author: ibylich (Ilya Bylich)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
* Backport: 2.4: DONTNEED, 2.5: DONTNEED, 2.6: DONE
----------------------------------------
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)
~~~




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next