Lyricdev
GitHub

LYR-SEM0184

a function that cannot be inline

error · spec 03-types

inline is written on a function whose body cannot be set in place: an interface member, a function without a body (extern), a mut fn, a function with a place parameter, or a body that yields.

Explanation

An inline function's body is copied to each call. That needs a body, a call that is resolved statically (not through a conformer's table), no receiver or parameter that is the caller's place, and a body that runs where it is called — a coroutine's runs where it is pulled.

Remove inline from the function.

Wrong

inline fn add(&x: int): void {
    x += 1;
}

fn main(): void {
    var n = 1;
    add(&n);
    assert(n == 2);
}
fn add(&x: int): void {
    x += 1;
}

fn main(): void {
    var n = 1;
    add(&n);
    assert(n == 2);
}