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
Attempted to compile a program where an empty array is accessed within a non-executed if statement:
fnmain(x: pubbool) {
letempty_array: [Field; 0] = [];
ifx {
let_ = empty_array[0];
}
// the same error occurs when the `if` block is elided:// let _ = empty_array[0];// and when the index is dynamic (x: pub u32)// if x == 0 {// let _ = empty_array[x];// }// and when the array is dynamic (xs: pub [Field; 0])// let empty_array: [Field; 0] = xs;
}
Expected Behavior
Expected the program to compile successfully
Bug
nargo compile panics during the DIE pass:
The application panicked (crashed).
Message: attempt to divide by zero
Location: compiler/noirc_evaluator/src/ssa/opt/die.rs:386
This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at https://github.com/noir-lang/noir/issues/.
If there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml
To Reproduce
Workaround
Yes
Workaround Description
Locate empty array
Replace with the singleton array [std::mem::zeroed()]
Add a new parameter to ignore the std::mem::zeroed() when needed
Additional Context
No response
Project Impact
None
Blocker Context
No response
Nargo Version
nargo version = 0.33.0 noirc version = 0.33.0+712468a08dd95eaed42345320e8c3e6751e88c47 (git version hash: 712468a, is dirty: false)
NoirJS Version
No response
Proving Backend Tooling & 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:
# Description
## Problem
Resolves#5936
## Summary
## Additional Context
I was computing an array's element size in a way that could lead to
dividing by zero, but there was already a method to get the element
size.
## 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 <jake@aztecprotocol.com>
Aim
Attempted to compile a program where an empty array is accessed within a non-executed
if
statement:Expected Behavior
Expected the program to compile successfully
Bug
nargo compile
panics during the DIE pass:To Reproduce
Workaround
Yes
Workaround Description
[std::mem::zeroed()]
std::mem::zeroed()
when neededAdditional Context
No response
Project Impact
None
Blocker Context
No response
Nargo Version
nargo version = 0.33.0 noirc version = 0.33.0+712468a08dd95eaed42345320e8c3e6751e88c47 (git version hash: 712468a, is dirty: false)
NoirJS Version
No response
Proving Backend Tooling & 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: