E4115

E4115#

不能自动填充此类型的参数。

MoonBit 支持自动填充 SourceLocArgsLoc 参数的函数。将其他类型参数的默认值留空将导致出现此错误。

错误示例#

///|
#callsite(autofill(parameter))
fn f(parameter~ : Int) -> Unit {
  // ^~~~~~~~~ Error: Cannot auto-fill parameter of type Int
}

建议#

为参数使用默认值:

///|
pub fn f(parameter? : Int = 0) -> Int {
  parameter
}

///|
test {
  inspect(f(), content="0")
  inspect(f(parameter=1), content="1")
}