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:
parent
2080557f50
commit
26b0e7fd34
@ -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(')')
|
||||
|
6
vlib/v/fmt/tests/extra_par_expr_expected.vv
Normal file
6
vlib/v/fmt/tests/extra_par_expr_expected.vv
Normal file
@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
_, _ := (22 > 11), (43 > 22)
|
||||
_ := (10 + 11)
|
||||
_ := (11 * 2)
|
||||
_ := (11 * 2)
|
||||
}
|
6
vlib/v/fmt/tests/extra_par_expr_input.vv
Normal file
6
vlib/v/fmt/tests/extra_par_expr_input.vv
Normal file
@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
_, _ := (((22 > 11))), (43 > 22)
|
||||
_ := ((10 + 11))
|
||||
_ := ((((((11 * 2))))))
|
||||
_ := ((11 * 2))
|
||||
}
|
Loading…
Reference in New Issue
Block a user