All of this was done to make Inf.Rat.Num roundtrip. I suggest thus that we make Inf.Rat fail, like we let Inf.Int fail.
> On 06 Aug 2016, at 05:18, Zoffix Znet (via RT) <[email protected]> > wrote: > > # New Ticket Created by Zoffix Znet > # Please include the string: [perl #128857] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=128857 > > > > TimToady's comments on the matter: > http://irclog.perlgeek.de/perl6-dev/2016-08-06#i_12976358 > > I stumbled on this while examining > https://rt.perl.org/Ticket/Display.html?id=127341#ticket-history > > It seems this commit had a consequence that .Rat on an Inf or NaN does not > actually return an object that can be stored in a Rat: > https://github.com/rakudo/rakudo/commit/498d0a4ae4572a84f80c0c572632e12017d779f3 > > The issue is now there's no guarantee that a .Rat can be used as a Rat and > thus the programmer has to perform additional checks. > > Here are some examples of the issue: > > <Zoffix> m: say ∞.Rat ~~ Rat > <camelia> rakudo-moar 589061: OUTPUT«False» > <Zoffix> m: Duration.new: NaN > <camelia> rakudo-moar 589061: OUTPUT«Type check failed in assignment to > $!tai; expected Rat but got Rational[Num,Int] (?) in block <unit> at <tmp> > line 1» > <Zoffix> m: Duration.new: ∞ > <camelia> rakudo-moar 589061: OUTPUT«Type check failed in assignment to > $!tai; expected Rat but got Rational[Num,Int] (?) in block <unit> at <tmp> > line 1» > <Zoffix> m: class { has Rat $.secret-ingredient; method new ($v) { > self.bless: secret-ingredient => $v.Rat } }.new: ∞ > <camelia> rakudo-moar 589061: OUTPUT«Type check failed in assignment to > $!secret-ingredient; expected Rat but got Rational[Num,Int] (?) in method > new at <tmp> line 1 in block <unit> at <tmp> line 1» > <Zoffix> m: my Rat $x = ∞.Rat > <camelia> rakudo-moar 589061: OUTPUT«Type check failed in assignment to $x; > expected Rat but got Rational[Num,Int] (?) in block <unit> at <tmp> line > 1» > > > -- > Cheers, > ZZ | https://twitter.com/zoffix
