# Subtyping of Tuple's with abstract types and type variables

**URL:** https://discourse.julialang.org/t/subtyping-of-tuples-with-abstract-types-and-type-variables/32596
**Category:** General Usage
**Tags:** question
**Created:** [December 23, 2019, 12:59am UTC](https://discourse.julialang.org/t/subtyping-of-tuples-with-abstract-types-and-type-variables/32596 "2019-12-23T00:59:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bug-brain](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bug-brain](https://discourse.julialang.org/u/bug-brain)
#### Post date: [December 23, 2019, 12:59am UTC](https://discourse.julialang.org/t/subtyping-of-tuples-with-abstract-types-and-type-variables/32596/1 "2019-12-23T00:59:38Z")

</div>

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
julia> Tuple{Real, Real} <: Tuple{R,R} where R
false
julia> Tuple{Int, UInt} <: Tuple{R, R} where R
false

```

---

<div class="post-metadata">

### Author: ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)
#### Post date: [December 23, 2019, 4:30am UTC](https://discourse.julialang.org/t/subtyping-of-tuples-with-abstract-types-and-type-variables/32596/2 "2019-12-23T04:30:05Z")

</div>

`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:

```julia
Tuple{Int, UInt} <: Tuple{R, S} where {R, S}

```

---

<div class="post-metadata">

### Author: ![bug-brain](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bug-brain](https://discourse.julialang.org/u/bug-brain)
#### Post date: [December 23, 2019, 10:45am UTC](https://discourse.julialang.org/t/subtyping-of-tuples-with-abstract-types-and-type-variables/32596/3 "2019-12-23T10:45:42Z")

</div>

I found a section in the manual about [diagonal types](https://docs.julialang.org/en/v1/devdocs/types/#Diagonal-types-1) that describes these rules that exist because tuples are used in dispatch. I solved my original problem by introducing the type variable somewhere else.
