E4013#
此函数的类型需要的参数数量与提供的参数数量不同。
错误示例:#
fn f() -> (() -> Int) {
fn (x: Int) { x }
}
上面的示例声明了一个函数 f,该函数返回一个不带参数的函数,但实际返回的却是一个带一个参数的函数。这将导致第 2 行出现以下错误:
This function has type () -> Int, which expects 0 argument(s), but is given 1 argument(s).
建议#
Adjust the code so that the number of arguments in the function type matches the number of arguments in the function definition:
fn f() -> ((Int) -> Int) {
fn (x: Int) { x }
}
或:
fn f(x: Int) -> (() -> Int) {
fn() { x }
}