-
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: Consider constants as used values to keep their rc ops (#6122)
# Description ## Problem\* Resolves #6121 ## Summary\* Die was not considering constants as used. As a result, the reference counter operations on constants were removed. This created a correctness issue. ## 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.
- Loading branch information
1 parent
5598059
commit 1217005
Showing
4 changed files
with
27 additions
and
0 deletions.
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
6 changes: 6 additions & 0 deletions
6
test_programs/execution_success/brillig_constant_reference_regression/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,6 @@ | ||
[package] | ||
name = "brillig_constant_reference_regression" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
1 change: 1 addition & 0 deletions
1
test_programs/execution_success/brillig_constant_reference_regression/Prover.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 @@ | ||
sorted_index = ["1", "0"] |
16 changes: 16 additions & 0 deletions
16
test_programs/execution_success/brillig_constant_reference_regression/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,16 @@ | ||
unconstrained fn main(sorted_index: [u32; 2]) { | ||
let original = [ | ||
55, | ||
11 | ||
]; | ||
|
||
let mut sorted = original; // Stores the constant "original" into the sorted reference | ||
|
||
for i in 0..2 { | ||
let index = sorted_index[i]; | ||
let value = original[index]; | ||
sorted[i] = value; // On first iteration, we should not mutate the original constant array, RC should be > 1 | ||
} | ||
|
||
assert_eq(sorted[1], 55); | ||
} |