Issue #12485 has been updated by jeremyevans0 (Jeremy Evans).

File rational-denom-to_int.patch added

I'm not sure if this is considered a bug or not.  Rational will already try to convert numerator and denominator via `to_r`.  However, if we do want to convert via `to_int` if `to_r` is not defined, the attached patch should implement it.

----------------------------------------
Bug #12485: Kernel.Rational raises TypeError though given denominator returns 1 by to_int
https://bugs.ruby-lang.org/issues/12485#change-80002

* Author: mrkn (Kenta Murata)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Is it an intentional behavior?

```ruby
class << (o = Object.new)
  def to_int
    1
  end
end

Rational(1, o)  #=> TypeError: not an integer
```

---Files--------------------------------
rational.c.diff (539 Bytes)
rational-denom-to_int.patch (1.73 KB)


-- 
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>