You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
brillig fn main f0 {
b0(v0: Field, v1: Field):
v3, v4 = call f1(v0, v1)
v6, v7 = call f1(v1, v0)
v9 = allocate
store [v3, v4, v6, v7] at v9
v10 = load v9
v13 = array_get v10, index Field 2
v15 = array_get v10, index Field 3
v16 = eq v13, v1
constrain v16
v18 = load v9
v19, v20, v21 = call slice_remove(v18, Field 2)
...
}
Bug
The ssa generated looks like this:
brillig fn main f0 {
b0(v0: Field, v1: Field):
v3, v4 = call f1(v0, v1)
v6, v7 = call f1(v1, v0)
v9 = allocate
store [v3, v4, v6, v7] at v9
v10 = load v9
v13 = array_get v10, index Field 2
v15 = array_get v10, index Field 3
v16 = eq v13, v1
constrain v16
v18 = load v9
v19, v20, v21 = call slice_remove(v18, Field 1) // here: The index should have been multipled by the number of elements in the struct
// Like it has been for array_get operations
v22 = eq v20, v1
constrain v22
v24 = array_get v21, index Field 0
v25 = eq v24, Field 0
constrain v25
return
}
Aim
Slices of structs should generate consistent SSA
Expected Behavior
Consider the following code:
It should generate SSA like the following:
Bug
The ssa generated looks like this:
Also, the simplification in SSA does not handle correctly struct slices:
https://github.com/noir-lang/noir/blob/master/crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs#L438
As you can see there, it's assuming there is only going to be one parameter to push to a slice. But when pushing to struct slices, the SSA does have one parameter per field of the struct:
To Reproduce
Installation Method
None
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: