E4114

E4114#

只有顶层函数可以有带标签的参数。

This error occurs when trying to use labelled arguments in a local function or anonymous function.

错误示例#

pub fn f() -> Unit {
  fn h(x~: Int) -> Unit {
//     ^^ Error: Only toplevel functions can have labelled arguments.
    println(x)
  }
  h(x=42)
}

建议#

To fix this error, you can either:

  • Move the function to the top level of the module

fn h(x~: Int) -> Unit {
  println(x)
}

pub fn f() -> Unit {
  h(x=42)
}
  • Remove the labelled arguments

pub fn f() -> Unit {
  fn h(x: Int) -> Unit {
    println(x)
  }
  h(42)
}