diff --git a/vlib/v/gen/c/for.v b/vlib/v/gen/c/for.v index a7e8b35b46..5e88134550 100644 --- a/vlib/v/gen/c/for.v +++ b/vlib/v/gen/c/for.v @@ -70,7 +70,21 @@ fn (mut g Gen) for_c_stmt(node ast.ForCStmt) { } g.write('; ') if node.has_inc { - g.stmt(node.inc) + mut processed := false + if node.inc is ast.ExprStmt { + if node.inc.expr is ast.ConcatExpr { + for inc_expr_idx, inc_expr in node.inc.expr.vals { + g.expr(inc_expr) + if inc_expr_idx < node.inc.expr.vals.len - 1 { + g.write(', ') + } + } + processed = true + } + } + if !processed { + g.stmt(node.inc) + } } g.writeln(') {') g.is_vlines_enabled = true diff --git a/vlib/v/tests/for_c_multiple_expressions_in_increment_test.v b/vlib/v/tests/for_c_multiple_expressions_in_increment_test.v new file mode 100644 index 0000000000..84c4c45df2 --- /dev/null +++ b/vlib/v/tests/for_c_multiple_expressions_in_increment_test.v @@ -0,0 +1,6 @@ +fn test_2_expressions_in_same_for_increment_part() { + mut a := 0 + for i := 0; i < 10; i++, a++ { + assert a == i + } +}