E3044
E3044 — A top-levelconstwhose value is not known while compiling, or does not fit its declared type. Aconstholds a number or abool: a literal, or arithmetic on literals and otherconsts. Aconsttable holds a list of number literals, and is read one number at a time, asTABLE[i].
What the compiler reports
Error[E3044] at [[@LINE+1]]:1: const 'CALLED' has no value known while compiling
Error[E3044] at [[@LINE+1]]:1: const 'ITSELF' has no value known while compiling
Error[E3044] at [[@LINE+1]]:1: const 'HALF' has a value whose type differs from the declared 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
//
fn two() -> i32 {
return 2;
}
// A function call has no value while compiling.
const CALLED : i32 = two();
// Defined through itself.
const ITSELF : i32 = ITSELF + 1;
// A float for an integer type.
const HALF : i32 = 1.5;
fn main() -> i32 {
return CALLED + ITSELF + HALF;
}
From tests/frontend/fail/const_items_without_a_value.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.
E3043A
for loop over a reference to a type with no method to iterate it by. The loop calls iter() for for x in &c and iter_mut() for for x in &mut c, as Rust's collections do, so the type needs the one the loop asks for.