While empty array construction works well
julia> n=0;
julia> [u for u=1:n]
0-element Array{Int64,1}
and also the type is correctly inferred, I encountered this surprising error in a slightly more complex situation
julia> n=0;
julia> [(u,v) for u=1:n for v=1:10]
ERROR: ArgumentError: argument to Flatten must contain at least one iterator
in start(::Base.Flatten{Base.Generator{UnitRange{Int64},##73#75}}) at ./iterator.jl:599
in grow_to!(::Array{Tuple{Int64,Int64},1}, ::Base.Flatten{Base.Generator{UnitRange{Int64},##73#75}}) at ./array.jl:357
in collect(::Base.Flatten{Base.Generator{UnitRange{Int64},##73#75}}) at ./array.jl:273
in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
in macro expansion at ./REPL.jl:95 [inlined]
in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
Here is the culprit line
https://github.com/JuliaLang/julia/blob/e94007ea13f963e545534028dc967697f7267649/base/iterator.jl#L660
This one works well instead
julia> [(u,v) for u=1:10 for v=1:0]
0-element Array{Tuple{Int64,Int64},1}
Bye,
Carlo
This is intentional, and would require something like #18823. In the meantime I can try some Nullable tricks and see if it performs ok.
Hi, can I work on this issue if it is doable by a beginner?
Please help me with how and where to start. Thanks
Hopefully will be fixed by #25261.
this is fixed on master
julia> n=0;
julia> [(u,v) for u=1:n for v=1:10]
0-element Array{Tuple{Int64,Int64},1}