docs

#E0079: 無法在編譯時期求值

常數、陣列長度、常數泛型引數或 const fn 主體使用了在編譯時期沒有值的東西:呼叫一般的 fn、堆積配置,或執行時的值。請使用字面值、其他常數和 const fn 呼叫。

nabi
fn three() -> i32 { 3 }
const N: i32 = three();
error[E0079]: const `N` cannot be evaluated at compile time: calls `three`, which is not a `const fn`
  --> main.nabi:2:16
   |
 2 | const N: i32 = three();
   |                ^^^^^^^

把函式改成 const fn:

nabi
const fn three() -> i32 { 3 }
const N: i32 = three();
println(f"{N}");
3

相關錯誤碼:E0080 相依於自身的定義、E0081 無效的常數泛型引數

發現錯誤? 在 GitHub 上編輯此頁 最後更新: