Skip to content

Commit af7b835

Browse files
committed
#662, don't warn on ($x), since it might not really be TH
1 parent d2b7c52 commit af7b835

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Changelog for HLint (* = breaking change)
22

3+
#662, don't warn on ($x), since it might not really be TH
34
#660, suggest tuple sections for \y -> (x,y) and similar
45
#667, warn on return x >> m and similar
56
#653, add symmetric versions of some == hints

src/Hint/Bracket.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ yes = f (x) y -- @Warning x
2626
no = f (+x) y
2727
no = f ($x) y
2828
no = ($x)
29-
yes = (($x)) -- @Warning ($x)
29+
yes = (($x))
3030
no = ($1)
3131
yes = (($1)) -- @Warning ($1)
3232
no = (+5)
@@ -104,6 +104,7 @@ bracketHint _ _ x =
104104
x -> x
105105

106106
isPartialAtom :: Exp_ -> Bool
107+
isPartialAtom (SpliceExp _ IdSplice{}) = True -- might be $x, which was really $ x, but TH enabled misparsed it
107108
isPartialAtom x = isRecConstr x || isRecUpdate x
108109

109110
-- Dirty, should add to Brackets type class I think
@@ -131,7 +132,7 @@ bracket isPartialAtom root = f Nothing
131132
-- f (Maybe (index, parent, gen)) child
132133
f :: (Data (a S), ExactP a, Pretty (a S), Brackets (a S)) => Maybe (Int,a S,a S -> a S) -> a S -> [Idea]
133134
f Just{} o@(remParens -> Just x) | isAtom x, not $ isPartialAtom x = bracketError msg o x : g x
134-
f Nothing o@(remParens -> Just x) | root || isAtom x = (if isAtom x then bracketError else bracketWarning) msg o x : g x
135+
f Nothing o@(remParens -> Just x) | root || isAtom x, not $ isPartialAtom x = (if isAtom x then bracketError else bracketWarning) msg o x : g x
135136
f (Just (i,o,gen)) v@(remParens -> Just x) | not $ needBracket i o x, not $ isPartialAtom x =
136137
suggest msg o (gen x) [r] : g x
137138
where

0 commit comments

Comments
 (0)