Commit 9bdf3d8c authored by Kirchmayr's avatar Kirchmayr
Browse files

Differentiate between warnings for unused global bindings and others

parent 38cb35e0
......@@ -123,7 +123,7 @@ checkExports :: Maybe ExportSpec -> WCM () -- TODO checks
checkExports Nothing = ok
checkExports (Just (Exporting _ exports)) = do
mapM_ visitExport exports
reportUnusedVars
reportUnusedGlobalVars
where
visitExport (Export qid) = visitQId qid
visitExport _ = ok
......@@ -870,7 +870,13 @@ checkShadowing x = warnFor WarnNameShadowing $
shadowsVar x >>= maybe ok (report . warnShadowing x)
reportUnusedVars :: WCM ()
reportUnusedVars = warnFor WarnUnusedBindings $ do
reportUnusedVars = reportAllUnusedVars WarnUnusedBindings
reportUnusedGlobalVars :: WCM ()
reportUnusedGlobalVars = reportAllUnusedVars WarnUnusedGlobalBindings
reportAllUnusedVars :: WarnFlag -> WCM ()
reportAllUnusedVars wFlag = warnFor wFlag $ do
unused <- returnUnrefVars
unless (null unused) $ mapM_ report $ map warnUnrefVar unused
......
......@@ -153,39 +153,42 @@ data TargetType
-- |Warnings flags
data WarnFlag
= WarnMultipleImports -- ^ Warn for multiple imports
| WarnDisjoinedRules -- ^ Warn for disjoined function rules
| WarnUnusedBindings -- ^ Warn for unused bindings
| WarnNameShadowing -- ^ Warn for name shadowing
| WarnOverlapping -- ^ Warn for overlapping rules/alternatives
| WarnIncompletePatterns -- ^ Warn for incomplete pattern matching
| WarnMissingSignatures -- ^ Warn for missing type signatures
= WarnMultipleImports -- ^ Warn for multiple imports
| WarnDisjoinedRules -- ^ Warn for disjoined function rules
| WarnUnusedGlobalBindings -- ^ Warn for unused global bindings
| WarnUnusedBindings -- ^ Warn for unused local bindings
| WarnNameShadowing -- ^ Warn for name shadowing
| WarnOverlapping -- ^ Warn for overlapping rules/alternatives
| WarnIncompletePatterns -- ^ Warn for incomplete pattern matching
| WarnMissingSignatures -- ^ Warn for missing type signatures
deriving (Eq, Bounded, Enum, Show)
-- |Warning flags enabled by default
stdWarnFlags :: [WarnFlag]
stdWarnFlags =
[ WarnMultipleImports , WarnDisjoinedRules --, WarnUnusedBindings
, WarnNameShadowing , WarnOverlapping , WarnIncompletePatterns
, WarnMissingSignatures
[ WarnMultipleImports , WarnDisjoinedRules --, WarnUnusedGlobalBindings
, WarnUnusedBindings , WarnNameShadowing , WarnOverlapping
, WarnIncompletePatterns, WarnMissingSignatures
]
-- |Description and flag of warnings flags
warnFlags :: [(WarnFlag, String, String)]
warnFlags =
[ ( WarnMultipleImports , "multiple-imports"
[ ( WarnMultipleImports , "multiple-imports"
, "multiple imports" )
, ( WarnDisjoinedRules , "disjoined-rules"
, ( WarnDisjoinedRules , "disjoined-rules"
, "disjoined function rules" )
, ( WarnUnusedBindings , "unused-bindings"
, ( WarnUnusedGlobalBindings, "unused-global-bindings"
, "unused bindings" )
, ( WarnNameShadowing , "name-shadowing"
, ( WarnUnusedBindings , "unused-bindings"
, "unused bindings" )
, ( WarnNameShadowing , "name-shadowing"
, "name shadowing" )
, ( WarnOverlapping , "overlapping"
, ( WarnOverlapping , "overlapping"
, "overlapping function rules" )
, ( WarnIncompletePatterns, "incomplete-patterns"
, ( WarnIncompletePatterns , "incomplete-patterns"
, "incomplete pattern matching")
, ( WarnMissingSignatures , "missing-signatures"
, ( WarnMissingSignatures , "missing-signatures"
, "missing type signatures" )
]
......
......@@ -51,7 +51,9 @@ runTest :: CO.Options -> String -> [String] -> IO Progress
runTest opts test [] = passOrFail <$> runSecure (buildCurry opts' test)
where
wOpts = CO.optWarnOpts opts
wFlags = CO.WarnUnusedBindings : CO.wnWarnFlags wOpts
wFlags = CO.WarnUnusedBindings
: CO.WarnUnusedGlobalBindings
: CO.wnWarnFlags wOpts
opts' = opts { CO.optForce = True
, CO.optWarnOpts = wOpts { CO.wnWarnFlags = wFlags }
}
......@@ -63,7 +65,9 @@ runTest opts test [] = passOrFail <$> runSecure (buildCurry opts' test)
runTest opts test errorMsgs = catchE <$> runSecure (buildCurry opts' test)
where
wOpts = CO.optWarnOpts opts
wFlags = CO.WarnUnusedBindings : CO.wnWarnFlags wOpts
wFlags = CO.WarnUnusedBindings
: CO.WarnUnusedGlobalBindings
: CO.wnWarnFlags wOpts
opts' = opts { CO.optForce = True
, CO.optWarnOpts = wOpts { CO.wnWarnFlags = wFlags }
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment