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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
}