diff options
| author | aarne <aarne@chalmers.se> | 2012-06-25 11:14:52 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2012-06-25 11:14:52 +0000 |
| commit | d15e0f775d0eeb82e322f715d9e2a55d90206615 (patch) | |
| tree | 1358430e0ae168bc24a910ea722034f8055f5744 /src | |
| parent | 3dc2e55949496acd054bdb09428b4c44562ee0d0 (diff) | |
checkMapRecover: find undefined idents in all jments in Rename
Diffstat (limited to 'src')
| -rw-r--r-- | src/compiler/GF/Compile/Rename.hs | 2 | ||||
| -rw-r--r-- | src/compiler/GF/Infra/CheckM.hs | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/compiler/GF/Compile/Rename.hs b/src/compiler/GF/Compile/Rename.hs index 32ba76f9b..aeaf3b250 100644 --- a/src/compiler/GF/Compile/Rename.hs +++ b/src/compiler/GF/Compile/Rename.hs @@ -52,7 +52,7 @@ renameSourceTerm g m t = do renameModule :: [SourceModule] -> SourceModule -> Check SourceModule renameModule ms mo@(m,mi) = do status <- buildStatus (mGrammar ms) mo - js <- checkMap (renameInfo status mo) (jments mi) + js <- checkMapRecover (renameInfo status mo) (jments mi) return (m, mi{jments = js}) type Status = (StatusTree, [(OpenSpec, StatusTree)]) diff --git a/src/compiler/GF/Infra/CheckM.hs b/src/compiler/GF/Infra/CheckM.hs index 7a5ac2d45..c1198dea6 100644 --- a/src/compiler/GF/Infra/CheckM.hs +++ b/src/compiler/GF/Infra/CheckM.hs @@ -15,7 +15,7 @@ module GF.Infra.CheckM (Check(..), CheckResult(..), Message, runCheck, checkError, checkCond, checkWarn, - checkErr, checkIn, checkMap + checkErr, checkIn, checkMap, checkMapRecover ) where import GF.Data.Operations @@ -65,6 +65,13 @@ checkMap f map = do xs <- mapM (\(k,v) -> do v <- f k v return (k,v)) (Map.toList map) return (Map.fromAscList xs) +checkMapRecover :: (Ord a) => (a -> b -> Check b) -> Map.Map a b -> Check (Map.Map a b) +checkMapRecover f mp = do + let xs = map (\ (k,v) -> (k,runCheck (f k v))) (Map.toList mp) + case [s | (_,Bad s) <- xs] of + ss@(_:_) -> checkError (text (unlines ss)) + _ -> return (Map.fromAscList [(k,x) | (k, Ok (x,_)) <- xs]) + checkErr :: Err a -> Check a checkErr (Ok x) = return x checkErr (Bad err) = checkError (text err) |
