mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix for (int i = 0; i < 10; i++, a++) {
(multiple expressions in the inc part)
This commit is contained in:
parent
82eb495617
commit
3ac3375b43
@ -70,8 +70,22 @@ fn (mut g Gen) for_c_stmt(node ast.ForCStmt) {
|
||||
}
|
||||
g.write('; ')
|
||||
if node.has_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
|
||||
g.inside_for_c_stmt = false
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user