E1014

E1014 — Macro expansion went too far: macro calls nest more than 128 deep, each in the code that the call before it wrote, or the macro calls of one file write more than 1,000,000 tokens. A macro that calls itself with no end is the usual cause.

What the compiler reports

Error[E1014] in a_macro_that_calls_itself_in_an_expression.vx: a call of macro `loops` is inside 128 other macro calls, and 128 is the limit.

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
//
//
// Each call of `loops` writes one more call of `loops`, so the calls never end. The
// compiler stops with an error when the calls nest 128 deep. It must not run out of stack.
//

macro_rules loops {
  ($v : expr) => { loops!($v) };
}

fn main() -> i32 {
  let x = loops!(1);
  return x;
}

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

Related