Permalink
Browse files

We cannot coerce Inf/-Inf/NaN to a Rat

So fail instead of silently returning Inf/-Inf/NaN

See http://irclog.perlgeek.de/p6dev/2016-05-02#i_12423404
  • Loading branch information...
lizmat committed May 2, 2016
1 parent 949a7c7 commit e2f1fa735132b9f43e7aa9390b42f42a17ea815f
Showing with 2 additions and 5 deletions.
  1. +2 −5 src/core/Num.pm
@@ -36,11 +36,8 @@ my class Num does Real { # declared in BOOTSTRAP
}

method Rat(Num:D: Real $epsilon = 1.0e-6, :$fat) {
if nqp::isnanorinf(nqp::unbox_n(self)) {
return self;
}

(self == Inf || self == -Inf) && fail("Cannot coerce Inf to a Rat");
fail("Cannot coerce {self} to a Rat")
if nqp::isnanorinf(nqp::unbox_n(self));

my Num $num = self;
my Int $signum = $num < 0 ?? -1 !! 1;

0 comments on commit e2f1fa7

Please sign in to comment.