cgen: support inc cond for c style for loop with alias types (#21708)

This commit is contained in:
Swastik Baranwal 2024-06-22 15:45:43 +05:30 committed by GitHub
parent 4302f8698e
commit 2bb815f0fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -520,7 +520,9 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
g.expr(left)
g.write(' ${extracted_op} ')
g.expr(val)
if !g.inside_for_c_stmt {
g.write(';')
}
return
} else {
g.write(' = ${styp}_${util.replace_op(extracted_op)}(')

View file

@ -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
}
}