-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into jf/fix-slice-coercion
- Loading branch information
Showing
4 changed files
with
40 additions
and
3 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
7 changes: 7 additions & 0 deletions
7
test_programs/execution_success/regression_capacity_tracker/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 = "regression_capacity_tracker" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.26.0" | ||
|
||
[dependencies] |
3 changes: 3 additions & 0 deletions
3
test_programs/execution_success/regression_capacity_tracker/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,3 @@ | ||
expected = "10" | ||
first = "10" | ||
input = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] |
19 changes: 19 additions & 0 deletions
19
test_programs/execution_success/regression_capacity_tracker/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,19 @@ | ||
// Reference https://github.com/noir-lang/noir/issues/4395#issuecomment-2018948631 | ||
// for context. | ||
// We were not accurately accounting for situations where the slice capacity tracker | ||
// was expecting a capacity from slice intrinsic results. | ||
fn main(expected: pub Field, first: Field, input: [Field; 20]) { | ||
let mut hasher_slice = input.as_slice(); | ||
hasher_slice = hasher_slice.push_front(first); | ||
assert(hasher_slice[0] == expected); | ||
// We need a conditional based upon witnesses | ||
// to force a store of the slice. | ||
// If this successfully compiles it means we have stored | ||
// the results of the slice intrinsics used above. | ||
if expected as u32 > 10 { | ||
hasher_slice[expected - 10] = 100; | ||
} else { | ||
hasher_slice[expected] = 100; | ||
} | ||
assert(hasher_slice[0] == expected); | ||
} |