Lyricdev
GitHub

LYR-PAR0015

a function type without '->'

error · spec 03-types

A function type fn(…) is not followed by -> and its return type.

Explanation

A function type always names what the function returns: fn(int) -> int, fn() -> void. The arrow separates the parameter types from it.

Write -> and the return type after the parameter types.

Wrong

fn apply(f: fn(int) int, v: int): int {
    return f(v);
}

fn main(): void {
}
fn apply(f: fn(int) -> int, v: int): int {
    return f(v);
}

fn main(): void {
    let _ = apply((n: int) => n, 1);
}