Added a warning when we removed an unused variable
This commit is contained in:
parent
0d486f108f
commit
6fc4ac9550
|
@ -278,11 +278,12 @@ checkProcCallArgsUsage = mapM_ checkArgs . listify isProcCall
|
|||
checkUnusedVar :: CheckOptM ()
|
||||
checkUnusedVar = forAnyAST doSpec
|
||||
where
|
||||
doSpec (A.Spec _ (A.Specification _ name _) scope :: A.Structured A.Process)
|
||||
doSpec (A.Spec _ (A.Specification mspec name _) scope :: A.Structured A.Process)
|
||||
= do vars <- withChild [1] $ getCachedAnalysis' isScopeIn varsTouchedAfter
|
||||
liftIO $ putStrLn $ "Vars: " ++ show vars
|
||||
when (not $ (Var $ A.Variable emptyMeta name) `Set.member` vars) $
|
||||
substitute scope
|
||||
do warnPC mspec WarnUnusedVariable $ formatCode "Unused variable: %" name
|
||||
substitute scope
|
||||
doSpec _ = return ()
|
||||
|
||||
isScopeIn :: UsageLabel -> Bool
|
||||
|
|
|
@ -117,6 +117,9 @@ instance Die CheckOptM where
|
|||
instance CSMR CheckOptM where
|
||||
getCompState = CheckOptM . lift $ getCompState
|
||||
|
||||
instance Warn CheckOptM where
|
||||
warnReport = CheckOptM . lift . warnReport
|
||||
|
||||
deCheckOptM :: CheckOptM a -> StateT CheckOptData PassM a
|
||||
deCheckOptM (CheckOptM x) = x
|
||||
|
||||
|
@ -154,6 +157,12 @@ instance Die m => Die (ReaderT (Route t outer) m) where
|
|||
instance Die (CheckOptM' t) where
|
||||
dieReport = liftCheckOptM . dieReport
|
||||
|
||||
instance Warn (CheckOptM' t) where
|
||||
warnReport = liftCheckOptM . warnReport
|
||||
|
||||
instance CSMR (CheckOptM' t) where
|
||||
getCompState = liftCheckOptM getCompState
|
||||
|
||||
askRoute :: CheckOptM' t (Route t A.AST)
|
||||
askRoute = CheckOptM' . RestartT . liftM Right $ ask
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user