E3034
E3034 — A comptime block inside another one. The outer block already runs at compile time, so the inner one asks for nothing extra, and nesting them is what made a block's value depend on evaluating a closure defined inside another block.
What the compiler reports
Error[E3034]{{.*}}inside another one
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` block inside another one is refused.
//
// The outer block already runs while compiling, so the inner one asks for nothing extra.
// Allowing it is what put a closure's body out of reach: a block declared inside another
// block had a value that needed calling a closure declared alongside it.
//
fn main() -> i32 {
let n = comptime {
let inner = comptime {
3
};
inner + 1
};
return 0;
}
From tests/frontend/fail/comptime_block_nested.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.
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.
E3035A method name that more than one impl block defines for the same type. The impls are kept in a hash map, so which body a call reached used to change from one run of the compiler to the next; refusing the call is the only answer that is the same twice.