@@ -47,25 +47,26 @@ fn (mut g Gen) array_init(node ast.ArrayInit, var_name string) {
4747 }
4848 is_sumtype := elem_sym.kind == .sum_type
4949 for i, expr in node.exprs {
50- if node.expr_types[i] == ast.string_type
50+ expr_type := if node.expr_types.len > i { node.expr_types[i] } else { node.elem_type }
51+ if expr_type == ast.string_type
5152 && expr ! in [ast.IndexExpr, ast.CallExpr, ast.StringLiteral, ast.StringInterLiteral, ast.InfixExpr] {
5253 if is_sumtype {
53- g.expr_with_cast (expr, node.expr_types[i] , node.elem_type)
54+ g.expr_with_cast (expr, expr_type , node.elem_type)
5455 } else {
5556 g.write ('string_clone(' )
5657 g.expr (expr)
5758 g.write (')' )
5859 }
5960 } else {
6061 if node.elem_type.has_flag (.option) {
61- g.expr_with_opt (expr, node.expr_types[i] , node.elem_type)
62+ g.expr_with_opt (expr, expr_type , node.elem_type)
6263 } else if elem_type.unaliased_sym.kind == .array_fixed
6364 && expr in [ast.Ident, ast.SelectorExpr] {
6465 info := elem_type.unaliased_sym.info as ast.ArrayFixed
6566 g.fixed_array_var_init (g.expr_string (expr), expr.is_auto_deref_var (),
6667 info.elem_type, info.size)
6768 } else {
68- g.expr_with_cast (expr, node.expr_types[i] , node.elem_type)
69+ g.expr_with_cast (expr, expr_type , node.elem_type)
6970 }
7071 }
7172 if i != len - 1 {
0 commit comments