Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
all ranges autotruncate on subscripting overrun
  • Loading branch information
TimToady committed Sep 2, 2014
1 parent 0a4af1c commit a8df1c9
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/core/array_slice.pm
Expand Up @@ -2,16 +2,19 @@

sub POSITIONS (\SELF, \pos) { # handle possible infinite slices
my $positions = pos.flat;
$positions.gimme(*);
return $positions.map( {
$_ ~~ Callable ?? $_(|(SELF.elems xx $_.count)) !! $_
} ).eager.Parcel unless $positions.infinite;

my $list = SELF.list;
$positions.map( {
last if $_ >= $list.gimme( $_ + 1 );
$_;
} ).eager.Parcel;
if pos ~~ Range || ($positions.gimme(*) && $positions.infinite) {
my $list = SELF.list;
$positions.map( {
last if $_ >= $list.gimme( $_ + 1 );
$_;
} ).eager.Parcel;
}
else {
$positions.map( {
$_ ~~ Callable ?? $_(|(SELF.elems xx $_.count)) !! $_
} ).eager.Parcel;
}
}

my class X::NYI { ... }
Expand Down

0 comments on commit a8df1c9

Please sign in to comment.