E3044

E3044 — A top-level const whose value is not known while compiling, or does not fit its declared type. A const holds a number or a bool: a literal, or arithmetic on literals and other consts. A const table holds a list of number literals, and is read one number at a time, as TABLE[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