error not-comptime
Выражение не вычисляется при компиляции.
What it means#
const initialisers, associated constants, array lengths and attribute arguments MUST be comptime expressions (§4.1, §4.9, §15.1): literals, other constants and calls to comptime functions. Ordinary functions, and anything with effects, cannot run at compile time.
Example#
fn compute() -> i32 => 6 * 7
const ANSWER: i32 = compute() // <- not-comptimeerror
not-comptime
How to fix#
comptime fn compute() -> i32 => 6 * 7
const ANSWER: i32 = compute()Mark the function comptime (it must then be deterministic and free of effects), or write the value directly.