Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Error with modules sharing types

$
0
0

@peterj wrote:

The following code gives me an error with Julia v1.4

# M1.jl
module M1
    export M1Type
    struct M1Type
        data::Real
    end
end

# M2.jl
module M2
    using ..M1
    export f
    function f(x::M1Type)
        
    end
end

# At the REPL (or main module)
using .M1
using .M2
f(M1Type(1))

and the error is

 MethodError: no method matching f(::M1Type) Closest candidates are: f(::Main.M1.M1Type) Stacktrace:..

Currently the workaround I use is to have the main module only have using .M1, and use Reexport.jl to reexport everything in M1 from M2, but I shouldn’t need to do that, right?

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles