Check if some names were shadowed while loading the file
authorAnders Mörtberg <andersmortberg@gmail.com>
Thu, 8 Jun 2017 07:46:27 +0000 (09:46 +0200)
committerAnders Mörtberg <andersmortberg@gmail.com>
Thu, 8 Jun 2017 07:46:27 +0000 (09:46 +0200)
Main.hs

diff --git a/Main.hs b/Main.hs
index c41c03e0769ff07f9a3aaf385b6a7528a10a7fd1..fba67a939f5de4077e742415adc13b6175e70906 100644 (file)
--- a/Main.hs
+++ b/Main.hs
@@ -98,10 +98,19 @@ initLoop flags f hist = do
       putStrLn $ "Resolver failed: " ++ err
       runInputT (settings []) (putHistory hist >> loop flags f [] TC.verboseEnv)
     Right (adefs,names) -> do
+
       (merr,tenv) <- TC.runDeclss TC.verboseEnv adefs
       case merr of
         Just err -> putStrLn $ "Type checking failed: " ++ shrink err
-        Nothing  -> putStrLn "File loaded."
+        Nothing  -> do
+          putStrLn "File loaded."
+          -- After loading the file check if some definitions were shadowed:
+          let ns = map fst names
+              uns = nub ns
+              dups = ns \\ uns
+          unless (dups == []) $
+            putStrLn $ "Warning: the following definitions were shadowed [" ++
+                        intercalate ", " dups ++ "]"
       if Batch `elem` flags
         then return ()
         else -- Compute names for auto completion