E3032
E3032 — A chain of generic instantiations that does not end — f<N - 1>() whose base case is never reached. Reported here rather than left to run out of stack, which gave no file, no line and no message.
What the compiler reports
Error[E3032]{{.*}}generic calls deep 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 generic recursion that never reaches its base case is reported, not crashed on.
//
// The base case returns, but the call after the `if` is checked anyway, so `N` goes
// 2, 1, 0, -1, -2 and never stops. Each round is a new instance checked inside the
// last, which used to take the compiler's stack down with no file and no message.
//
fn countdown<const N : i32>() -> i32 {
if comptime N == 0 {
return 0;
}
return countdown<N - 1>() + 1;
}
fn main() -> i32 {
return countdown<3>();
}
From tests/frontend/fail/const_generic_runaway_instantiation.vx, which asserts this diagnostic on every commit.
Related
A tour of VxThe chapter covering the rule this code enforces.
All diagnosticsEvery code the compiler can emit, grouped by stage.
E3031
impl Copy for X where one of X's fields is a type that moves. Copy promises a value survives being assigned elsewhere, and a field that does not survive it breaks that promise for the whole type — which would be a way to duplicate a tensor, or any other placed value, without saying so.
E3033A comptime block the evaluator could not finish. The block runs during compilation and leaves nothing behind, so one that cannot be run has no meaning — and used to be emitted as ordinary run-time code, which hid the fact entirely.