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

pull/5620/head
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
1 changed files with 6 additions and 0 deletions

View File

@ -709,6 +709,12 @@ fn (mut g Gen) stmt(node ast.Stmt) {
g.write('; ') g.write('; ')
} else { } else {
g.stmt(node.init) 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 { if node.has_cond {
g.expr(node.cond) g.expr(node.cond)