Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Disallow positions < 0 on index/rindex, bartolin++
  • Loading branch information
lizmat committed Nov 21, 2015
1 parent a8812c0 commit fa3ce11
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/Cool.pm
Expand Up @@ -209,6 +209,11 @@ my class Cool { # declared in BOOTSTRAP
}
}
}
fail X::OutOfRange.new(
:what("Position in index"),
:got($i),
:range("0..{self.chars}"),
) if $i < 0;
$i = nqp::index(
nqp::unbox_s(self.Str),
nqp::unbox_s($needle),
Expand All @@ -232,6 +237,11 @@ my class Cool { # declared in BOOTSTRAP
}
}
}
fail X::OutOfRange.new(
:what("Position in rindex"),
:got($i),
:range("0..{self.chars}"),
) if $i < 0;
$i = nqp::rindex(
nqp::unbox_s(self.Str),
nqp::unbox_s($needle),
Expand Down

0 comments on commit fa3ce11

Please sign in to comment.