I want to have type definitions in one module module1 and then write functions that operate on my type in another module module2 and use these functions and the type in my main script / REPL. But in my current setup I then get MethodError: no method matching f(::mytype) Closest candidates are: f(!Matched::Main.module2.module1.mytype)
Here is the full MWE:
mutable struct mytype
end # module
and finally the test script:
a = mytype(5)
and if I then run julia testscript.jl I get the error message
which sounds an awful lot like julia thinks, that mytype in the MAIN scope and in the module2 scope are different types. How do I have to setup the includes / using to make it clear, that both are the same thing?
It is similar, but the accepted answer there has one problem: The accepted solution in that thread is to remove include("./module1") \n using .module1 in the main script and write f(a) = ... instead of f(a::mytype) = ... because there is no mytype inside the scope of module2 now.
But what do I do if I want to explcitely specify the argument type of f to be mytype? It seems, that in that case I definitely have to include module1 somehow in module2.