-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[T]::pop_front()
panics when inside non-executed if
#5462
Comments
Looks like Instead of calling Anyway, neither It looks like there is a length check on |
# Description TODO - [x] Make note to finish slice test after `pop_front` issue: #5462 - [x] Refactor `any::<T>()` - [x] Make issues for failing tests ## Problem\* Part of #5362 ## Summary\* Simple combinator-based parsing tests for control flow. - Originally designed for slices, but adapted to arrays by emulating slices as bounded vectors ```rust struct Bvec<T, let N: u32> { inner: [T; N], // elements at indices < offset are zero offset: u32, // elements at indices >= len are zero len: u32, } ``` ## Additional Context This code is hacky, but let me know if any parts are worth cleaning up for the stdlib, e.g. `reverse_array`. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
# Description ## Problem\* Partial fix to #5462 ## Summary\* This PR doesn't fully fix #5462 but allows full compilation of a program without panicking. The test program from #5462 now successfully compiles (due to us being able to remove the inactive branch during inlining) We still fail to properly handle branches which are conditional on runtime values such as the below: ``` fn main(active: bool) { let empty_slice: [u8] = &[]; if !active { let _ = empty_slice.pop_front(); } } ``` This compiles to the below program ``` Compiled ACIR for main (unoptimized): func 0 current witness index : 2 private parameters indices : [0] public parameters indices : [] return value indices : [] BLACKBOX::RANGE [(0)] [ ] INIT (id: 0, len: 0) EXPR [ (-1, _1) 0 ] MEM (id: 0, read at: x1, value: x2) ``` This will then fail to execute with the below error: ``` error: Index out of bounds, array has size 0, but index was 0 ┌─ /mnt/user-data/tom/noir/test_programs/execution_success/inactive_slice_popping/src/main.nr:11:17 │ 11 │ let _ = empty_slice.pop_front(); │ --------------------- │ = Call stack: 1. /mnt/user-data/tom/noir/test_programs/execution_success/inactive_slice_popping/src/main.nr:11:17 ``` Note the memory block has been allocated with a length of 0 so even applying a predicate to the array get will fail. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
# Description ## Problem\* Regression test for github.com//issues/5462 ## Summary\* - Added the test from [5462](github.com//issues/5462) - Updated the issue needed to re-enable the `array_regex` execution test ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
* master: (202 commits) chore: remove usage of slices in pedersen hash (#6295) chore: remove dead function (#6308) feat: new formatter (#6300) feat: Sync from aztec-packages (#6301) fix: Allow array map on empty arrays (#6305) fix: Display function name and body when inlining recursion limit hit (#6291) feat(interpreter): Comptime derive generators (#6303) fix: enforce correctness of decompositions performed at compile time (#6278) feat: Warn about private types leaking in public functions and struct fields (#6296) chore(docs): refactoring guides and some other nits (#6175) fix: Do not warn on unused self in traits (#6298) fix: Reject invalid expression with in CLI parser (#6287) chore: regression test for #5462 (#6286) feat(improve): Remove scan through globals (#6282) feat: show LSP diagnostic related information (#6277) feat: trait inheritance (#6252) feat: optimize reading a workspace's files (#6281) fix: prevent compiler panic when popping from empty slices (#6274) feat(test): Include the PoseidonHasher in the fuzzing (#6280) feat: slightly improve "unexpected token" error message (#6279) ...
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
The application panicked (crashed). Message: There are no elements in this slice to be removed Location: compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs:162
To Reproduce
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: d44f882, is dirty: false)
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: