Skip to content

Commit

Permalink
Fix R::I::Rotor calling .pull-one one too many times
Browse files Browse the repository at this point in the history
Rakudo::Iterator::Rotor was calling .pull-one too many times causing
error. This type of error has been encountered before, on another
code-path involving Rakudo::Iterator::Batch. zoffix++ for pointing
this out.

Addresses [Issue 1397](#1397)

See commit for more details:
    bcd902a
  • Loading branch information
jstuder-gh committed Jan 14, 2018
1 parent 029226f commit 4a82b4b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/Rakudo/Iterator.pm
Expand Up @@ -2795,6 +2795,7 @@ class Rakudo::Iterator {
has $!cycle;
has $!buffer;
has int $!complete;
has int $!is-exhausted = 0;
method !SET-SELF(\iterator,\cycle,\partial) {
nqp::stmts(
($!iterator := iterator),
Expand All @@ -2812,6 +2813,9 @@ class Rakudo::Iterator {
)
}
method pull-one() is raw {
nqp::if(
$!is-exhausted,
IterationEnd,
nqp::stmts(
nqp::if(
nqp::istype((my $todo := $!cycle.pull-one),Pair),
Expand Down Expand Up @@ -2896,6 +2900,7 @@ class Rakudo::Iterator {
nqp::if(
nqp::not_i(nqp::elems($!buffer))
|| (nqp::eqaddr($pulled,IterationEnd)
&& ($!is-exhausted = 1)
&& $!complete
&& nqp::islt_i(nqp::elems($!buffer),$elems)
),
Expand Down Expand Up @@ -2946,6 +2951,7 @@ class Rakudo::Iterator {
)
)
)
)
}
method is-lazy() { $!iterator.is-lazy }
}.new(iterator,cycle,partial)
Expand Down

0 comments on commit 4a82b4b

Please sign in to comment.