E4010

E4010 — A change to a variable declared without mut: assigning it, or a field or element of it, borrowing it &mut, or calling a method that takes &mut self on it. Declare it let mut x, or for a parameter mut x : T.

What the compiler reports

Error[E4010] at {{.*}}assigning_to_a_tuple_of_places.vx:18:{{.*}}`b`

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
//
//
// Assigning a tuple to a tuple of places follows the rules of each assignment: a place that
// is not `mut` cannot be assigned.
//

fn main() -> i32 {
  let mut a : i32 = 0;
  let b : i32 = 0;
  (a, b) = (1, 2);
  return a + b;
}

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

Related