From 2673ace2d5b0c605d6a8107c4500b406a7f73810 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 13 Nov 2008 13:01:22 +0000 Subject: [PATCH] Changed the lambda in checkUnusedVar to be an inner function, now that I've removed my code that used to ignore pattern-match failures --- checks/Check.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/checks/Check.hs b/checks/Check.hs index 02a64e6..9f07f1a 100644 --- a/checks/Check.hs +++ b/checks/Check.hs @@ -276,13 +276,15 @@ checkProcCallArgsUsage = mapM_ checkArgs . listify isProcCall -- TODO make this work on any structured type (provide forAnyASTStruct) checkUnusedVar :: CheckOptM () -checkUnusedVar = forAnyAST $ \(A.Spec _ (A.Specification _ 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 +checkUnusedVar = forAnyAST doSpec where + doSpec (A.Spec _ (A.Specification _ 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 + doSpec _ = return () + isScopeIn :: UsageLabel -> Bool isScopeIn (Usage _ (Just (ScopeIn {})) _ _) = True isScopeIn _ = False