Skip to content

Commit

Permalink
Fix a whole ton of methods on cached Seqs
Browse files Browse the repository at this point in the history
When Seq is cached, its $!list gets .DEFINITE and we can get
cached stuff from it. However, several methods do not check
for presence of $!list cache and assume the absence of $!iter means
the Seq has been consumed and there is no cache.

Fixes incorrect "Seq has been consumed; try caching" error for:
infix:<eqv>, .iterator, .Slip, .join, .List, .list, .eager,
.Array, .is-lazy, and .sink

Bug find: https://irclog.perlgeek.de/perl6-dev/2017-05-03#i_14524925
  • Loading branch information
zoffixznet committed May 3, 2017
1 parent 91fb307 commit 400f4ec
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/Seq.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,23 @@ my class Seq is Cool does Iterable does PositionalBindFailover {
($!iter := Iterator),
iter
),
X::Seq::Consumed.new.throw
nqp::if(
$!list.DEFINITE,
$!list.iterator,
X::Seq::Consumed.new.throw
)
)
}

multi method is-lazy(Seq:D:) {
nqp::if(
$!iter.DEFINITE,
$!iter.is-lazy,
X::Seq::Consumed.new.throw
nqp::if(
$!list.DEFINITE,
$!list.is-lazy,
X::Seq::Consumed.new.throw
)
)
}

Expand Down Expand Up @@ -192,6 +200,10 @@ my class Seq is Cool does Iterable does PositionalBindFailover {
nqp::stmts(
$!iter.sink-all,
($!iter := Iterator)
),
nqp::if(
$!list.DEFINITE,
$!list.iterator.sink-all
)
)
}
Expand Down

0 comments on commit 400f4ec

Please sign in to comment.