E8004

E8004 — Compile-time evaluation exceeded the call-depth limit

What the compiler reports

E8004 … compile-time evaluation went more than 256 calls deep

The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.

A program that triggers it

//
// Part of the Vx Project, under the Apache License v2.0 with LLVM Exceptions.
// See LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// A recursion that never reaches a base case is a diagnostic, not a crashed compiler.
//
// Without the limit this took the compiler's stack down: "fatal runtime error: stack
// overflow", SIGABRT, no file, no line, and nothing naming the function responsible.
//

fn spin(n : i64) -> i64 {
  return spin(n + 1);
}

fn main() -> i32 {
  comptime {
    assert(spin(0) == 1, "never terminates");
  }
  return 0;
}

From tests/frontend/fail/comptime_call_depth_limit.vx, which asserts this diagnostic on every commit.

Related