LYR-SEM0183
an inline function used as a value
An inline fn is named anywhere other than as the callee of a call: bound to a variable, passed as an argument, returned.
Explanation
An inline fn has no address: it is set in place where it is called, and nothing is there to point at.
Call it, or wrap the call in a lambda, (x: int) => inc(x), where a function value is needed.
Wrong
inline fn inc(x: int): int {
return x + 1;
}
fn main(): void {
let h = inc;
assert(h(1) == 2);
}
Right
inline fn inc(x: int): int {
return x + 1;
}
fn main(): void {
let h = (x: int) => inc(x);
assert(h(1) == 2);
}