- -- If the module name is Main, allow it to be in a file
- -- different from Main.hs, and mash the mod and loc
- -- to match. Otherwise just moan.
- (mashed_mod, mashed_loc)
- <- case () of
- () | mod_name == moduleName mod
- -> return (mod, location)
- | mod_name /= moduleName mod && mod_name == mkModuleName "Main"
- -> return (mash mod location "Main")
- | otherwise
- -> do hPutStrLn stderr (showSDoc (
- text "ghc: warning: file name - module name mismatch:" <+>
- ppr (moduleName mod) <+> text "vs" <+> ppr mod_name))
- return (mash mod location (moduleNameUserString (moduleName mod)))
- where
- mash old_mod old_loc new_nm
- = (mkHomeModule (mkModuleName new_nm),
- old_loc{ml_hi_file = maybe_swizzle_basename new_nm
- (ml_hi_file old_loc)})
-
- maybe_swizzle_basename new Nothing = Nothing
- maybe_swizzle_basename new (Just old)
- = case splitFilename3 old of
- (dir, name, ext) -> Just (dir ++ new ++ ext)
-
- return (ModSummary mashed_mod
- mashed_loc{ml_hspp_file=Just hspp_fn}
- srcimps imps
- maybe_src_timestamp)
+ if mod_name == moduleName mod
+ then return ()
+ else throwDyn (OtherError
+ (showSDoc (text "file name does not match module name: "
+ <+> ppr (moduleName mod) <+> text "vs"
+ <+> ppr mod_name)))
+
+ return (ModSummary mod location{ml_hspp_file=Just hspp_fn}
+ srcimps imps
+ maybe_src_timestamp)