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

fmt: remove extra parentheses (#14125)

This commit is contained in:
yuyi 2022-04-21 23:20:32 +08:00 committed by GitHub
parent 2080557f50
commit 26b0e7fd34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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))
}