Skip to content

"tuple must be non-empty" when iterating two nested Iterators.product #28753

@fjarri

Description

@fjarri

The code:

using Base.Iterators: product
println(collect(product(product())))

Expected:

(ProductIterator{Tuple{}}(()),)

(or something of that sort, in the real code I have

iters = product(product(...))
for x in iters
    for y in x
        ...
    end
end

)

Got:

ERROR: LoadError: ArgumentError: tuple must be non-empty
Stacktrace:
 [1] first(::Tuple{}) at ./tuple.jl:74
 [2] _pisdone at ./iterators.jl:803 [inlined]
 [3] isdone at ./iterators.jl:810 [inlined]
 [4] _pisdone at ./iterators.jl:804 [inlined]
 [5] isdone at ./iterators.jl:810 [inlined]
 [6] iterate at ./iterators.jl:842 [inlined]
 [7] copyto!(::Array{Tuple{Tuple{}},0}, ::Base.Iterators.ProductIterator{Tuple{Base.Iterators.ProductIterator{Tuple{}}}}) at ./abstractarray.jl:650
 [8] _collect(::UnitRange{Int64}, ::Base.Iterators.ProductIterator{Tuple{Base.Iterators.ProductIterator{Tuple{}}}}, ::Base.HasEltype, ::Base.HasShape{0}) at ./array.jl:563
 [9] collect(::Base.Iterators.ProductIterator{Tuple{Base.Iterators.ProductIterator{Tuple{}}}}) at ./array.jl:557
 [10] top-level scope at none:0
 [11] include at ./boot.jl:317 [inlined]
 [12] include_relative(::Module, ::String) at ./loading.jl:1038
 [13] include(::Module, ::String) at ./sysimg.jl:29
 [14] exec_options(::Base.JLOptions) at ./client.jl:229
 [15] _start() at ./client.jl:421

versioninfo():

Julia Version 1.0.0
Commit 5d4eaca (2018-08-08 20:58 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, haswell)

Metadata

Metadata

Assignees

No one assigned

    Labels

    iterationInvolves iteration or the iteration protocol

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions