E8003

E8003 — Compile-time index out of range

What the compiler reports

E8003] at {{.*}}tensor_index_out_of_range_in_closure.vx:[[@LINE+1]]:{{.*}}index 5 is out of range

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
//
// An out-of-range index inside a closure must still report E8003. The type-based
// check returns early when capturing, so the value check must cover this case.
//
fn main() -> i32 {
  let a : Tensor<i64, [3]> = [ 3i64, 1i64, 2i64 ];
  let f = ||
  a[5];
  println!(f());
  return 0;
}

From tests/frontend/fail/tensor_index_out_of_range_in_closure.vx, which asserts this diagnostic on every commit.

Related