E3018
E3018 — An array literal whose elements are not scalars, or which is empty. An array literal lowers totensor.from_elements, whose element type must be a scalar, so[a, b]for tensors — placed or not — has nothing to lower to, and an empty literal has no element type to give it. Both used to be accepted by the checker (the element type silently stayed at itsf32default) and then crash codegen with an internal error rather than a diagnostic. See Vx#354.
What the compiler reports
E3018
no element 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
// An empty array literal has no element type to report. The checker used to
// hand back the historical `f32` default and codegen panicked with "Empty
// arrays not supported yet" -- an internal error where a diagnostic belongs
// (Vx#354).
fn main() -> i32 {
let arr = [];
return 0;
}
From tests/middle_end/fail/array_literal_empty.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.
E3017Closure argument count or type mismatch
E3019A
match arm whose integer literal cannot be represented in the scrutinee's type. The arm can never be selected, so the program does not mean what it says. Codegen used to parse the literal with a zero fallback, which turned an unrepresentable arm into a comparison against 0 — so the arm fired for scrutinee 0, the most common value there is, with no diagnostic.