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
Given an array, the program tries to get another of length y.
use dep::std;
use dep::std::collections::vec::Vec;
global DEPTH: Field = 40000;
fn main(x: [u32; DEPTH], y: u32) {
let mut new_x = Vec::new();
new_x = clear(x, y);
}
unconstrained fn clear(x: [u32; DEPTH], y: u32) -> Vec<u32> {
let mut a = Vec::new();
for i in 0..y{
a.push(x[i]);
}
a
}
Expected Behavior
Should have run successfully, to populate new_x with values
Bug
But when running it gives an error: internal error: entered unreachable code: The type [u32] cannot be represented in ACIR
To Reproduce
Installation Method
None
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
Yes
Support Needs
No response
The text was updated successfully, but these errors were encountered:
Unfortunately, Vec<T> cannot be passed between unconstrained and non-unconstrained functions because it contains a slice internally. Slices and references are both prohibited to cross this boundary, although for different reasons. For slices it is because we'd need to know their exact length at that point - so you'd need to convert them to an array. For references, it is because any mutations to the reference inside the unconstrained function will not be observed outside.
I'll work on a better user-facing compiler error to explain this.
#4280)
# Description
## Problem\*
Resolves#2535
## Summary\*
We currently panic when attempting to return a slice from an
unconstrained runtime to an ACIR runtime. In some cases such as in the
linked issue the panic is not very clear at all.
New error:
<img width="811" alt="Screenshot 2024-02-06 at 1 33 39 PM"
src="https://github.com/noir-lang/noir/assets/43554004/e37e7b3b-13ef-4222-a359-2f14084478da">
## Additional Context
## Documentation\*
Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.
# PR Checklist\*
- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
---------
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Aim
Given an array, the program tries to get another of length
y
.Expected Behavior
Should have run successfully, to populate
new_x
with valuesBug
But when running it gives an error:
internal error: entered unreachable code: The type [u32] cannot be represented in ACIR
To Reproduce
Installation Method
None
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
Yes
Support Needs
No response
The text was updated successfully, but these errors were encountered: