#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 上編輯此頁 最後更新: