redefinition of typealias raises error

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> 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

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.

2 Likes

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.

There are nightlies available to download from 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 :wink:

1 Like

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

thanks anyway, I’ll stay with my safe 0.6 :sunny: