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

cgen: format generated code in match_expr() (#10397)

This commit is contained in:
yuyi 2021-06-13 02:14:08 +08:00 committed by GitHub
parent b7f9bc2a96
commit 0e34ce2759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1026,7 +1026,9 @@ fn (mut g Gen) stmts_with_tmp_var(stmts []ast.Stmt, tmp_var string) {
g.skip_stmt_pos = true
g.write('$tmp_var = ')
g.stmt(stmt)
g.writeln(';')
if !g.out.last_n(2).contains(';') {
g.writeln(';')
}
}
} else {
g.stmt(stmt)
@ -4086,7 +4088,7 @@ fn (mut g Gen) match_expr(node ast.MatchExpr) {
}
if need_tmp_var {
g.empty_line = true
cur_line = g.go_before_stmt(0)
cur_line = g.go_before_stmt(0).trim_left(' \t')
tmp_var = g.new_tmp_var()
g.writeln('${g.typ(node.return_type)} $tmp_var;')
}