Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle splice with offset past end
  • Loading branch information
lizmat committed Jul 9, 2015
1 parent 6a000f8 commit 261accb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/core/List.pm
Expand Up @@ -438,11 +438,17 @@ my class List does Positional { # declared in BOOTSTRAP

if $SINK {
nqp::splice($!items, nqp::getattr(@v, List, '$!items'), $o, $s);
Nil;
}
else {
my @ret := $expected =:= Mu ?? Array.new !! Array[$expected].new;
@ret = self[$o..($o + $s - 1)] if $s;
nqp::splice($!items, nqp::getattr(@v, List, '$!items'), $o, $s);
if @v || $o < $elems {
@ret = self[$o..($o + $s - 1)] if $s;
nqp::splice($!items,nqp::getattr(@v,List,'$!items'),$o,$s);
}
else { # offset past end, and nothing to put in, don't vivify
@ret = ($expected =:= Mu ?? Any !! $expected) xx $s;
}
@ret;
}
}
Expand Down

0 comments on commit 261accb

Please sign in to comment.