# Type promotion clarification

**URL:** <https://discourse.julialang.org/t/type-promotion-clarification/49148>\
**Category:** New to Julia\
**Created:** [October 27, 2020, 9:04pm UTC](https://discourse.julialang.org/t/type-promotion-clarification/49148 "2020-10-27T21:04:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djbarker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djbarker/32/19000_2.png) [@djbarker](https://discourse.julialang.org/u/djbarker)\
**Post date:** [October 27, 2020, 9:04pm UTC](https://discourse.julialang.org/t/type-promotion-clarification/49148/1 "2020-10-27T21:04:00Z")

</div>

Hi All,

Complete Julia newbie here. I thought I roughly understood the idea behind the `promote_rule` and `convert` stuff (after looking at the docs and a few articles) but I don’t understand the following

```julia
abstract type A end
struct A1 <: A val1::Float64 end
struct A2 <: A val2::Float64 end
promote_rule(::Type{A2}, ::Type{A1}) = A1
promote_rule(::Type{A1}, ::Type{A2}) = A1 # AFAIU this should not actually be needed
promote_type(A1, A2) # I expect this to return A1 but it returns A

```

Can anyone explain why the call to `promote_type` returns `A` not `A1`? (I’m using 1.5.2 if it matters)

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)\
**Post date:** [October 27, 2020, 9:17pm UTC](https://discourse.julialang.org/t/type-promotion-clarification/49148/2 "2020-10-27T21:17:38Z")

</div>

> [@djbarker](#):
>
> `promote_rule(::Type{A1}, ::Type{A2}) = A1`

do: `Base.promote_rule(::Type{A1}, ::Type{A2}) = A1`

Then

```julia
julia> promote_type(A1, A2)
A1

```

---

<div class="post-metadata">

**Author:** ![djbarker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djbarker/32/19000_2.png) [@djbarker](https://discourse.julialang.org/u/djbarker)\
**Post date:** [October 27, 2020, 9:22pm UTC](https://discourse.julialang.org/t/type-promotion-clarification/49148/3 "2020-10-27T21:22:25Z")

</div>

Ah! Yes that works, thanks.
