# Error with same type called from different modules

**URL:** <https://discourse.julialang.org/t/error-with-same-type-called-from-different-modules/22609>\
**Category:** New to Julia\
**Tags:** type\
**Created:** [April 1, 2019, 6:08pm UTC](https://discourse.julialang.org/t/error-with-same-type-called-from-different-modules/22609 "2019-04-01T18:08:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yosinlpet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yosinlpet/32/46964_2.png) [@yosinlpet](https://discourse.julialang.org/u/yosinlpet)\
**Post date:** [April 1, 2019, 6:08pm UTC](https://discourse.julialang.org/t/error-with-same-type-called-from-different-modules/22609/1 "2019-04-01T18:08:22Z")

</div>

How could I avoid the following error ?

> ERROR: LoadError: MethodError: no method matching getlinearspeedcoeffs(::Main.MultiPro.ProfileMod.VortexElement.LinearPanel, ::Main.MultiPro.ProfileMod.VortexElement.LinearPanel, ::Bool)  
> Closest candidates are:  
> getlinearspeedcoeffs(!Matched::Main.MultiPro.VortexElement.LinearPanel, !Matched::Main.MultiPro.VortexElement.LinearPanel, ::Any)

Both modules ‘ProfileMod’ and ‘MultiPro’ use the ‘VortexElement’ module but there seems to be a mismatch since ‘MultiPro’ also uses ‘ProfileMod’.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [April 2, 2019, 12:01pm UTC](https://discourse.julialang.org/t/error-with-same-type-called-from-different-modules/22609/2 "2019-04-02T12:01:10Z")

</div>

It looks like you’re probably calling `include()` on the same file multiple times, which is resulting in multiple different copies of the `VortexElement` module. You essentially never want to include the same file more than once in Julia. Fortunately, this is generally very easy to solve, although I can’t make a precise suggestion without some idea of what your code looks like. For more discussion, see [I'm confused with types names](https://discourse.julialang.org/t/im-confused-with-types-names/21795)

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 2, 2019, 12:35pm UTC](https://discourse.julialang.org/t/error-with-same-type-called-from-different-modules/22609/3 "2019-04-02T12:35:41Z")

</div>

> [@rdeits](#):
>
> this is generally very easy to solve, although I can’t make a precise suggestion without some idea of what your code looks like

Loading the module with `using` from a package could work in most cases.

---

<div class="post-metadata">

**Author:** ![PeterNorlindh](https://avatars.discourse-cdn.com/v4/letter/p/bc8723/32.png) [@PeterNorlindh](https://discourse.julialang.org/u/PeterNorlindh)\
**Post date:** [January 18, 2020, 4:38pm UTC](https://discourse.julialang.org/t/error-with-same-type-called-from-different-modules/22609/4 "2020-01-18T16:38:09Z")

</div>

I’ve struggled with this exact problem. The solution for me was trivial, but difficult to find online. I discovered it through persistent experimentation. It seems that I’ve stumbled upon a sound approach, but I’m not qualified so say for sure.

Here’s how I deal with the issue. I include each file (containing modules and structs) of interest only once, in say module “MyStartModule”. This brings their content into Main.MyStartModule, as far as I gather. And that’s where I retrieve their modules and structs from when using in other files. This seems to solve the problem and bring consistency to my types.

That call looks something like this “using .Main.MyStartModule.SomeModuleThatWasIncludedByMyStartModule”.

Peter
