-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
132 additions
and
8 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
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_struct_array_conditional/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_struct_array_conditional" | ||
version = "0.1.0" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
18 changes: 18 additions & 0 deletions
18
test_programs/execution_success/regression_struct_array_conditional/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,18 @@ | ||
y = 1 | ||
z = 1 | ||
|
||
[[x]] | ||
value = "0x23de33be058ce5504e1ade738db8bdacfe268fa9dbde777092bf1d38519bdf59" | ||
counter = "10" | ||
dummy = "0" | ||
|
||
[[x]] | ||
value = "3" | ||
counter = "2" | ||
dummy = "0" | ||
|
||
[[x]] | ||
value = "2" | ||
counter = "0" | ||
dummy = "0" | ||
|
38 changes: 38 additions & 0 deletions
38
test_programs/execution_success/regression_struct_array_conditional/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,38 @@ | ||
struct foo { | ||
value: Field, | ||
counter: u8, | ||
dummy: u8, | ||
} | ||
struct bar { | ||
dummy: [u8;3], | ||
value: Field, | ||
counter: u8, | ||
} | ||
struct bar_field { | ||
dummy: [Field;3], | ||
value: Field, | ||
counter: u8, | ||
} | ||
fn main(x: [foo; 3], y: u32, z: u32) -> pub u8 { | ||
let a = [y, z, x[y].counter as u32]; | ||
let mut b = [bar { value: 0, counter: 0, dummy: [0; 3] }; 3]; | ||
let mut c = [bar_field { value: 0, counter: 0, dummy: [0; 3] }; 3]; | ||
for i in 0..3 { | ||
b[i].value = x[i].value; | ||
b[i].counter = x[i].counter; | ||
b[i].dummy[0] = x[i].dummy; | ||
c[i].value = x[i].value; | ||
c[i].counter = x[i].counter; | ||
c[i].dummy[0] = x[i].dummy as Field; | ||
} | ||
if z == 0 { | ||
// offset | ||
assert(y as u8 < x[y].counter); | ||
assert(y <= a[y]); | ||
// first element is compatible | ||
assert(y as u8 < b[y].counter); | ||
// fallback | ||
assert(y as u8 < c[y].counter); | ||
} | ||
x[0].counter | ||
} |