-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ast: fix generic concrete of struct container type fields (fix #18852) (
- Loading branch information
Showing
3 changed files
with
98 additions
and
3 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
48 changes: 48 additions & 0 deletions
48
vlib/v/tests/generics_struct_field_with_generics_struct_elements_test.v
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,48 @@ | ||
struct Root[T] { | ||
mut: | ||
edge1 Edge[T] | ||
edge2 map[int]Edge[T] | ||
edge3 map[int][]Edge[T] | ||
edge4 []Edge[T] | ||
edge5 [][]Edge[T] | ||
edge6 [1]Edge[T] | ||
edge7 []T | ||
edge8 [][]T | ||
edge9 [1]T | ||
} | ||
|
||
struct Edge[T] { | ||
} | ||
|
||
fn new[T]() Root[T] { | ||
return Root[T]{} | ||
} | ||
|
||
// for issue 18852 | ||
fn test_generics_struct_field_with_generics_struct_elements() { | ||
mut root := new[int]() | ||
|
||
assert root.edge1 == Edge[int]{} | ||
|
||
root.edge2[1] = Edge[int]{} | ||
assert root.edge2[1] == Edge[int]{} | ||
|
||
root.edge3[1] = []Edge[int]{len: 1} | ||
assert root.edge3[1] == [Edge[int]{}] | ||
|
||
root.edge4 << Edge[int]{} | ||
assert root.edge4 == [Edge[int]{}] | ||
|
||
root.edge5 << root.edge4 | ||
assert root.edge5 == [[Edge[int]{}]] | ||
|
||
assert root.edge6 == [Edge[int]{}]! | ||
|
||
root.edge7 << 1 | ||
assert root.edge7 == [1] | ||
|
||
root.edge8 << root.edge7 | ||
assert root.edge8 == [[1]] | ||
|
||
assert root.edge9 == [0]! | ||
} |
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