# Invalid redefinition error for const X = Vector{\<:A}

**URL:** <https://discourse.julialang.org/t/invalid-redefinition-error-for-const-x-vector-a/82316>\
**Category:** Internals & Design\
**Created:** [June 6, 2022, 2:48pm UTC](https://discourse.julialang.org/t/invalid-redefinition-error-for-const-x-vector-a/82316 "2022-06-06T14:48:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skraemer](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@skraemer](https://discourse.julialang.org/u/skraemer)\
**Post date:** [June 6, 2022, 2:48pm UTC](https://discourse.julialang.org/t/invalid-redefinition-error-for-const-x-vector-a/82316/1 "2022-06-06T14:48:13Z")

</div>

When the following lines are run twice, the error `invalid redefinition of constant X` is thrown. The code is rather random, but it is the most minimal example I could come up with without removing the problem. In particular, `foo` does neither use `A` nor `X` but is essential.

```julia
abstract type A end
struct B <: A
    r
end
const X = Vector{<:A}
function foo(b::B)
    r = b.r
    i = 1
    for j in 1:length(r)
        while r[j] > 0 && i<10
             i+=1
        end
    end
end

```

Using the line `X = Vector{T} where {T<:A}` works fine instead, even though `Vector{<:A} == Vector{T} where {T<:A}` returns `true`.

Does anyone know what might be going on? This initially caused me to use `@isdefined` each time, but this seems unintended.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 6, 2022, 3:12pm UTC](https://discourse.julialang.org/t/invalid-redefinition-error-for-const-x-vector-a/82316/2 "2022-06-06T15:12:50Z")

</div>

I can reproduce on 1.7 but not 1.8 — this very well may have been a bug.

---

<div class="post-metadata">

**Author:** ![skraemer](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@skraemer](https://discourse.julialang.org/u/skraemer)\
**Post date:** [June 6, 2022, 3:16pm UTC](https://discourse.julialang.org/t/invalid-redefinition-error-for-const-x-vector-a/82316/3 "2022-06-06T15:16:35Z")

</div>

Sounds good. Thank you for quickly testing it.
