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][Compiler-v2] mutability mismatch of reference (&mut != &) in equality expression #11738

Closed
rahxephon89 opened this issue Jan 23, 2024 · 0 comments · Fixed by #12162
Closed
Assignees
Labels
bug Something isn't working compiler-v2 stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@rahxephon89
Copy link
Contributor

🐛 Bug

When compiling the following code:

    fun t3(): bool {
        let x = 5;
        let y = 7;
        &mut x == &y
    }

The following error will be generated:

+ error: invalid call of `==`: mutability mismatch (&mut != &) for argument 2
+    ┌─ tests/checking/typing/mutable_eq_and_neq.move:43:19
+    │
+ 43 │         &mut x == &y
+    │                   ^^

Same issues happens when compiling experimental package in third_party/move/documentation/examples/diem-framework/move-packages/experimental using V2:

    ┌─ /Users/tengzhang/aptos-core/third_party/move/documentation/examples/diem-framework/move-packages/experimental/../core/sources/configs/DiemSystem.move:286:27
    │
286 │         if (config_ref == &new_validator_config) {
    │                           ^^^^^^^^^^^^^^^^^^^^^
@rahxephon89 rahxephon89 added bug Something isn't working stale-exempt Prevents issues from being automatically marked and closed as stale compiler-v2 labels Jan 23, 2024
@rahxephon89 rahxephon89 self-assigned this Jan 23, 2024
@wrwg wrwg assigned wrwg and unassigned rahxephon89 Feb 8, 2024
wrwg added a commit that referenced this issue Feb 22, 2024
This enables the comparison of references with mixed mutability (`&x == &mut y`), and introduces generation of the `FreezeRef` operation when an argument is widned from mutable to immutable references. The later applies for any kind of function call, not only equalities. Without freeze, certain scenarios produce borrow errors in reference safety and/or the bytecode verifier.

Note that this PR is intended to work together with the new reference safety analysis, so some tests do not yet work without it.

Fixes #12151
Fixes #11738
Fixes #11434
wrwg added a commit that referenced this issue Feb 26, 2024
This enables the comparison of references with mixed mutability (`&x == &mut y`), and introduces generation of the `FreezeRef` operation when an argument is widned from mutable to immutable references. The later applies for any kind of function call, not only equalities. Without freeze, certain scenarios produce borrow errors in reference safety and/or the bytecode verifier.

Note that this PR is intended to work together with the new reference safety analysis, so some tests do not yet work without it.

Fixes #12151
Fixes #11738
Fixes #11434
wrwg added a commit that referenced this issue Feb 26, 2024
This enables the comparison of references with mixed mutability (`&x == &mut y`), and introduces generation of the `FreezeRef` operation when an argument is widned from mutable to immutable references. The later applies for any kind of function call, not only equalities. Without freeze, certain scenarios produce borrow errors in reference safety and/or the bytecode verifier.

Note that this PR is intended to work together with the new reference safety analysis, so some tests do not yet work without it.

Fixes #12151
Fixes #11738
Fixes #11434
wrwg added a commit that referenced this issue Feb 26, 2024
This enables the comparison of references with mixed mutability (`&x == &mut y`), and introduces generation of the `FreezeRef` operation when an argument is widned from mutable to immutable references. The later applies for any kind of function call, not only equalities. Without freeze, certain scenarios produce borrow errors in reference safety and/or the bytecode verifier.

Note that this PR is intended to work together with the new reference safety analysis, so some tests do not yet work without it.

Fixes #12151
Fixes #11738
Fixes #11434
wrwg added a commit that referenced this issue Feb 27, 2024
This enables the comparison of references with mixed mutability (`&x == &mut y`), and introduces generation of the `FreezeRef` operation when an argument is widned from mutable to immutable references. The later applies for any kind of function call, not only equalities. Without freeze, certain scenarios produce borrow errors in reference safety and/or the bytecode verifier.

Note that this PR is intended to work together with the new reference safety analysis, so some tests do not yet work without it.

Fixes #12151
Fixes #11738
Fixes #11434
@wrwg wrwg closed this as completed in 997d925 Feb 27, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Move Language and Runtime Feb 27, 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
Development

Successfully merging a pull request may close this issue.

2 participants