-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description ## Problem\* Resolves #4017 ## Summary\* After this PR #3979 and an internal discussion we have decided to temporarily block nested slices. This PR adds a check in the frontend and in the SSA against nested slices. The check in the frontend makes sure any struct fields with a nested slice (but without generics) are not blocked as well as any type declarations with nested slices. In order to account for generics in structs we also have a checked array codegen that makes sure we do not have a nested slice. ## Additional Context The actual nested slice code in the ACIR gen is somewhat intertwined so I felt it would be best for a separate PR which will be a followup to this one. ## Documentation\* Check one: - [] No documentation needed. - [X] Documentation included in this PR. - [ ] **[Exceptional Case]** 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.
- Loading branch information
Showing
21 changed files
with
170 additions
and
542 deletions.
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
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
test_programs/compile_failure/nested_slice_declared_type/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 = "nested_slice_declared_type" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.22.0" | ||
|
||
[dependencies] |
6 changes: 6 additions & 0 deletions
6
test_programs/compile_failure/nested_slice_declared_type/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,6 @@ | ||
fn main(x: Field, y: pub Field) { | ||
assert(x != y); | ||
|
||
let slice: [[Field]] = []; | ||
assert(slice.len() != 10); | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/compile_failure/nested_slice_literal/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 = "nested_slice_literal" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.22.0" | ||
|
||
[dependencies] |
23 changes: 23 additions & 0 deletions
23
test_programs/compile_failure/nested_slice_literal/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,23 @@ | ||
struct FooParent<T> { | ||
parent_arr: [Field; 3], | ||
foos: [Foo<T>], | ||
} | ||
|
||
struct Bar { | ||
inner: [Field; 3], | ||
} | ||
|
||
struct Foo<T> { | ||
a: Field, | ||
b: T, | ||
bar: Bar, | ||
} | ||
|
||
fn main(x: Field, y: pub Field) { | ||
assert(x != y); | ||
|
||
let foo = Foo { a: 7, b: [8, 9, 22].as_slice(), bar: Bar { inner: [106, 107, 108] } }; | ||
let mut slice = [foo, foo]; | ||
slice = slice.push_back(foo); | ||
assert(slice.len() == 3); | ||
} |
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 = "nested_slice_struct" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.22.0" | ||
|
||
[dependencies] |
18 changes: 18 additions & 0 deletions
18
test_programs/compile_failure/nested_slice_struct/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,18 @@ | ||
struct FooParent { | ||
parent_arr: [Field; 3], | ||
foos: [Foo], | ||
} | ||
|
||
struct Bar { | ||
inner: [Field; 3], | ||
} | ||
|
||
struct Foo { | ||
a: Field, | ||
b: [Field], | ||
bar: Bar, | ||
} | ||
|
||
fn main(x: Field, y: pub Field) { | ||
assert(x != y); | ||
} |
7 changes: 0 additions & 7 deletions
7
test_programs/execution_success/brillig_set_slice_of_slice/Nargo.toml
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
test_programs/execution_success/brillig_set_slice_of_slice/src/main.nr
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
test_programs/execution_success/slice_struct_field/Nargo.toml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.