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] tuple assignment to var message is confusing #12669

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

Comments

@brmataptos
Copy link
Contributor

🐛 Bug

PR 12223 fixes the error message in third_party/move/move-compiler-v2/tests/checking/typing/assign_wrong_arity.exp but it is still confusing.

The relevant code is:

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

The new error output is:

Diagnostics:
error: the left-hand side has 0 items but the right-hand side provided 3
  ┌─ tests/checking/typing/assign_wrong_arity.move:7:9
  │
7 │         x = (0, 1, 2);
  │         ^

which is better than before, but it is still confusing because the real problem is assigning a tuple to a local var at all.

That test output is also failing to error on the previous statement which assigns () to x, since those errors show up later in the compiler, in code generation. The message suggests that the type analysis is giving x a fixed type of Tuple(0), whichi is kind of strange.

Anyway, this particular error should be easy enough to fix in type analysis by changing the error message if the target seems to be of type Tuple(0).

@brmataptos brmataptos added bug Something isn't working compiler-v2 labels Mar 25, 2024
@sausagee sausagee added the stale-exempt Prevents issues from being automatically marked and closed as stale label Mar 26, 2024
@vineethk
Copy link
Contributor

Another test case to add for this issue (taken from third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.move from this PR: #12818):

module 0xc0ffee::m {
    fun tup(): (u64, u64) {
        (0, 0)
    }

    public fun bar() {
        let _ = tup();
    }
}

Here, v1 points to the return type of tup(), which can be helpful (although the wording used by v1 is probably what we want to use).

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 stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants