#E0042: 需要类型标注
编译器无法从代码中推断出类型:空的字面量、没有任何约束的闭包参数,或者没有任何东西确定类型实参的泛型调用。写出类型:let v: List<i32> = [];、|x: i32| .. 或 f::<i32>(..)。
nabi
let xs = [];
error[E0042]: type annotations needed: cannot infer the type of `xs` (`List<_>`) from its initializer or later uses - add an annotation naming its arguments (`let xs: List<..> = ..`) --> main.nabi:1:1 | 1 | let xs = []; | ^^^
写出类型:
nabi
let xs: List<i32> = [];
println(f"{xs.len()}");
0
相关错误码:E0040 类型不匹配,E0055 字面量适合多种类型
发现错误? 在 GitHub 上编辑此页 最后更新: