mirror of
https://github.com/vlang/v.git
synced 2025-09-15 23:42:28 +03:00
cgen: support inc cond for c style for loop with alias types (#21708)
This commit is contained in:
parent
4302f8698e
commit
2bb815f0fd
2 changed files with 14 additions and 1 deletions
|
@ -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)}(')
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
type Float = f32
|
||||
|
||||
fn test_increment_of_alias_in_for_c_loop() {
|
||||
min_value := Float(1)
|
||||
max_value := Float(10)
|
||||
step := Float(1)
|
||||
for n := min_value; n <= max_value; n += step {
|
||||
println('${n}')
|
||||
assert n > 0.0 && n < 11.0
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue