> On 27 May 2017, at 23:22, Elizabeth Mattijsen <l...@dijkmat.nl> wrote:
>> On 27 May 2017, at 19:33, Marcel Timmerman <mt1...@gmail.com> wrote:
>> In perl6 version 2017.04.3-287-g3e7675a built on MoarVM version 
>> 2017.04-64-g6d5ea04
>> implementing Perl 6.c. I observe the following;
>> 
>> my Num $num = Inf;
>> my FatRat $f = $num.FatRat;
>> Type check failed in assignment to $f; expected FatRat but got 
>> Rational[Num,Int] (?)
>> in block <unit> at <unknown file> line 1
>> 
>> Inf.WHAT;                    # (Num)
>> Inf.FatRat.WHAT              # (Rational[Num,Int])
>> 
>> It boils down to not converting to FatRat while a defined number does;
>> my Num $num = 2.3e3;
>> $num.FatRat.WHAT;            # (FatRat)
>> 
>> 
>> This is the same for NaN.
>> 
>> If this is defined behavior, then there is no way to set NaN or Inf for 
>> FatRat (and for Rat too). Is there another way to accomplish this?
> 
> This feels like a bug.  Could you rakudobug it so it won’t fall through the 
> cracks?
> 
> FWIW, the golf is:
> 
> $ 6 'dd FatRat.new(Inf)'
> Type check failed in binding to parameter 'nu'; expected Int but got Num (Inf)
>  in block <unit> at -e line 1

Please disregard the above.

This is a problem that basically comes down to:

  $ 6 'say Int.Range.max.WHAT'
  (Num)

In other words: the maximum value of an Int is  *not* an Int.  To be able to 
support Inf in rationals, we use a hack to create a special type of Rat that 
allows for a Num numerator.

  https://github.com/rakudo/rakudo/blob/nom/src/core/Num.pm#L44

I’m not seeing a way around this at the moment.  But then I’m really tired now  
:-)

Reply via email to