mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: remove all unnecessary parenthesis at once, instead of one pair at a time (#18441)
This commit is contained in:
parent
6806086bf1
commit
bbd1027a04
@ -2599,15 +2599,15 @@ pub fn (mut f Fmt) or_expr(node ast.OrExpr) {
|
||||
}
|
||||
|
||||
pub fn (mut f Fmt) par_expr(node ast.ParExpr) {
|
||||
requires_paren := node.expr !is ast.Ident
|
||||
if requires_paren {
|
||||
f.par_level++
|
||||
f.write('(')
|
||||
}
|
||||
mut expr := node.expr
|
||||
for mut expr is ast.ParExpr {
|
||||
expr = expr.expr
|
||||
}
|
||||
requires_paren := expr !is ast.Ident
|
||||
if requires_paren {
|
||||
f.par_level++
|
||||
f.write('(')
|
||||
}
|
||||
f.expr(expr)
|
||||
if requires_paren {
|
||||
f.par_level--
|
||||
|
@ -1,4 +1,9 @@
|
||||
fn main() {
|
||||
x := 3
|
||||
_ := &x
|
||||
_ := &x
|
||||
_ := &x
|
||||
|
||||
_, _ := (22 > 11), (43 > 22)
|
||||
_ := (10 + 11)
|
||||
_ := (11 * 2)
|
||||
|
@ -1,4 +1,9 @@
|
||||
fn main() {
|
||||
x := 3
|
||||
_ := &((x))
|
||||
_ := &(((x)))
|
||||
_ := &((((x))))
|
||||
|
||||
_, _ := (((22 > 11))), (43 > 22)
|
||||
_ := ((10 + 11))
|
||||
_ := ((((((11 * 2))))))
|
||||
|
Loading…
Reference in New Issue
Block a user