E8005

E8005 — Compile-time evaluation ran more loop iterations than the budget allows. A loop whose end condition is never reached is the usual cause; without this it hung the compiler.

What the compiler reports

Error[E8005]{{.*}}loop iterations and was stopped

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 `comptime` loop that never reaches its end is stopped and reported.
//
// Nothing in this `loop` sets up a `break`, so running it to completion is running it
// forever. Without the budget the compiler hung here: no file, no line, no message, just
// a build that never finished. E8005 says what happened and names the usual cause.
//
// The budget is counted across a whole evaluation rather than per loop, so this file also
// stands in for the shape where each of many loops is short and the total is not.
//

fn main() -> i32 {
  comptime {
    let mut spun = 0;
    loop {
      spun = spun + 1;
    }
  }
  return 0;
}

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

Related