Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

another typed failure from Str.substr

  • Loading branch information...
commit 1fe39c7f4f078da8b64f3798bcb9893a38e75b3d 1 parent 65e2aae
@moritz moritz authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/core/Str.pm
View
8 src/core/Str.pm
@@ -92,9 +92,13 @@ my class Str does Stringy {
if $istart > $ichars;
$length = $length($ichars - $istart) if nqp::istype($length, Callable);
my int $ilength = $length.defined ?? $length.Int !! $ichars - $istart;
- fail "Negative length argument ($length) to .substr, use *{$ilength} if you want relative to the end"
+ X::OutOfRange.new(
+ what => 'Length argument to substr',
+ got => $length,
+ range => (0..*),
+ comment => "use *{$ilength} if you want to index relative to the end"
+ ).fail
if $ilength < 0;
-
nqp::p6box_s(nqp::substr($sself, $istart, $ilength));
}

0 comments on commit 1fe39c7

Please sign in to comment.
Something went wrong with that request. Please try again.