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] Cannot check equality between mutable and immutable reference #11434

Closed
rahxephon89 opened this issue Dec 20, 2023 · 0 comments · Fixed by #12162
Closed

[Bug][Compiler-v2] Cannot check equality between mutable and immutable reference #11434

rahxephon89 opened this issue Dec 20, 2023 · 0 comments · Fixed by #12162
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

After landing the PR #11371, the compiler V2 will generate an error when trying to check equality between mutable and immutable reference. For instance, for the following function:

 fun t0(s: S, s_ref: &S) {
    (&mut s == s_ref: bool);
}

The compiler will generate the error:

Diagnostics:
error: invalid call of `==`: mutability mismatch (&mut != &) for argument 2
   ┌─ tests/checking/typing/eq.move:18:20
   │
18 │         (&mut s == s_ref: bool);
   │                    ^^^^^
@rahxephon89 rahxephon89 added bug Something isn't working stale-exempt Prevents issues from being automatically marked and closed as stale compiler-v2 labels Dec 20, 2023
@wrwg wrwg self-assigned this Feb 15, 2024
@wrwg wrwg moved this from 🆕 New to 📋 Backlog in Move Language and Runtime Feb 15, 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 📋 Backlog 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