# Erroneous automatic promotion

**URL:** <https://discourse.julialang.org/t/erroneous-automatic-promotion/11822>\
**Category:** General Usage\
**Tags:** question, bug\
**Created:** [June 20, 2018, 1:29pm UTC](https://discourse.julialang.org/t/erroneous-automatic-promotion/11822 "2018-06-20T13:29:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FMeirinhos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fmeirinhos/32/19527_2.png) [@FMeirinhos](https://discourse.julialang.org/u/FMeirinhos)\
**Post date:** [June 20, 2018, 1:29pm UTC](https://discourse.julialang.org/t/erroneous-automatic-promotion/11822/1 "2018-06-20T13:29:35Z")

</div>

While composing a minimal working example for #11821, I came across the following:

```julia
struct foo{T} <: T where {T<:Real}
    bar::T
end

```

seems to **not** throw a `convert` MethodError for declarations such as

```julia
julia> foo(3.0 + 1im)
foo{Complex{Float64}}(3.0 + 1.0im)

```

This is naturally absent when there’s no subtyping:

```julia
struct foo{T<:Real}
    bar::T
end

```

will prompt a `convert` MethodError for `foo(3.0 + 1im)`.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [June 20, 2018, 1:41pm UTC](https://discourse.julialang.org/t/erroneous-automatic-promotion/11822/2 "2018-06-20T13:41:15Z")

</div>

The `T`s in the first example are not the same, I think your example is equivalent with

```julia
struct foo{S} <: T where {T<:Real}
    bar::S
end

```

since those `T` have different scope.
