Lyricdev
GitHub

LYR-RES0004

an imported name the module does not declare

error ยท spec 04-modules

A selective import import m { x }; asks for a name the module m neither declares nor passes on with pub import.

Explanation

A selective import binds names the target module has: what it declares and what it passes on with pub import.

Correct the name, import it from the module that declares it, or declare it there.

Wrong

//- src/main.lyr
import app.geometry { volume };

fn main(): void {
    assert(volume(2) == 8);
}
//- src/geometry.lyr
pub fn area(side: int): int {
    return side * side;
}
//- src/main.lyr
import app.geometry { area };

fn main(): void {
    assert(area(2) == 4);
}
//- src/geometry.lyr
pub fn area(side: int): int {
    return side * side;
}