Skip to content

Unions with empty tuple causes error in conversions #28915

@arbenson

Description

@arbenson

Minimal working example:

TupleType = Union{NTuple{0,Int64},NTuple{1,Int64}}
convert(TupleType, (1,))

The error is

ERROR: BoundsError: attempt to access Tuple{}
at index [1]
Stacktrace:
[1] tuple_type_head(::Type) at ./essentials.jl:175
[2] convert(::Type{Union{Tuple{}, Tuple{Int64}}}, ::Tuple{Int64}) at ./essentials.jl:269
[3] push!(::Array{Union{Tuple{}, Tuple{Int64}},1}, ::Tuple{Int64}) at ./array.jl:855
[4] top-level scope at none:0

This error comes up when I want to push tuples of type TupleType to, say, an instance of Vector{TupleTyple}.

This was not a problem in 0.6.2 but is a problem in 1.0.

julia> 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-7920HQ CPU @ 3.10GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

Metadata

Metadata

Assignees

Labels

types 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