E4117

E4117#

Function with labelled arguments can only be applied directly.

This means you cannot pass a function with labelled arguments as an argument to another function.

错误示例#

///|
pub fn accumulate(acc~ : Int, value : Int) -> Int {
  acc + value
}

///|
test {
  let xs = [1, 2, 3, 4, 5]
  let sum = xs.fold(init=0, accumulate)
  //                       ^~~~~~~~~~~~
  // Error: Function with labelled arguments can only be applied directly.
}

Use Partial Applications to create non-labelled-arguments-function.

建议#

test {
  let xs = [1, 2, 3, 4, 5]
  let sum = xs.fold(init=0, accumulate(acc=_,_))
}