1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: remove an extra \n in for loops (#5618)

This commit is contained in:
yuyi 2020-07-02 17:03:40 +08:00 committed by GitHub
parent 6c022db786
commit e904732554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -709,6 +709,12 @@ fn (mut g Gen) stmt(node ast.Stmt) {
g.write('; ')
} else {
g.stmt(node.init)
// Remove excess return and add space
if g.out.last_n(1) == '\n' {
g.out.go_back(1)
g.empty_line = false
g.write(' ')
}
}
if node.has_cond {
g.expr(node.cond)