aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6.11k stars 3.62k forks source link

[Bug][Compiler-v2] Error messages are suppressed for the test mutable_borrow_from_immutable.exp #13500

Open rahxephon89 opened 4 months ago

rahxephon89 commented 4 months ago

🐛 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.

rahxephon89 commented 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
rahxephon89 commented 4 months ago

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;
   │              ^^^^