Skip to content

Commit fd92d74

Browse files
sasi591KristofferC
authored and
KristofferC
committed
Fix isdone for empty product iterators, fixes #43921 (#43947)
* Fix the issue #43921 * add a test Co-authored-by: Kristoffer <[email protected]> (cherry picked from commit b8a77da)
1 parent 8830c26 commit fd92d74

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

base/iterators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ iterate(::ProductIterator{Tuple{}}, state) = nothing
10411041
done1 === true || return done1 # false or missing
10421042
return _pisdone(tail(iters), tail(states)) # check tail
10431043
end
1044+
@inline isdone(::ProductIterator{Tuple{}}, states) = true
10441045
@inline isdone(P::ProductIterator, states) = _pisdone(P.iterators, states)
10451046

10461047
@inline _piterate() = ()

test/iterators.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,3 +902,11 @@ end
902902
@test last(Iterators.map(identity, 1:3)) == 3
903903
@test last(Iterators.filter(iseven, (Iterators.map(identity, 1:3)))) == 2
904904
end
905+
906+
@testset "empty product iterators" begin
907+
v = nothing
908+
for (z,) in zip(Iterators.product())
909+
v = z
910+
end
911+
@test v == ()
912+
end

0 commit comments

Comments
 (0)