-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Type check ACIR mutable reference passed to brillig (#4281)
# Description ## Problem\* Resolves #4245 ## Summary\* This adds a type check for call expressions to check the arguments of a call to an unconstrained function from a constrained function. As we have two different runtime environments this makes type checking a bit more complicated. As a followup to this PR we could try and catch the error added here (#4280) sooner. However, if the unconstrained function uses generics we must still fall back to the "type check" in SSA/ACIR gen from PR #4280. This PR now errors for the snippet in issue with the below using `nargo check`: <img width="900" alt="Screenshot 2024-02-06 at 3 36 27 PM" src="https://github.com/noir-lang/noir/assets/43554004/6c037458-3182-4ea4-8470-050a1734b875"> ## Additional Context ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test_programs/compile_failure/brillig_mut_ref_from_acir/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "brillig_mut_ref_from_acir" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.23.0" | ||
|
||
[dependencies] |
8 changes: 8 additions & 0 deletions
8
test_programs/compile_failure/brillig_mut_ref_from_acir/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
unconstrained fn mut_ref_identity(value: &mut Field) -> Field { | ||
*value | ||
} | ||
|
||
fn main(mut x: Field, y: pub Field) { | ||
let returned_x = mut_ref_identity(&mut x); | ||
assert(returned_x == x); | ||
} |