Function whose parameter type is defined in another module

zapiano
Wed, 10 May 2023 09:01:03 +0000
General Usage

I have a custom module called Utilities, where I define the struct Utility

# utilities.jl
module Utilities

export Utility

mutable struct Utility
 # etc...
end

# ..etc

end

and another module called SimplexTools where I am trying to import the module Utilities and declare a function whose arguments are of type Utility:

# simplexTools.jl
module SimplexTools

include("./utilities.jl")
using .Utilities

function buildSimplex(utilityA::Utility, utilityB::Utility)
# etc...
end

end

And, finally, I have a third module called EnvyFree that creates two instances of these Utility structs and calls the SimplexTools function buildSimplex, but when I run my code, I get the following error (I have simplified the folder structure a little bit for clarity):

ERROR: LoadError: MethodError: no method matching buildSimplex(::Main.Model.EnvyFree.Utilities.Utility, ::Main.Model.EnvyFree.Utilities.Utility)
Closest candidates are:
  buildSimplex(::Main.Model.EnvyFree.SimplexTools.Utilities.Utility, ::Main.Model.EnvyFree.SimplexTools.Utilities.Utility)

I have tried importing with import .Utilities: Utility, integrateUtility but it didn’t work. I don’t understand what’s happening here…

4 posts - 3 participants