Skip to content

Commit

Permalink
Revert "Fix Any.skip: *-1 crash"
Browse files Browse the repository at this point in the history
This reverts commit 44ff0a2.
.tail(Callable) is not equivalent to .skip(Callable); spectest
from master branch catching this was not yet pulled into postrelease
branch when this commit was applied, so nothing was caught
  • Loading branch information
zoffixznet committed Jan 24, 2018
1 parent 6f594ce commit 494ffb6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core/Any-iterable-methods.pm
Expand Up @@ -1844,7 +1844,7 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
}

proto method tail(|) {*}
multi method tail() is raw {
multi method tail(Any:D:) is raw {
nqp::if(
nqp::eqaddr((my $pulled :=
Rakudo::Iterator.LastValue(self.iterator,'tail')),
Expand All @@ -1854,7 +1854,7 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
$pulled
)
}
multi method tail($n) {
multi method tail(Any:D: $n) {
Seq.new(
nqp::if(
nqp::istype($n,Callable),
Expand All @@ -1875,7 +1875,13 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
Seq.new( $iter.skip-one ?? $iter !! Rakudo::Iterator.Empty )
}
multi method skip(Whatever) { Seq.new(Rakudo::Iterator.Empty) }
multi method skip(Callable:D \w) { self.tail: w }
multi method skip(Callable:D $w) {
nqp::if(
nqp::isgt_i((my $tail := -($w(0).Int)),0),
self.tail($tail),
Seq.new(Rakudo::Iterator.Empty)
)
}
multi method skip(Int() $n) {
my $iter := self.iterator;
Seq.new( $iter.skip-at-least($n) ?? $iter !! Rakudo::Iterator.Empty )
Expand Down

0 comments on commit 494ffb6

Please sign in to comment.