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 {{.*}}const_overflow_unused.vx:[[@LINE+1]]:1: const 'A' has a value that does not fit its declared type
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 computed const whose value does not fit its type is reported even when unused.
//
const A : i32 = 2147483647 + 1;
fn main() -> i32 {
return 0;
}
From tests/frontend/fail/const_overflow_unused.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.
E3045An integer literal that does not fit its type, such as 300 for a u8. A usize holds 0 up to the largest i64.