Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix problem with two sequence operators being active at the same time…
… (RT #98790).

This commit doesn't fix the actual underlying problem, which is
that lexically nested subs aren't being cloned properly.  jnthn++
is working on that issue.  Instead, this patch simply inlines the
nested sub instead of calling it separately.
  • Loading branch information
pmichaud committed Sep 9, 2011
1 parent f9d94fe commit 569deeb
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/core/operators.pm
Expand Up @@ -33,16 +33,6 @@ sub SEQUENCE($left, $right, :$exclude_end) {
my $tail := ().list;

my sub generate($code) {
my $count = $code.count;
my $value;
while 1 {
$tail.munch($tail.elems - $count);
$value := $code(|$tail);
last if $value ~~ $endpoint;
$tail.push($value);
take $value;
}
$value;
}

my sub succpred($cmp) {
Expand Down Expand Up @@ -100,9 +90,20 @@ sub SEQUENCE($left, $right, :$exclude_end) {
elsif $tail.elems == 0 {
$code = {()}
}
$value = $code.defined
?? generate($code)
!! (sub { fail "unable to deduce sequence" })();

if $code.defined {
my $count = $code.count;
while 1 {
$tail.munch($tail.elems - $count);
$value := $code(|$tail);
last if $value ~~ $endpoint;
$tail.push($value);
take $value;
}
}
else {
$value = (sub { fail "unable to deduce sequence" })();
}
}
take $value unless $exclude_end;
}, :$infinite), @right).list;
Expand Down

0 comments on commit 569deeb

Please sign in to comment.