# No signature match between same type across different modules

**URL:** <https://discourse.julialang.org/t/no-signature-match-between-same-type-across-different-modules/55014>\
**Category:** New to Julia\
**Tags:** question, repl\
**Created:** [February 10, 2021, 6:08pm UTC](https://discourse.julialang.org/t/no-signature-match-between-same-type-across-different-modules/55014 "2021-02-10T18:08:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pp492](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@pp492](https://discourse.julialang.org/u/pp492)\
**Post date:** [February 10, 2021, 6:08pm UTC](https://discourse.julialang.org/t/no-signature-match-between-same-type-across-different-modules/55014/1 "2021-02-10T18:08:38Z")

</div>

I have the following (simplified) module structure in my program.

![modules-2](https://global.discourse-cdn.com/julialang/original/3X/8/1/81b0d793cc19c2798396f2b517471c92ec5a1713.png)

I have also detailed the simplified structure of each module.

```julia
module Entities
    export Agent, Space
    struct Agent
        .
    end
    struct Space
        .
    end
end

```

```julia
module Loader
    export load_data, read_config
    include("./entities.jl")
    using .Entities: Agent, Space

    function read_config(...)
        .
    end
    function load_data(...)::Tuple{Vector{Space}, Vector{Agent}}
        .
    end
end

```

```julia
module Scheduler
    include("./loader.jl")
    include("./entities.jl")
    using .Loader: load_data, read_config
    using .Entities: Agent, Space

    function main()
        spaces, agents = load_data(read_config("scenarios/eq_2.json"))
        synthetise_schedule(agents, spaces, order)
        # println(typeof(spaces), "\t", typeof(agents), "\t", typeof(locations), "\t", typeof(order))
    end
    function synthetise_schedule(agents::Vector{Agent}, spaces::Vector{Space})
        .
    end
    main()
end

```

Now, when I run the `scheduler.jl` file, I get the following error

```julia
LoadError: MethodError: no method matching synthetise_schedule(::Array{Main.Scheduler.Loader.Entities.Agent,1}, ::Array{Main.Scheduler.Loader.Entities.Space,1})

```

It looks like the REPL treat `Main.Scheduler.Loader.Entities.*` and `Main.Scheduler.Entities.*` as different types, although they eventually all refer to the same original types `Entities.*`.

**Now, I am not sure if this behavior comes from the fact that I am missing a set of instructions within each module or if it is the expected behavior in Julia.**

In any case, how can I make sure that my `synthetise_schedule` function accepts `Main.Scheduler.Loader.Entities.*` types as input?

---

<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:** [February 10, 2021, 6:22pm UTC](https://discourse.julialang.org/t/no-signature-match-between-same-type-across-different-modules/55014/2 "2021-02-10T18:22:09Z")

</div>

> [@pp492](#):
>
> Now, I am not sure if this behavior comes from the fact that I am missing a set of instructions within each module or if it is the expected behavior in Julia.

This is expected, and it’s why you should ensure that each file is `include()`ed _exactly once_. In your case, it should be sufficient to do:

```julia
module Scheduler

include("loader.jl") # Note: `./` is implied
using .Loader: load_data, read_config
using .Loader.Entities: Agent, Space

```

---

<div class="post-metadata">

**Author:** ![pp492](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@pp492](https://discourse.julialang.org/u/pp492)\
**Post date:** [February 10, 2021, 7:08pm UTC](https://discourse.julialang.org/t/no-signature-match-between-same-type-across-different-modules/55014/3 "2021-02-10T19:08:32Z")

</div>

It makes sense. But know, the final common types is `Main.Scheduler.Loader.Entities.*`, which works but is kind of misleading from a conceptual point of view since `Main.Scheduler.Entities.*` types also exist on their own.

The bottomline is that I always have to use the “longest” include as my final types (if that makes sense), which is not ideal.

---

<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:** [February 10, 2021, 8:51pm UTC](https://discourse.julialang.org/t/no-signature-match-between-same-type-across-different-modules/55014/4 "2021-02-10T20:51:00Z")

</div>

Oh, sure–in that case you can do:

```julia
module Scheduler

include("entities.jl")
include("loader.jl")

```

as long as you _also_ change `loader.jl` to look like:

```julia
module Loader

using ..Entities: Agent

```

That should allow you to have your `Main.Scheduler.Entities` types as desired.
