Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some failure mode tweaks
  • Loading branch information
lizmat committed Jul 9, 2015
1 parent 01a60df commit 1b537b9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/List.pm
Expand Up @@ -399,7 +399,7 @@ my class List does Positional { # declared in BOOTSTRAP
@ret;
}
multi method splice(List:D: $offset=0, $size=Whatever, *@values, :$SINK) {
fail X::Cannot::Infinite.new(:action<.splice in>) if @values.infinite;
fail X::Cannot::Infinite.new(:action<splice in>) if @values.infinite;

self.gimme(*);
my $elems = self.elems;
Expand All @@ -409,9 +409,9 @@ my class List does Positional { # declared in BOOTSTRAP
?? $elems
!! $offset;
X::OutOfRange.new(
:what<Offset argument to List.splice>,
:got($offset),
:range("0..$elems"),
:what<Offset argument to List.splice>,
:got($o),
:range("0..$elems"),
).fail if $o < 0 || $o > $elems; # one after list allowed for "push"

my int $s = nqp::istype($size,Callable)
Expand All @@ -420,9 +420,9 @@ my class List does Positional { # declared in BOOTSTRAP
?? $elems - ($o min $elems)
!! $size.Int;
X::OutOfRange.new(
:what<Size argument to List.splice>,
:got($size),
:range("0..^{$elems - $o}"),
:what<Size argument to List.splice>,
:got($s),
:range("0..^{$elems - $o}"),
).fail if $s < 0;

# need to enforce type checking
Expand Down

0 comments on commit 1b537b9

Please sign in to comment.