Open rahxephon89 opened 4 months ago
This is V1 error:
error[E07001]: referential transparency violated
┌─ tests/move_check/typing/mutable_borrow_from_immutable.move:6:9
│
6 │ &mut (&s).v;
│ ^^^^^^^^^^^
│ │ │
│ │ Immutable because of this position
│ Invalid mutable borrow from an immutable reference
error[E07001]: referential transparency violated
┌─ tests/move_check/typing/mutable_borrow_from_immutable.move:7:9
│
7 │ &mut (&s.x).f;
│ ^^^^^^^^^^^^^
│ │ │
│ │ Immutable because of this position
│ Invalid mutable borrow from an immutable reference
error[E07001]: referential transparency violated
┌─ tests/move_check/typing/mutable_borrow_from_immutable.move:10:9
│
8 │ let sref = &s;
│ -- Immutable because of this position
9 │ let xref = &s.x;
10 │ &mut sref.v;
│ ^^^^^^^^^^^ Invalid mutable borrow from an immutable reference
error[E07001]: referential transparency violated
┌─ tests/move_check/typing/mutable_borrow_from_immutable.move:11:9
│
9 │ let xref = &s.x;
│ ---- Immutable because of this position
10 │ &mut sref.v;
11 │ &mut xref.v;
│ ^^^^^^^^^^^ Invalid mutable borrow from an immutable reference
error[E03010]: unbound field
┌─ tests/move_check/typing/mutable_borrow_from_immutable.move:11:14
│
11 │ &mut xref.v;
│ ^^^^^^ Unbound field 'v' in '0x8675309::M::X'
error[E07001]: referential transparency violated
┌─ tests/move_check/typing/mutable_borrow_from_immutable.move:15:9
│
14 │ fun t2(s: &S, x: &X) {
│ -- Immutable because of this position
15 │ x.f = x.f + 1;
│ ^^^ Invalid mutable borrow from an immutable reference
error[E07001]: referential transparency violated
┌─ tests/move_check/typing/mutable_borrow_from_immutable.move:16:9
│
14 │ fun t2(s: &S, x: &X) {
│ -- Immutable because of this position
15 │ x.f = x.f + 1;
16 │ s.x.f = s.x.f + 1
│ ^^^^^ Invalid mutable borrow from an immutable reference
This is V2 error:
Diagnostics:
error: cannot mutably borrow from an immutable ref
┌─ tests/reference-safety/v1-typing/mutable_borrow_from_immutable.move:6:9
│
6 │ &mut (&s).v;
│ ^^^^^^^^^^^
error: field `v` not declared in struct `X`
┌─ tests/reference-safety/v1-typing/mutable_borrow_from_immutable.move:11:14
│
11 │ &mut xref.v;
│ ^^^^
🐛 Bug
For the test case
third_party/move/move-compiler-v2/tests/reference-safety/v1-typing/mutable_borrow_from_immutable.exp
, V2 generates fewer error messages because some of them are suppressed.