E8007

E8007 — An access clause that does not hold: an atomic(t) whose body uses t without an atomic operation, a reads_only(t) whose body may write t, or a writes_only() whose body may write memory

What the compiler reports

Error[E8007] at {{.*}}atomic_contract_in_a_generic_function.vx:19:10: `reads_an_element` says `atomic(t)`, so it may use `t` only in an atomic operation

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 generic function with `ensures atomic(t)` reads an element of `t` without an atomic
// operation. The compiler checks the copy that the call makes, and the error names the function
// as the program wrote it.
//

fn reads_an_element<M : Memory>(t : &Tensor<i32, [?], Memory::M>, i : i32) -> i32
ensures atomic(t)
{
  return t[i];
}

fn main() -> i32 {
  let h = Tensor<i32, [2]>::fill(3);
  return reads_an_element(&h, 0);
}

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

Related