-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Clean error when attemping to return a slice from Brillig to ACIR (
#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>
- Loading branch information
1 parent
e5cfb4d
commit bcad4ec
Showing
6 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test_programs/compile_failure/brillig_slice_to_acir/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "brillig_slice_to_acir" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.23.0" | ||
|
||
[dependencies] |
14 changes: 14 additions & 0 deletions
14
test_programs/compile_failure/brillig_slice_to_acir/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
global DEPTH: Field = 40000; | ||
|
||
fn main(x: [u32; DEPTH], y: u32) { | ||
let mut new_x = []; | ||
new_x = clear(x, y); | ||
} | ||
|
||
unconstrained fn clear(x: [u32; DEPTH], y: u32) -> [u32] { | ||
let mut a = []; | ||
for i in 0..y { | ||
a = a.push_back(x[i]); | ||
} | ||
a | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "brillig_vec_to_acir" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.23.0" | ||
|
||
[dependencies] |
14 changes: 14 additions & 0 deletions
14
test_programs/compile_failure/brillig_vec_to_acir/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
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 | ||
} |