# redefinition of typealias raises error

**URL:** <https://discourse.julialang.org/t/redefinition-of-typealias-raises-error/10776>\
**Category:** General Usage\
**Created:** [May 8, 2018, 11:41am UTC](https://discourse.julialang.org/t/redefinition-of-typealias-raises-error/10776 "2018-05-08T11:41:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim/32/6848_2.png) [@tim](https://discourse.julialang.org/u/tim)\
**Post date:** [May 8, 2018, 11:41am UTC](https://discourse.julialang.org/t/redefinition-of-typealias-raises-error/10776/1 "2018-05-08T11:41:51Z")

</div>

Hi all,

I am trying to define a type alias for a parametric type. Unfortuntately, when running the same line of code again, I get an error “invalid redefinition of constant …”. While that is generally okai (it’s constant so I don’t want o change it ^^) it’s a bit annoying when rerunning a script in the same itnerpreter to avoid the startup time of Julia (roughly 30 seconds for my particular script).

Here is a minimal not working example. How can I avoid that the second line raises and error?

```julia
julia> MyUnion{A, B} = Union{A,B}
Union{A, B} where B where A

julia> MyUnion{A, B} = Union{A,B}
ERROR: invalid redefinition of constant MyUnion

```

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 8, 2018, 11:48am UTC](https://discourse.julialang.org/t/redefinition-of-typealias-raises-error/10776/2 "2018-05-08T11:48:19Z")

</div>

FWIW works on 0.7.

As a workaround, you can wrap your code in a module and then the inclusion should work fine.

When it comes to hotloading code, you definitely need to check out [https://github.com/timholy/Revise.jl](https://github.com/timholy/Revise.jl).

---

<div class="post-metadata">

**Author:** ![tim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim/32/6848_2.png) [@tim](https://discourse.julialang.org/u/tim)\
**Post date:** [May 8, 2018, 12:35pm UTC](https://discourse.julialang.org/t/redefinition-of-typealias-raises-error/10776/3 "2018-05-08T12:35:57Z")

</div>

ok, thanks. When is Julia 0.7 likely to come out? And is there a beta already for testing it? I used conda to install julia, so maybe there is a conda channel for that?

Thanks for the workaround, works like a charm. And Revise.jl looks awesome, I’ll be trying it out these days.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 8, 2018, 12:46pm UTC](https://discourse.julialang.org/t/redefinition-of-typealias-raises-error/10776/4 "2018-05-08T12:46:50Z")

</div>

> [@tim](#):
>
> And is there a beta already for testing it

There are nightlies available to download from [https://julialang.org/downloads/nightlies.html](https://julialang.org/downloads/nightlies.html) but you should know that not many packages support it and it is still changing a bit (not too big things right now though).

An alpha should be out in not too long time 😉

---

<div class="post-metadata">

**Author:** ![tim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim/32/6848_2.png) [@tim](https://discourse.julialang.org/u/tim)\
**Post date:** [May 8, 2018, 12:54pm UTC](https://discourse.julialang.org/t/redefinition-of-typealias-raises-error/10776/5 "2018-05-08T12:54:06Z")

</div>

haha, so asking for a beta was a bit too much (:

thanks anyway, I’ll stay with my safe 0.6 ☀
