hlint 1.9.9 → 1.9.10
raw patch · 4 files changed
+59/−1 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +2/−0
- hlint.cabal +2/−1
- src/Hint/All.hs +2/−0
- src/Hint/Unsafe.hs +53/−0
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for HLint +1.9.10+ Spot unsafePerformIO without NOINLINE 1.9.9 #89, fix compiling the executable with --flag=-gpl 1.9.8
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.6 build-type: Simple name: hlint-version: 1.9.9+version: 1.9.10 license: BSD3 license-file: LICENSE category: Development@@ -96,6 +96,7 @@ Hint.Pragma Hint.Structure Hint.Type+ Hint.Unsafe Hint.Util Test.All Test.Annotations
src/Hint/All.hs view
@@ -21,6 +21,7 @@ import Hint.Extensions import Hint.Duplicate import Hint.Comment+import Hint.Unsafe -- | A list of builtin hints, currently including entries such as @\"List\"@ and @\"Bracket\"@.@@ -36,6 +37,7 @@ ,"Import" + importHint ,"Pragma" + pragmaHint ,"Extensions" + extensionsHint+ ,"Unsafe" + unsafeHint ,"Duplicate" * duplicateHint ,"Comment" - commentHint ]
+ src/Hint/Unsafe.hs view
@@ -0,0 +1,53 @@+{-# LANGUAGE ViewPatterns #-}++{-+ Find things that are unsafe++<TEST>+{-# NOINLINE slaves #-}; slaves = unsafePerformIO newIO+slaves = unsafePerformIO Multimap.newIO -- {-# NOINLINE slaves #-} ; slaves = unsafePerformIO Multimap.newIO+slaves = unsafePerformIO $ f y where foo = 1 -- {-# NOINLINE slaves #-} ; slaves = unsafePerformIO $ f y where foo = 1+slaves v = unsafePerformIO $ Multimap.newIO where foo = 1+slaves v = x where x = unsafePerformIO $ Multimap.newIO+slaves = x where x = unsafePerformIO $ Multimap.newIO -- {-# NOINLINE slaves #-} ; slaves = x where x = unsafePerformIO $ Multimap.newIO+slaves = unsafePerformIO . bar+slaves = unsafePerformIO . baz $ x -- {-# NOINLINE slaves #-} ; slaves = unsafePerformIO . baz $ x+slaves = unsafePerformIO . baz $ x -- {-# NOINLINE slaves #-} ; slaves = unsafePerformIO . baz $ x+</TEST>+-}+++module Hint.Unsafe(unsafeHint) where++import Hint.Type+import Data.Char+++unsafeHint :: ModuHint+unsafeHint _ m =+ [ rawIdea Error "Missing NOINLINE pragma" (toSrcSpan $ ann d)+ (prettyPrint d)+ (Just $ dropWhile isSpace (prettyPrint $ gen x) ++ "\n" ++ prettyPrint d)+ []+ | d@(PatBind _ (PVar _ x) _ _) <- moduleDecls m+ , isUnsafeDecl d, x `notElem_` noinline]+ where+ gen x = InlineSig an False Nothing $ UnQual an x+ noinline = [q | InlineSig _ False Nothing (UnQual _ q) <- moduleDecls m]++isUnsafeDecl :: Decl_ -> Bool+isUnsafeDecl (PatBind _ _ rhs bind) =+ any isUnsafeApp (childrenBi rhs) || any isUnsafeDecl (childrenBi bind)+isUnsafeDecl _ = False++-- Am I equivalent to @unsafePerformIO x@+isUnsafeApp :: Exp_ -> Bool+isUnsafeApp (InfixApp _ x d _) | isDol d = isUnsafeFun x+isUnsafeApp (App _ x _) = isUnsafeFun x+isUnsafeApp _ = False++-- Am I equivalent to @unsafePerformIO . x@+isUnsafeFun :: Exp_ -> Bool+isUnsafeFun (Var _ x) | x ~= "unsafePerformIO" = True+isUnsafeFun (InfixApp _ x d _) | isDot d = isUnsafeFun x+isUnsafeFun _ = False