Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E1200: Comptime evaluation failed

CodeCategoryStability
E1200ComptimePermanent

Explanation

Compile-time evaluation could not produce a value for a position that requires one. The reason names the specific failure: an operation whose result is not compile-time known, an arithmetic fact that would trap at runtime, and -- the two recursion cases -- a specialization that ran past the maximum nesting depth, or a comptime call whose reduction requires that same call. The two recursion cases are distinct. A depth overrun means each round produced a new specialization and the chain never reached a base case, so a smaller argument or a reachable base case fixes it. Self-dependence means the call needs its own result with the same compile-time arguments, which no depth budget would satisfy.

Likely cause

A comptime-recursive function is missing a compile-time-known base case, a generic function reinstantiates itself with a new type every round, or a comptime call is written so that reducing it demands its own result. Give the recursion a base case the compiler can see, or break the self-dependence.

Examples

Recurse with no compile-time-known base case

fn runaway(comptime n: i32) -> i32 {
    runaway(n + 1)
}
fn main() -> i32 { runaway(0) }

Require a comptime call's own result

fn Bad() -> type { Bad() }
fn main() -> i32 {
    Bad();
    0
}

References