-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Restrict fill_internal_slices pass to acir functions (#3634)
* restrict fill_internal_slices pass to acir functions * rename test
- Loading branch information
Showing
3 changed files
with
67 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/brillig_set_slice_of_slice/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_set_slice_of_slice" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.19.4" | ||
|
||
[dependencies] |
51 changes: 51 additions & 0 deletions
51
test_programs/execution_success/brillig_set_slice_of_slice/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,51 @@ | ||
struct Property | ||
{ | ||
key : [u8], | ||
value : [u8], | ||
} | ||
|
||
struct JSON | ||
{ | ||
doc : [Property] | ||
} | ||
|
||
unconstrained fn slice_eq(self: [u8], other: [u8]) -> bool { | ||
let mut equal = true; | ||
for i in 0..self.len() { | ||
if self[i] != other[i] { | ||
equal = false; | ||
} | ||
} | ||
equal | ||
} | ||
|
||
// This test acts a regression for issue #3476 | ||
unconstrained fn main() { | ||
let mut json = JSON { doc: [] }; | ||
let mut prop = Property { key: [], value:[] }; | ||
|
||
let other_prop = Property { key: [0, 1, 2], value:[10] }; | ||
json.doc = json.doc.push_back(other_prop); | ||
|
||
for i in 0..3 { | ||
prop.key = prop.key.push_back(i as u8); | ||
} | ||
prop.value = prop.value.push_back(5); | ||
|
||
// add property to json or replace existing | ||
let len : Field = json.doc.len(); | ||
let mut found = false; | ||
for i in 0..len | ||
{ | ||
if (!found) | ||
{ | ||
if (slice_eq(prop.key, json.doc[i].key)) | ||
{ | ||
json.doc[i].value = prop.value; | ||
found = true; | ||
} | ||
} | ||
} | ||
assert(found == true); | ||
assert(json.doc[0].value[0] == 5); | ||
} |