E3018

E3018 — An array literal whose elements are not scalars, or which is empty. An array literal lowers to tensor.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 its f32 default) 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