# Problem with replacing module and ambiguous methods

**URL:** <https://discourse.julialang.org/t/problem-with-replacing-module-and-ambiguous-methods/34712>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 16, 2020, 8:30am UTC](https://discourse.julialang.org/t/problem-with-replacing-module-and-ambiguous-methods/34712 "2020-02-16T08:30:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![EvgeniyMist](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evgeniymist/32/12875_2.png) [@EvgeniyMist](https://discourse.julialang.org/u/EvgeniyMist)\
**Post date:** [February 16, 2020, 8:30am UTC](https://discourse.julialang.org/t/problem-with-replacing-module-and-ambiguous-methods/34712/1 "2020-02-16T08:30:12Z")

</div>

Initially, I wanted to create a structure similar to a linked list, but more complex, namely:

```julia
mutable struct Move
    data::Int64
    next_moves::Union{Array{Move, 1}, Nothing}
    Move(data) = new(data, nothing)
end

```

Next I faced this problem: “ERROR: LoadError: invalid redefinition of constant Move”. And with the help of the Julia community I found a solution - to create a module. I think, this is in some sense useless, because, in my opinion, module is needed only to create another namespace and to structure the code.

Finally, I added simple function, so final code:

```julia
module move

export Move

mutable struct Move
    data::Int64
    next_moves::Union{Array{Move, 1}, Nothing}
    Move(data) = new(data, nothing)
end

end

function my_func(x::Union{Nothing, move.Move})
    println("Hello world")
end

my_func(nothing)

```

There isn’t any problem with the first code run, but with the second…

WARNING: replacing module move.  
ERROR: LoadError: MethodError: my\_func(::Nothing) is ambiguous. Candidates:  
my\_func(x::Union{Nothing, Main.move.Move}) in Main at Path:14  
my\_func(x::Union{Nothing, Main.move.Move}) in Main at Path:14  
Possible fix, define  
my\_func(::Nothing)

And I absolutely don’t understand, what is happening

P.S. Julia v.1.2.0, Atom v.1.39.0

---

<div class="post-metadata">

**Author:** ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)\
**Post date:** [February 16, 2020, 8:52am UTC](https://discourse.julialang.org/t/problem-with-replacing-module-and-ambiguous-methods/34712/2 "2020-02-16T08:52:12Z")

</div>

maybe you should restart with a fresh shell. I can’t reproduce your problem.

---

<div class="post-metadata">

**Author:** ![EvgeniyMist](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evgeniymist/32/12875_2.png) [@EvgeniyMist](https://discourse.julialang.org/u/EvgeniyMist)\
**Post date:** [February 16, 2020, 9:11am UTC](https://discourse.julialang.org/t/problem-with-replacing-module-and-ambiguous-methods/34712/3 "2020-02-16T09:11:19Z")

</div>

Yes, restart solves the problem. But I don’t want to restart after each code fix

---

<div class="post-metadata">

**Author:** ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)\
**Post date:** [February 16, 2020, 10:02am UTC](https://discourse.julialang.org/t/problem-with-replacing-module-and-ambiguous-methods/34712/4 "2020-02-16T10:02:12Z")

</div>

do you know/use [Revise](https://github.com/timholy/Revise.jl)?
