fmt: remove extra parentheses (#14125)

yuyi 2022-04-21 23:20:32 +08:00 committed by Jef Roosens
parent 34961a23b4
commit 6eea50c955
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 17 additions and 1 deletions

View File

@ -2315,7 +2315,11 @@ pub fn (mut f Fmt) par_expr(node ast.ParExpr) {
f.par_level++
f.write('(')
}
f.expr(node.expr)
mut expr := node.expr
for mut expr is ast.ParExpr {
expr = expr.expr
}
f.expr(expr)
if requires_paren {
f.par_level--
f.write(')')

View File

@ -0,0 +1,6 @@
fn main() {
_, _ := (22 > 11), (43 > 22)
_ := (10 + 11)
_ := (11 * 2)
_ := (11 * 2)
}

View File

@ -0,0 +1,6 @@
fn main() {
_, _ := (((22 > 11))), (43 > 22)
_ := ((10 + 11))
_ := ((((((11 * 2))))))
_ := ((11 * 2))
}