E8017

E8017 — A comptime block, or an assert that the compiler runs while compiling, that makes more than 200,000 calls in all, on every path that it tries. A function that calls itself two or more times at each level is the usual cause.

What the compiler reports

Error[E8017] at {{.*}}an_assert_that_makes_too_many_calls_while_compiling.vx:[[@LINE+1]]:3: compile-time evaluation made more than 200000 calls here, so the compiler stopped it.

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
//
//
// The compiler runs each assert while compiling, to find one that is always false. `f(60)`
// makes about 3 to the power 60 calls. The compiler stops the assert with an error after
// 200,000 calls.

fn f(n : i32) -> i32 {
  if n == 0 {
    return 1;
  }
  return f(n - 1) + f(n - 1) - f(n - 1);
}

fn main() -> i32 {
  assert(f(60) == 1, "f gives 1");
  return 0;
}

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

Related