File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1052,11 +1052,16 @@ fn (mut g Gen) infix_expr_left_shift_op(node ast.InfixExpr) {
10521052 array_info := left.unaliased_sym.info as ast.Array
10531053 noscan := g.check_noscan (array_info.elem_type)
10541054 elem_is_option := array_info.elem_type.has_flag (.option)
1055+ mut prevent_push_many := g.table.sumtype_has_variant (array_info.elem_type, node.right_type,
1056+ false )
1057+ if prevent_push_many && node.right is ast.CallExpr {
1058+ // Allow concatenation for array-returning calls; avoids nesting for common builder APIs.
1059+ prevent_push_many = false
1060+ }
10551061 if (right.unaliased_sym.kind == .array
10561062 || (right.unaliased_sym.kind == .struct && right.unaliased_sym.name == 'array' ))
10571063 && left.sym.nr_dims () == right.sym.nr_dims () && array_info.elem_type != right.typ
1058- && ! elem_is_option
1059- && ! g.table.sumtype_has_variant (array_info.elem_type, node.right_type, false ) {
1064+ && ! elem_is_option && ! prevent_push_many {
10601065 // push an array => PUSH_MANY, but not if pushing an array to 2d array (`[][]int << []int`)
10611066 g.write ('_PUSH_MANY${noscan }(' )
10621067 mut expected_push_many_atype := left.typ
You can’t perform that action at this time.
0 commit comments