diff --git a/base/iterators.jl b/base/iterators.jl index 8be343e4060d4..e22fe75ce31b5 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -993,6 +993,7 @@ iterate(::ProductIterator{Tuple{}}, state) = nothing done1 === true || return done1 # false or missing return _pisdone(tail(iters), tail(states)) # check tail end +@inline isdone(::ProductIterator{Tuple{}}, states) = true @inline isdone(P::ProductIterator, states) = _pisdone(P.iterators, states) @inline _piterate() = () diff --git a/test/iterators.jl b/test/iterators.jl index bbcd81ddea82a..fc3685ed4314b 100644 --- a/test/iterators.jl +++ b/test/iterators.jl @@ -859,3 +859,11 @@ end @test cumprod(x + 1 for x in 1:3) == [2, 6, 24] @test accumulate(+, (x^2 for x in 1:3); init=100) == [101, 105, 114] end + +@testset "empty product iterators" begin + v = nothing + for (z,) in zip(Iterators.product()) + v = z + end + @test v == () +end