From 0e34ce2759c11adbc8a300fae76bda3fea3f8e87 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 13 Jun 2021 02:14:08 +0800 Subject: [PATCH] cgen: format generated code in match_expr() (#10397) --- vlib/v/gen/c/cgen.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 9f731c8342..0c8854fbd7 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -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;') }