Lyricdev
GitHub

LYR-PAR0012

a lambda without '=>' before its body

error · spec 08-expressions

A lambda's parameters, or its parameters and return type, are not followed by =>; or the parameters of a trailing block { a, b => … } are not.

Explanation

A lambda is its parameters in parentheses, an optional : T with its throws, then => and the body: (x: int): int => x * 2. In a trailing block the parameters are followed by => too.

Write => between the signature and the body.

Wrong

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