Lyricdev
GitHub

LYR-RES0003

an import of a module that does not exist

error ยท spec 04-modules

An import names a module that no file provides: no src/<path>.lyr in the package, no module of a dependency or of std by that path.

Explanation

A module is a file, and its name is its path: app.geometry is src/geometry.lyr of the package app, geo.shapes is src/shapes.lyr of the dependency geo. A package's root module src/lib.lyr is imported by the package's name alone, never as <package>.lib.

Create the file, correct the path, or declare the package that holds it under [dependencies] in lyric.toml.

Wrong

import app.geometry { area };

fn main(): void {
    assert(area(2) == 4);
}
//- 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;
}