Closed michaeljklein closed 1 month ago
Looks like pop_back
is broken as well but in a different way.
Instead of calling pop_back
on its slice internally it repeatedly calls push_front to build a new slice. I believe this is to avoid logic on guessing how many times to pop when the element is a struct type which is represented as multiple SSA values.
Anyway, neither pop_back
nor pop_front
have checks for if the slice is empty. pop_front
leads to the error you found while pop_back
will silently "optimize" to an empty array result. Execution will still fail though because it will leave behind a v0 = sub u32 0, u32 1
instruction. When this happens the program just exits with "Constraint Failed" and no explanation.
It looks like there is a length check on SliceRemove
and SliceInsert
at least.
Aim
Attempted to conditionally
pop_front
from a slice, depending on whether it's empty:Expected Behavior
I expected the predicate to prevent
pop_front
from executing and failing when the slice is empty.Bug
To Reproduce
1. 2. 3. 4.
Project Impact
Nice-to-have
Impact Context
NOTE: this is required to finish the slice control flow test here.
Workaround
None
Workaround Description
No response
Additional Context
No response
Installation Method
Binary (
noirup
default)Nargo Version
nargo version = 0.31.0 noirc version = 0.31.0+d44f882be094bf492b1742370fd3896b0c371f59 (git version hash: d44f882be094bf492b1742370fd3896b0c371f59, is dirty: false)
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response