Tuple type don't inherit as expected

just did some experimentations with Tuple types. Take the following example

d = Dict{Int, Int}
d_unionall = Type{T} where T <: Dict
u = Union{String, Int}
u_unionall = Type{T} where T>:String
isa(d, d_unionall)  # true
isa(u, u_unionall)  # true

then the respective Tuple combination of both does not work

isa((d, u), Tuple{d_unionall, u_unionall})  # false :-( 

EDIT: subtyping works like expected

Tuple{Type{d}, Type{u}} <: Tuple{d_unionall, u_unionall}  # true :-)

anyone an idea what is going on here?

julia> isa((Int,), Tuple{Type{Int}})
julia> isa.((Int,), (Type{Int},))
1 Like

The issue you are facing is the same as

julia> (Float64, ) isa Tuple{Type{<:AbstractFloat}}

I don’t think you can use Type except in the outermost position.

You can use a Tuple type and form the Union outside, eg

julia> Tuple{Float64, Int} isa (Type{Tuple{T,S}} where {T <: AbstractFloat, S <: Integer})
1 Like

thanks a lot!

just misunderstood how isa works obviously

still there is confusion on my side.

Why is the following not working?

julia> (Int, String) :: Tuple{Type{Int}, Type{String}}
ERROR: TypeError: in typeassert, expected Tuple{Type{Int64},Type{String}}, got Tuple{DataType,DataTy