LYR-SEM0089
a shared function name used as a value without a type to choose by
The bare name of several functions stands where a value is wanted, and no expected function type picks exactly one of them.
Explanation
A call chooses among functions of one name by its arguments; a function value has none, so the type it is wanted as has to choose. Without one, or when none or several of the functions fit it, the name stays ambiguous.
Give the binding or parameter a function type (let g: fn(int) -> int = step;), or wrap the call in a lambda.
Wrong
fn step(n: int): int { return n; }
fn step(a: int, b: int): int { return a + b; }
fn main(): void {
let g = step;
let _ = g(1);
}
Right
fn step(n: int): int { return n; }
fn step(a: int, b: int): int { return a + b; }
fn main(): void {
let g: fn(int) -> int = step;
let _ = g(1);
}