Commit 9d96f56f authored by simonmar's avatar simonmar

[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.
parent ce9fd3c8
......@@ -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}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment