You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I should not be allowed to take a &mut from a non-mut variable. Not only does Noir allow it, it apparently creates a copy of the value when doing so, which means that the mutable reference does not refer to the original value, leading to hard-to-track bugs in which expected mutations are not carried out.
Expected Behavior
Given
fnbar(x: &mutField) {
*x = 2;
}
then none of the following calls to bar should compile, but they all do
# Description
## Problem
Resolves#5721
## Summary
Today I bumped into this bug so I thought about trying to fix it.
## Additional Context
## Documentation
Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.
# PR Checklist
- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Aim
I should not be allowed to take a
&mut
from a non-mut
variable. Not only does Noir allow it, it apparently creates a copy of the value when doing so, which means that the mutable reference does not refer to the original value, leading to hard-to-track bugs in which expected mutations are not carried out.Expected Behavior
Given
then none of the following calls to
bar
should compile, but they all doBug
These two tests pass, but
take_ref_from_non_mut
should not even compile.The text was updated successfully, but these errors were encountered: