Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][move-compiler-v2] V2 error messaging should show the assignments that lead to the type constraints #14634

Open
brmataptos opened this issue Sep 14, 2024 · 1 comment
Labels
bug Something isn't working compiler-v2-stable compiler-v2 stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@brmataptos
Copy link
Contributor

🐛 Bug

Two test cases illustrate this bug:

Case 1

This test case:

  • third_party/move/move-compiler/tests/move_check/typing/assign_unpack_references_invalid.exp
  • third_party/move/move-compiler-v2/tests/checking/typing/assign_unpack_references_invalid.exp

V2 shows an error like:

error: cannot assign `integer` to left-hand side of type `&u64`
  ┌─ tests/checking/typing/assign_unpack_references_invalid.move:9:9
  │
9 │         f = 0;
  │         ^

where the code is:

      2     struct S { f: u64 }
      ...
      6         let f;
      8         R { s1: S { f }, s2 } = &R { s1: S{f: 0}, s2: S{f: 1} };
      9         f = 0;

So the fact that the "left-hand side" f has type &u64 is indirect.

V1 has a better error message, which provides some context that explains the type of f:

error[E04007]: incompatible types
  ┌─ tests/move_check/typing/assign_unpack_references_invalid.move:9:9
  │
8 │         R { s1: S { f }, s2 } = &R { s1: S{f: 0}, s2: S{f: 1} };
  │                     - Expected: '&u64'
9 │         f = 0;
  │         ^
  │         │
  │         Invalid assignment to local 'f'
  │         Given: integer

.

Case 2

In this test case:

  • third_party/move/move-compiler/tests/move_check/typing/assign_wrong_arity.exp
  • third_party/move/move-compiler-v2/tests/checking/typing/assign_wrong_arity.exp
    V2 says something like:
error: tuple type `(integer, integer, integer)` is not allowed as a local variable type
  ┌─ tests/checking/typing/assign_wrong_arity.move:5:13
  │
5 │         let x;
  │             ^
  │
  = required by declaration of local `x`

where the relevant code is:

      5         let x;
      6         x = ();
      7         x = (0, 1, 2);

so it points to the declaration of x but doesn't show the assignment which tries to assign a tuple-typed value to it.

Copy link
Contributor

This issue is stale because it has been open 45 days with no activity. Remove the stale label or comment - otherwise this will be closed in 15 days.

@github-actions github-actions bot added the Stale label Oct 30, 2024
@wrwg wrwg added stale-exempt Prevents issues from being automatically marked and closed as stale and removed Stale labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler-v2-stable compiler-v2 stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants