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

checker/fmt/cgen: fun vfmt on changes from previous commit

This commit is contained in:
Joe Conigliaro 2020-03-21 00:46:00 +11:00
parent a331abf675
commit 15d4b5fcdb
3 changed files with 8 additions and 14 deletions
vlib/v

@ -406,9 +406,6 @@ fn (f mut Fmt) expr(node ast.Expr) {
f.write(' ') f.write(' ')
} }
} }
// if !single_line {
// f.writeln('')
// }
f.write('}') f.write('}')
f.single_line_if = false f.single_line_if = false
} }

@ -1176,7 +1176,7 @@ fn (g mut Gen) if_expr(node ast.IfExpr) {
} }
// one line ?: // one line ?:
// TODO clean this up once `is` is supported // TODO clean this up once `is` is supported
// TODO: make sure only one stmt in eac branch // TODO: make sure only one stmt in each branch
if node.is_expr && node.branches.len >= 2 && node.has_else && type_sym.kind != .void { if node.is_expr && node.branches.len >= 2 && node.has_else && type_sym.kind != .void {
g.inside_ternary = true g.inside_ternary = true
for i, branch in node.branches { for i, branch in node.branches {
@ -1211,7 +1211,6 @@ fn (g mut Gen) if_expr(node ast.IfExpr) {
g.writeln(') {') g.writeln(') {')
} }
} }
} }
else if i < node.branches.len - 1 || !node.has_else { else if i < node.branches.len - 1 || !node.has_else {
g.writeln('} else if (') g.writeln('} else if (')
@ -1229,9 +1228,7 @@ fn (g mut Gen) if_expr(node ast.IfExpr) {
// Assign ret value // Assign ret value
// if i == node.stmts.len - 1 && type_sym.kind != .void {} // if i == node.stmts.len - 1 && type_sym.kind != .void {}
// g.writeln('$tmp =') // g.writeln('$tmp =')
//
g.stmts(branch.stmts) g.stmts(branch.stmts)
// g.writeln('')
} }
if is_guard { if is_guard {
g.write('}') g.write('}')