From: simonmar Date: Tue, 27 Aug 2002 09:38:43 +0000 (+0000) Subject: [project @ 2002-08-27 09:38:43 by simonmar] X-Git-Tag: Approx_11550_changesets_converted~1750 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c79b5b17018b7b2b455d27bbc578a1ba59f7c94d;p=ghc-hetmet.git [project @ 2002-08-27 09:38:43 by simonmar] - If the same module is defined in multiple "root" source files, then complain. Before, the compiler would silently ignore one of them. - Remove some unuseed imports MERGE TO STABLE --- diff --git a/ghc/compiler/compMan/CompManager.lhs b/ghc/compiler/compMan/CompManager.lhs index abe2bf7..bc76eab 100644 --- a/ghc/compiler/compMan/CompManager.lhs +++ b/ghc/compiler/compMan/CompManager.lhs @@ -57,9 +57,6 @@ where #include "HsVersions.h" -import MkIface --tmp -import HsSyn -- tmp - import CmLink import CmTypes import DriverPipeline @@ -1151,6 +1148,7 @@ topological_sort include_source_imports summaries downsweep :: [FilePath] -> [ModSummary] -> IO [ModSummary] downsweep roots old_summaries = do rootSummaries <- mapM getRootSummary roots + checkDuplicates rootSummaries all_summaries <- loop (concat (map (\ m -> zip (repeat (fromMaybe "" (ml_hs_file (ms_location m)))) (ms_imps m)) rootSummaries)) @@ -1179,6 +1177,21 @@ downsweep roots old_summaries hs_file = file ++ ".hs" lhs_file = file ++ ".lhs" + -- In a root module, the filename is allowed to diverge from the module + -- name, so we have to check that there aren't multiple root files + -- defining the same module (otherwise the duplicates will be silently + -- ignored, leading to confusing behaviour). + checkDuplicates :: [ModSummary] -> IO () + checkDuplicates summaries = mapM_ check summaries + where check summ = + case dups of + [] -> return () + files -> multiRootsErr modl files + where modl = ms_mod summ + dups = + [ fromJust (ml_hs_file (ms_location summ')) + | summ' <- summaries, ms_mod summ' == modl ] + getSummary :: (FilePath,ModuleName) -> IO (Maybe ModSummary) getSummary (currentMod,nm) = do found <- findModule nm @@ -1290,4 +1303,10 @@ packageModErr mod = throwDyn (CmdLineError (showSDoc (text "module" <+> quotes (ppr mod) <+> text "is a package module"))) + +multiRootsErr mod files + = throwDyn (ProgramError (showSDoc ( + text "module" <+> quotes (ppr mod) <+> + text "is defined in multiple files:" <+> + sep (map text files)))) \end{code}