diff --git a/src/core/Iterator.pm6 b/src/core/Iterator.pm6 index d80fa62b6d0..29424508bf6 100644 --- a/src/core/Iterator.pm6 +++ b/src/core/Iterator.pm6 @@ -27,16 +27,16 @@ my role Iterator { # pushed, or IterationEnd if it reached the end of the iteration. method push-exactly($target, int $n) { nqp::stmts( - (my int $i = -1), + (my int $todo = nqp::add_i($n,1)), nqp::until( # doesn't sink - nqp::isge_i($i = nqp::add_i($i,1),$n) + nqp::not_i($todo = nqp::sub_i($todo,1)) || nqp::eqaddr((my $pulled := self.pull-one),IterationEnd), $target.push($pulled) # don't .sink $pulled here, it can be a Seq ), nqp::if( nqp::eqaddr($pulled,IterationEnd), IterationEnd, - $i + $n ) ) }