Skip to content

Commit

Permalink
cgen: support inc cond for c style for loop with alias types
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Jun 20, 2024
1 parent b0a9820 commit 0d068aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vlib/v/gen/c/assign.v
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
g.expr(left)
g.write(' ${extracted_op} ')
g.expr(val)
g.write(';')
if !g.inside_for_c_stmt {
g.write(';')
}
return
} else {
g.write(' = ${styp}_${util.replace_op(extracted_op)}(')
Expand Down
10 changes: 10 additions & 0 deletions vlib/v/slow_tests/inout/alias_for_c_loop_assign_op.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
10 changes: 10 additions & 0 deletions vlib/v/slow_tests/inout/alias_for_c_loop_assign_op.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type Float = f32

fn main() {
min_value := Float(1)
max_value := Float(10)
step := Float(1)
for n := min_value; n <= max_value; n += step {
println('${n}')
}
}

0 comments on commit 0d068aa

Please sign in to comment.