Change in behavior when loading a module twice

To elaborate:

julia> include("Mod1.jl")
Main.Mod1

julia> using .Mod1

julia> userfun()
1-element Vector{Any}:
 Main.Mod1.Mod2.MyStruct

julia> using .Mod1

julia> userfun()
1-element Vector{Any}:
 Main.Mod1.Mod2.MyStruct

as you can see, just doing using .Mod1 twice has no effect. When you include the file the second time you missed a warning:

julia> include("Mod1.jl")
WARNING: replacing module Mod1.
Main.Mod1

julia> userfun()
Any[]

My guess is that Main.userfun is the old Mod1.userfun, which doesn’t see the old Mod1 anymore as it has been overwritten, but you should be able to call Mod1.userfun and in fact

julia> Mod1.userfun()
1-element Vector{Any}:
 Main.Mod1.Mod2.MyStruct

julia> userfun === Mod1.userfun
false

The summary is don’t include files twice, actually read the warnings, and only reload modules.

If you’re doing all of this in the REPL for quick development, you may want to look at Revise.jl instead.