Skip to content

Regression in collect(Iterators.flatten((some_values..., ))) on the main branch #56783

Open
@bvdmitri

Description

The following code fails on the e0656ac

julia> collect(Iterators.flatten((1, )))
ERROR: MethodError: no method matching promote_typejoin(::Type{Int64})
The function `promote_typejoin` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  promote_typejoin(::Any, ::Any)
   @ Base promotion.jl:174

Stacktrace:
 [1] eltype(::Type{Base.Iterators.Flatten{Tuple{Int64}}})
   @ Base.Iterators ./iterators.jl:1205
 [2] eltype(x::Base.Iterators.Flatten{Tuple{Int64}})
   @ Base ./abstractarray.jl:241
 [3] _collect(cont::UnitRange{Int64}, itr::Base.Iterators.Flatten{Tuple{Int64}}, ::Base.HasEltype, isz::Base.HasLength)
   @ Base ./array.jl:733
 [4] collect(itr::Base.Iterators.Flatten{Tuple{Int64}})
   @ Base ./array.jl:727
 [5] top-level scope
   @ REPL[2]:1

julia> versioninfo()
Julia Version 1.12.0-DEV.1734
Commit e0656ac017 (2024-12-08 21:48 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin24.1.0)
  CPU: 11 × Apple M3 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, apple-m3)
Threads: 1 default, 0 interactive, 1 GC (on 5 virtual cores)

Works fine in 1.10.7 and 1.11.2

julia> collect(Iterators.flatten((1, ))) 
1-element Vector{Int64}:
 1

julia> versioninfo() # also works on 1.10.7
Julia Version 1.11.2
Commit 5e9a32e7af2 (2024-12-01 20:02 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 11 × Apple M3 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 1 default, 0 interactive, 1 GC (on 5 virtual cores)

Interestingly enough, this works fine

julia> collect(Iterators.flatten((1, (1, ))))
2-element Vector{Int64}:
 1
 1

and also this

julia> collect(Iterators.flatten((1, (1, ), 1)))
3-element Vector{Int64}:
 1
 1
 1

but not this

julia> collect(Iterators.flatten((1, 1, 1)))
ERROR: MethodError: no method matching promote_typejoin(::Type{Int64}, ::Type{Int64}, ::Type{Int64})
The function `promote_typejoin` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  promote_typejoin(::Any, ::Any)

So yeah the idea in the original code that the arguments might or might just number or other collections, previously it was possible to mix those.

More examples of seemingly broken behaviour

julia> a = 1
1

julia> collect(Iterators.flatten((a, )))
ERROR: MethodError: no method matching promote_typejoin(::Type{Int64})
The function `promote_typejoin` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  promote_typejoin(::Any, ::Any)
   @ Base promotion.jl:174

Stacktrace:
 [1] eltype(::Type{Base.Iterators.Flatten{Tuple{Int64}}})
   @ Base.Iterators ./iterators.jl:1205
 [2] eltype(x::Base.Iterators.Flatten{Tuple{Int64}})
   @ Base ./abstractarray.jl:241
 [3] _collect(cont::UnitRange{Int64}, itr::Base.Iterators.Flatten{Tuple{Int64}}, ::Base.HasEltype, isz::Base.HasLength)
   @ Base ./array.jl:733
 [4] collect(itr::Base.Iterators.Flatten{Tuple{Int64}})
   @ Base ./array.jl:727
 [5] top-level scope
   @ REPL[11]:1

julia> collect(Iterators.flatten((a, a)))
2-element Vector{Int64}:
 1
 1

julia> collect(Iterators.flatten((a, a, a)))
ERROR: MethodError: no method matching promote_typejoin(::Type{Int64}, ::Type{Int64}, ::Type{Int64})
The function `promote_typejoin` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  promote_typejoin(::Any, ::Any)
   @ Base promotion.jl:174

Stacktrace:
 [1] eltype(::Type{Base.Iterators.Flatten{Tuple{Int64, Int64, Int64}}})
   @ Base.Iterators ./iterators.jl:1205
 [2] eltype(x::Base.Iterators.Flatten{Tuple{Int64, Int64, Int64}})
   @ Base ./abstractarray.jl:241
 [3] _collect(cont::UnitRange{Int64}, itr::Base.Iterators.Flatten{Tuple{…}}, ::Base.HasEltype, isz::Base.HasLength)
   @ Base ./array.jl:733
 [4] collect(itr::Base.Iterators.Flatten{Tuple{Int64, Int64, Int64}})
   @ Base ./array.jl:727
 [5] top-level scope
   @ REPL[13]:1
Some type information was truncated. Use `show(err)` to see complete types.

All of the above works fine in 1.11.2.

Initially caught here with the following stacktrace

MethodError: no method matching promote_typejoin(::Type{Symbol}, ::Type{Symbol}, ::Type{Symbol}, ::Type{Symbol})
  The function `promote_typejoin` exists, but no method is defined for this combination of argument types.
  
  Closest candidates are:
    promote_typejoin(::Any, ::Any)
     @ Base promotion.jl:174
  
  Stacktrace:
    [1] eltype(::Type{Base.Iterators.Flatten{NTuple{4, Tuple{Symbol}}}})
      @ Base.Iterators ./iterators.jl:1205
    [2] eltype(x::Base.Iterators.Flatten{NTuple{4, Tuple{Symbol}}})
      @ Base ./abstractarray.jl:241
    [3] _collect(cont::UnitRange{Int64}, itr::Base.Iterators.Flatten{NTuple{4, Tuple{Symbol}}}, ::Base.HasEltype, isz::Base.HasLength)
      @ Base ./array.jl:733
    [4] collect(itr::Base.Iterators.Flatten{NTuple{4, Tuple{Symbol}}})

Steps to reproduce are

julia> collect(Iterators.flatten((:a, :b, :c, :d)))
ERROR: MethodError: no method matching promote_typejoin(::Type{Any}, ::Type{Any}, ::Type{Any}, ::Type{Any})
The function `promote_typejoin` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  promote_typejoin(::Any, ::Any)
   @ Base promotion.jl:174

Stacktrace:
 [1] eltype(::Type{Base.Iterators.Flatten{NTuple{4, Symbol}}})
   @ Base.Iterators ./iterators.jl:1205
 [2] eltype(x::Base.Iterators.Flatten{NTuple{4, Symbol}})
   @ Base ./abstractarray.jl:241
 [3] _collect(cont::UnitRange{Int64}, itr::Base.Iterators.Flatten{NTuple{…}}, ::Base.HasEltype, isz::Base.SizeUnknown)
   @ Base ./array.jl:737
 [4] collect(itr::Base.Iterators.Flatten{NTuple{4, Symbol}})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    regressionRegression in behavior compared to a previous versionregression 1.12Regression in the 1.12 release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions