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] Wildcard patterns can be dropped #12475

Closed
brmataptos opened this issue Mar 12, 2024 · 2 comments · Fixed by #12818
Closed

[Bug][move-compiler-v2] Wildcard patterns can be dropped #12475

brmataptos opened this issue Mar 12, 2024 · 2 comments · Fixed by #12818
Assignees
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

The following example (moved_var_not_simplified3.move) generates no errors in V2, as it treats the wildcard (_) assignment as a noop in stackless-bytecode generation:

module 0xc0ffee::m {
    public fun test(): u8 {
        let x = 40;
        let y = move x;
        let _ = x;
        y
    }
}

In V1, it yields the following error:

error[E06002]: use of unassigned variable
  ┌─ tests/move_check/simplifier/moved_var_not_simplified3.move:5:17
  │
4 │         let y = move x;
  │                 ------
  │                 │
  │                 The value of 'x' was previously moved here.
  │                 Suggestion: use 'copy x' to avoid the move.
5 │         let _ = x;
  │                 ^ Invalid usage of previously moved variable 'x'.

If instead of a wildcard (_) we have a variable (_z) (test case moved_var_not_simplified2.move) then V2 produces a similar error.

@brmataptos
Copy link
Contributor Author

@wrwg points out we might even have cases where an illegal drop happens due to the wildcard. So we probably need to fix this.

@brmataptos
Copy link
Contributor Author

OTOH, converting _ to a variable may run into trouble because it might match a tuple.

@sausagee sausagee added the stale-exempt Prevents issues from being automatically marked and closed as stale label Mar 13, 2024
@wrwg wrwg moved this from 🆕 New to For Grabs in Move Language and Runtime Mar 14, 2024
@vineethk vineethk self-assigned this Mar 20, 2024
@vineethk vineethk moved this from For Grabs to Assigned in Move Language and Runtime Mar 20, 2024
@vineethk vineethk moved this from Assigned to 🏗 In progress in Move Language and Runtime Apr 11, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Move Language and Runtime Apr 12, 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 stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: Done
3 participants