From: simonmar Date: Fri, 5 Mar 2004 16:04:05 +0000 (+0000) Subject: [project @ 2004-03-05 16:04:05 by simonmar] X-Git-Tag: Approx_11550_changesets_converted~20 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=9d96f56fb2ae81bb93a2583fc6cb09fa1c30b67a;p=ghc-hetmet.git [project @ 2004-03-05 16:04:05 by simonmar] Fail with an error if the interface file we're reading doesn't contain the module we were expecting. --- diff --git a/ghc/compiler/iface/LoadIface.lhs b/ghc/compiler/iface/LoadIface.lhs index a1ceb2d..945e7ea 100644 --- a/ghc/compiler/iface/LoadIface.lhs +++ b/ghc/compiler/iface/LoadIface.lhs @@ -498,7 +498,11 @@ findAndReadIface doc_str mod_name hi_boot_file ; read_result <- readIface mod_name file_path hi_boot_file ; case read_result of Left err -> returnM (Left (badIfaceFile file_path err)) - Right iface -> returnM (Right iface) + Right iface + | moduleName (mi_module iface) /= mod_name -> + return (Left (wrongIfaceModErr iface mod_name file_path)) + | otherwise -> + returnM (Right iface) }}} findHiFile :: ModuleName -> IsBootInterface @@ -681,4 +685,15 @@ noIfaceErr dflags mod_name boot_file files text "(use -v to see a list of the files searched for)" | otherwise = hang (ptext SLIT("locations searched:")) 4 (vcat (map text files)) + +wrongIfaceModErr iface mod_name file_path + = sep [ptext SLIT("Interface file") <+> iface_file, + ptext SLIT("contains module") <+> quotes (ppr (mi_module iface)) <> comma, + ptext SLIT("but we were expecting module") <+> quotes (ppr mod_name), + sep [ptext SLIT("Probable cause: the source code which generated"), + nest 2 iface_file, + ptext SLIT("has an incompatible module name") + ] + ] + where iface_file = doubleQuotes (text file_path) \end{code}