Subtyping of Tuple's with abstract types and type variables

When checking for subtype relations of tuples with 2 or elements Julia does not find a match for a type variable on the right side if the types on the left side are abstract or have a common super type. The below examples are both true for R == Real. Is this intended and if so, why?

julia> Tuple{Real, Real} <: Tuple{R,R} where R
false
julia> Tuple{Int, UInt} <: Tuple{R, R} where R
false

Tuple{R, R} where R only allows subtypes of the form Tuple{Int, Int}, Tuple{UInt, UInt}, etc. i.e, both elemtens must be of same type.

On the other hand, the following is true:

Tuple{Int, UInt} <: Tuple{R, S} where {R, S}
4 Likes

I found a section in the manual about diagonal types that describes these rules that exist because tuples are used in dispatch. I solved my original problem by introducing the type variable somewhere else.

2 Likes