E4037#
Cannot perform action: package is not imported.
Erroneous Example#
In main/main.mbt
, we try to call a function from @middle
:
fn main {
let a = @middle.return_Obj().m()
}
In middle/middle.mbt
, we define a function that returns an
object of a trait Obj
defined in @ty
:
pub fn return_Obj() -> &@ty.Obj {
@ty.T(42)
}
In ty/ty.mbt
, we define a trait Obj
and a type T
that
implements it:
pub(all) type T Int
pub fn f(self: T) -> Unit {
println(self._)
}
pub(open) trait Obj {
f(Self) -> Unit
}
... but in main/moon.pkg.json
there is no mention of @ty
:
{
"import": ["<PACKAGE>/middle"]
}
This gives the following error on line 2 of main/main.mbt
:
Cannot call method of type &@<PACKAGE>/ty.Obj: package @<PACKAGE>/ty is not imported.
Suggestion#
Make sure that all relevant packages are imported.
In the above example, this means importing both @middle
and @ty
in main/moon.pkg.json
:
{
"import": ["<PACKAGE>/middle", "<PACKAGE>/ty"]
}