Multimodule project: Error when calling function from imported module in Julia

dmgcodevil
Wed, 17 Apr 2024 03:17:26 +0000
New to Julia

I’m new to Julia. I want to organize my code into modules. I have three modules:

ModuleA.jl :

module ModuleA

include("ModuleB.jl")
export process
using .ModuleB
function process(foo::Foo)
end

end

ModuleB.jl :

module ModuleB
export Foo

struct Foo end

end

ModuleC.jl:

include("ModuleA.jl")
include("ModuleB.jl")

using .ModuleA
using .ModuleB

process(Foo())

When I run julia ModuleC.jl I get the following error:

ERROR: LoadError: MethodError: no method matching process(::Foo)

Closest candidates are:
  process(::Main.ModuleA.ModuleB.Foo)
   @ Main.ModuleA /julia/mutli-module/ModuleA.jl:6

What I’m doing wrong?

2 posts - 2 participants