E4119#
Compiler diagnostic name: unknown_func_labelled_arg.
This function is not a toplevel function, so it cannot have labelled arguments.
Only toplevel functions can declare or receive labelled arguments. Local
functions are inferred as ordinary function values, so a call such as g(x~)
is rejected when g is a local function parameter.
Erroneous example#
fn init {
let x = 42
fn f(g) {
g(x~)
//^
// Error: This function is not a toplevel function, so it cannot have labelled arguments.
}
f(h)
}
fn h(x : Int) -> Unit {
ignore(x)
}
Suggestion#
Pass the value positionally when calling a local function value, or move the function to the toplevel if you need labelled arguments.
fn init {
let x = 42
fn f(g) {
g(x)
}
f(h)
}
fn h(x : Int) -> Unit {
ignore(x)
}