Skip to content

Commit f20652c

Browse files
authored
ci,cgen: fix regression in ./v test vlib/toml after 38ac4e6 (#26485)
1 parent f8a9f2e commit f20652c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎vlib/v/gen/c/infix.v‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)