mirror of
https://github.com/google/ormolu.git
synced 2024-11-27 03:24:10 +03:00
Fix extra layer of parentheses around operator sections
This commit is contained in:
parent
1e6f4cdc95
commit
e00bd3e72a
@ -9,3 +9,5 @@ baz =
|
||||
( *
|
||||
3 ^ 5
|
||||
)
|
||||
|
||||
quux = (,) <$> foo <$> bar
|
||||
|
@ -5,3 +5,5 @@ baz =
|
||||
+ )
|
||||
( *
|
||||
3 ^ 5)
|
||||
|
||||
quux = (,) <$> foo <$> bar
|
||||
|
@ -56,7 +56,7 @@ p_rdrName l@(L spn _) = located l $ \x -> do
|
||||
if AnnOpenP `elem` ids
|
||||
then parens
|
||||
else id
|
||||
(m, isUnit) =
|
||||
(m, avoidParens) =
|
||||
case x of
|
||||
Unqual occName ->
|
||||
(atom occName, False)
|
||||
@ -68,8 +68,8 @@ p_rdrName l@(L spn _) = located l $ \x -> do
|
||||
-- NOTE I'm not sure this "stable string" is stable enough, but
|
||||
-- it looks like this is the most robust way to tell if we're
|
||||
-- looking at exactly this piece of built-in syntax.
|
||||
(atom name, nameStableString name == "$ghc-prim$GHC.Tuple$()")
|
||||
if isUnit
|
||||
(atom name, nameStableString name `elem` avoidParensStableNames)
|
||||
if avoidParens
|
||||
then m
|
||||
else parensWrapper (backticksWrapper m)
|
||||
|
||||
@ -83,3 +83,13 @@ p_ieWildcard :: IEWildcard -> R ()
|
||||
p_ieWildcard = \case
|
||||
NoIEWildcard -> return ()
|
||||
IEWildcard n -> parens (atom n)
|
||||
|
||||
avoidParensStableNames :: [String]
|
||||
avoidParensStableNames =
|
||||
[ "$ghc-prim$GHC.Tuple$()"
|
||||
, "$ghc-prim$GHC.Tuple$(,)"
|
||||
, "$ghc-prim$GHC.Tuple$(,,)"
|
||||
, "$ghc-prim$GHC.Tuple$(,,,)"
|
||||
, "$ghc-prim$GHC.Tuple$(,,,,)"
|
||||
, "$ghc-prim$GHC.Tuple$(,,,,,)"
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user