Lyricdev
GitHub

LYR-SEM0045

a lambda parameter whose type nothing gives

error · spec 03-types

A lambda parameter has no written type and the lambda stands where no function type is expected, or a trailing lambda's implicit it stands where the expected function does not take exactly one parameter.

Explanation

A lambda's parameter types come from the position it stands in — a parameter or binding of a function type — or are written. A lambda bound with a bare let has no such position.

Write the parameter's type ((x: int) => x + 1), or declare the binding's function type.

Wrong

fn main(): void {
    let f = x => x + 1;
    let _ = f(1);
}
fn main(): void {
    let f = (x: int) => x + 1;
    let _ = f(1);
}