Skip to content

constructing tuples: some reasonable Union tuple type constructors throw #53181

Open
@nsajko

Description

@nsajko
julia> Tuple{Int,Int}(Any[1.0,2.0])
(1, 2)

julia> Union{Tuple{Int,Int},Tuple{Float64}}(Any[1.0,2.0])
ERROR: MethodError: no method matching argtail()

Closest candidates are:
  argtail(::Any, ::Any...)
   @ Base essentials.jl:466

Stacktrace:
 [1] tuple_type_tail(T::Type)
   @ Base ./tuple.jl:446
 [2] tuple_type_tail(T::Type)
   @ Base ./tuple.jl:438
 [3] _totuple
   @ ./tuple.jl:472 [inlined]
 [4] _totuple
   @ ./tuple.jl:473 [inlined]
 [5] Union{Tuple{Float64}, Tuple{Int64, Int64}}(itr::Vector{Any})
   @ Base ./tuple.jl:455
 [6] top-level scope
   @ REPL[4]:1

julia> versioninfo()
Julia Version 1.11.0-DEV.1451
Commit f117a500ca9 (2024-02-01 15:38 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

IMO we should instead have (1, 2) === Union{Tuple{Int,Int},Tuple{Float64}}(Any[1.0,2.0]). Working on a PR that should fix this, and other, issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    collectionsData structures holding multiple items, e.g. setstypes and dispatchTypes, subtyping and method dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions