mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: appending to an array of sumtype (#18201)
This commit is contained in:
parent
1e9dcb9b9e
commit
adcf47dcce
@ -178,7 +178,7 @@ fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type {
|
||||
continue
|
||||
} else if expecting_sumtype_array {
|
||||
if i == 0 {
|
||||
if c.table.is_sumtype_or_in_variant(expected_value_type, typ) {
|
||||
if c.table.is_sumtype_or_in_variant(expected_value_type, ast.mktyp(typ)) {
|
||||
elem_type = expected_value_type
|
||||
} else {
|
||||
if expr.is_auto_deref_var() {
|
||||
|
@ -0,0 +1,8 @@
|
||||
type IntStr = int | string
|
||||
|
||||
fn test_array_of_sumtype_append_array_of_sumtype() {
|
||||
mut a := [IntStr(1), 2, 'a']
|
||||
a << [3, 4, 'dsafa']
|
||||
println(a)
|
||||
assert '${a}' == "[IntStr(1), IntStr(2), IntStr('a'), IntStr(3), IntStr(4), IntStr('dsafa')]"
|
||||
}
|
Loading…
Reference in New Issue
Block a user