Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
nqp::unbox_i should really check for bigints
This reverts commit 9f58110.
  • Loading branch information
lizmat committed Aug 22, 2015
1 parent a20db8f commit 40079e8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/core/Cool.pm
Expand Up @@ -218,10 +218,11 @@ my class Cool { # declared in BOOTSTRAP
$i < 0 ?? Nil !! nqp::box_i($i,Int);
}
multi method index(Cool:D: Str(Cool) $needle, Int(Cool) $pos) {
my str $str = nqp::unbox_s(self.Str);
my int $i = $pos < 0 || $pos > nqp::chars($str)
?? -1
!! nqp::index($str, nqp::unbox_s($needle), nqp::unbox_i($pos));
my int $i = nqp::index(
nqp::unbox_s(self.Str),
nqp::unbox_s($needle),
nqp::unbox_i($pos)
);
$i < 0 ?? Nil !! nqp::box_i($i,Int);
}

Expand All @@ -231,10 +232,11 @@ my class Cool { # declared in BOOTSTRAP
$i < 0 ?? Nil !! nqp::box_i($i,Int);
}
multi method rindex(Cool:D: Str(Cool) $needle, Int(Cool) $pos) {
my str $str = nqp::unbox_s(self.Str);
my int $i = $pos < 0 || $pos > nqp::chars($str)
?? -1
!! nqp::rindex($str, nqp::unbox_s($needle), nqp::unbox_i($pos));
my int $i = nqp::rindex(
nqp::unbox_s(self.Str),
nqp::unbox_s($needle),
nqp::unbox_i($pos)
);
$i < 0 ?? Nil !! nqp::box_i($i,Int);
}

Expand Down

0 comments on commit 40079e8

Please sign in to comment.