Lyricdev
GitHub

LYR-SEM0190

a macro site names no macro

error · spec 11-metaprogramming

A site name!(…) names nothing in scope, or names something that is not a macro (a function, a type).

Explanation

name! expands a macro, which a module imports as it imports a function. The name must be in scope and be a macro.

Import the macro (import app.macros { echo };), or call a function without the !.

Wrong

fn main(): void {
    assert(echo!(3) == 3);
}
//- src/main.lyr
import app.macros { echo };

fn main(): void {
    assert(echo!(3) == 3);
}
//- src/macros.lyr
import std.syntax { Expr };

pub macro echo(e: Expr): Expr {
    return e;
}