# Lower bound of type has no effect?

**URL:** https://discourse.julialang.org/t/lower-bound-of-type-has-no-effect/62372
**Category:** New to Julia
**Created:** [June 4, 2021, 2:03am UTC](https://discourse.julialang.org/t/lower-bound-of-type-has-no-effect/62372 "2021-06-04T02:03:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jinml](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jinml](https://discourse.julialang.org/u/jinml)
#### Post date: [June 4, 2021, 2:03am UTC](https://discourse.julialang.org/t/lower-bound-of-type-has-no-effect/62372/1 "2021-06-04T02:03:01Z")

</div>

When playing with the various confusing type relations, I found the following impossible to understand:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/6/9610994ecad6e429592a15b9cee2230eb937d48f.png)  
There lower bound for `T` seems to have no effect? I expect to get `Union{}`, but got `Int64`. What am I missing here?

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [June 4, 2021, 2:15am UTC](https://discourse.julialang.org/t/lower-bound-of-type-has-no-effect/62372/2 "2021-06-04T02:15:12Z")

</div>

`Int`  
is the same as Int64. And the only subtype of Int64 is itself. (The \<: is inclusive)

---

<div class="post-metadata">

### Author: ![jinml](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jinml](https://discourse.julialang.org/u/jinml)
#### Post date: [June 4, 2021, 4:26am UTC](https://discourse.julialang.org/t/lower-bound-of-type-has-no-effect/62372/3 "2021-06-04T04:26:18Z")

</div>

OK, that’s fair, what about the following:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/c/4c48b9ba349198e11c7ad72cff1ddd686e7be680.png)  
The rule seems inconsistent.

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [June 4, 2021, 2:37pm UTC](https://discourse.julialang.org/t/lower-bound-of-type-has-no-effect/62372/4 "2021-06-04T14:37:47Z")

</div>

There you have reached one example of this, I think: [Vector{Int} \<: Vector{Real} is false??? · JuliaNotes.jl](https://m3g.github.io/JuliaNotes.jl/stable/typevariance/)

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [June 4, 2021, 3:05pm UTC](https://discourse.julialang.org/t/lower-bound-of-type-has-no-effect/62372/5 "2021-06-04T15:05:16Z")

</div>

`Ref{Number}` is an actual data type: you can create objects of that type that reference data of type `Number`:

```julia
julia> R = Ref{Number}
Ref{Number}

julia> typeof(R)
DataType

julia> methods(R)
# 2 methods for type constructor:
[1] Ref{T}() where T in Base at refpointer.jl:135
[2] Ref{T}(x) where T in Base at refpointer.jl:136

julia> R(1)
Base.RefValue{Number}(1)

```

The other is a weird union of data types, which cannot even be instantiated:

```julia
julia> S = Ref{T} where Real<:T<:Number
Ref{T} where Real<:T<:Number

julia> typeof(S)
UnionAll

julia> methods(S)
# 0 methods for type constructor:

```

So they cannot be equal at all.

---

<div class="post-metadata">

### Author: ![jinml](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jinml](https://discourse.julialang.org/u/jinml)
#### Post date: [June 4, 2021, 4:12pm UTC](https://discourse.julialang.org/t/lower-bound-of-type-has-no-effect/62372/6 "2021-06-04T16:12:56Z")

</div>

Thanks. I guess my confusion is that in the first case, the lower bound did not have any effect, in the second one, it did. The `T->Ref{T}` “type mapping” is “invariant” but I guess the `T->T` type mapping is “covariant” ? Maybe that’s how I should look at it?
