1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix alloc empty struct array error (#14007)

This commit is contained in:
牧心
2022-04-11 19:16:09 +08:00
committed by GitHub
parent 843ce43077
commit 25d8faabf6
4 changed files with 32 additions and 3 deletions

View File

@ -300,3 +300,15 @@ fn test_alias_string_contains() {
names := [Str('')]
assert (Str('') in names) == true
}
struct XYZ {}
fn test_array_append_empty_struct() {
mut names := []XYZ{cap: 2}
names << XYZ{}
assert (XYZ{} in names) == true
// test fixed array
array := [XYZ{}]
assert (XYZ{} in names) == true
}