diff --git a/vlib/v/checker/containers.v b/vlib/v/checker/containers.v index 6988a0179d..c0cd25b505 100644 --- a/vlib/v/checker/containers.v +++ b/vlib/v/checker/containers.v @@ -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() { diff --git a/vlib/v/tests/array_of_sumtype_append_array_of_sumtype_test.v b/vlib/v/tests/array_of_sumtype_append_array_of_sumtype_test.v new file mode 100644 index 0000000000..b72e7e5fb1 --- /dev/null +++ b/vlib/v/tests/array_of_sumtype_append_array_of_sumtype_test.v @@ -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')]" +}