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

Revert "fmt: fix parens around reference module prefix expressions (#18416)"

This reverts commit 7f178d4662.
This commit is contained in:
Alexander Medvednikov 2023-06-13 08:50:50 +03:00
parent 126fbe8e33
commit 24c09881f7
2 changed files with 3 additions and 24 deletions

View File

@ -2629,9 +2629,9 @@ pub fn (mut f Fmt) postfix_expr(node ast.PostfixExpr) {
}
pub fn (mut f Fmt) prefix_expr(node ast.PrefixExpr) {
if node.right is ast.ParExpr {
if node.op == .not && node.right.expr is ast.InfixExpr {
// !(a in b) => a !in b, !(a is b) => a !is b
// !(a in b) => a !in b, !(a is b) => a !is b
if node.op == .not && node.right is ast.ParExpr {
if node.right.expr is ast.InfixExpr {
if node.right.expr.op in [.key_in, .not_in, .key_is, .not_is]
&& node.right.expr.right !is ast.InfixExpr {
f.expr(node.right.expr.left)
@ -2645,14 +2645,6 @@ pub fn (mut f Fmt) prefix_expr(node ast.PrefixExpr) {
f.expr(node.right.expr.right)
return
}
} else if node.op == .amp && node.right.expr is ast.Ident {
// Reference prefix ParExpr. E.g.: `a := &(modname.constname)`
f.write(node.op.str())
f.write('(')
f.expr(node.right)
f.or_expr(node.or_block)
f.write(')')
return
}
}
f.write(node.op.str())

View File

@ -1,13 +0,0 @@
module ast
struct MyChar {
c string
}
const a_char = MyChar{
c: 'a'
}
fn foo() {
mut b := &(ast.a_char)
}