[project @ 2002-10-15 11:52:31 by simonpj]
authorsimonpj <unknown>
Tue, 15 Oct 2002 11:52:32 +0000 (11:52 +0000)
committersimonpj <unknown>
Tue, 15 Oct 2002 11:52:32 +0000 (11:52 +0000)
------------------------------------------------
Fix exports for a module with  no local bindings
------------------------------------------------

Fix the export-list generation for a module with no local bindings.
This one bug was breaking a bunch of modxxx tests, plus some renamer
test, plus a desugarer test.

ghc/compiler/typecheck/TcRnDriver.lhs
ghc/compiler/typecheck/TcRnMonad.lhs

index 6e146f4..e3858d0 100644 (file)
@@ -145,7 +145,7 @@ tcRnModule hsc_env pcs
    do {        -- Deal with imports; sets tcg_rdr_env, tcg_imports
        (rdr_env, imports) <- rnImports import_decls ;
        updGblEnv ( \ gbl -> gbl { tcg_rdr_env = rdr_env,
-                                  tcg_imports = imports }) 
+                                  tcg_imports = tcg_imports gbl `plusImportAvails` imports }) 
                     $ do {
        traceRn (text "rn1") ;
                -- Fail if there are any errors so far
@@ -172,7 +172,7 @@ tcRnModule hsc_env pcs
        updGblEnv (\gbl -> gbl { tcg_deprecs = tcg_deprecs gbl `plusDeprecs` mod_deprecs })
                  $ do {
 
-       traceRn (text "rn4") ;
+       traceRn (text "Rn4:" <+> ppr (imp_unqual (tcg_imports tcg_env))) ;
                -- Process the export list
        export_avails <- exportsFromAvail exports ;
        updGblEnv (\gbl -> gbl { tcg_exports = export_avails })
index 58930ac..07dbe12 100644 (file)
@@ -14,7 +14,7 @@ import HscTypes               ( HscEnv(..), PersistentCompilerState(..),
                          GlobalRdrEnv, LocalRdrEnv, NameCache, FixityEnv,
                          GhciMode, lookupType, unQualInScope )
 import TcRnTypes
-import Module          ( Module, foldModuleEnv )
+import Module          ( Module, moduleName, foldModuleEnv )
 import Name            ( Name, isInternalName )
 import Type            ( Type )
 import NameEnv         ( extendNameEnvList )
@@ -140,7 +140,7 @@ initTc  (HscEnv { hsc_mode   = ghci_mode,
                tcg_ist      = mkImpTypeEnv eps hpt,
                tcg_inst_env = mkImpInstEnv dflags eps hpt,
                tcg_exports  = [],
-               tcg_imports  = emptyImportAvails,
+               tcg_imports  = init_imports,
                tcg_binds    = EmptyMonoBinds,
                tcg_deprecs  = NoDeprecs,
                tcg_insts    = [],
@@ -177,6 +177,13 @@ initTc  (HscEnv { hsc_mode   = ghci_mode,
   where
     eps = pcs_EPS pcs
 
+    init_imports = mkImportAvails (moduleName mod) True []
+       -- Initialise tcg_imports with an empty set of bindings for
+       -- this module, so that if we see 'module M' in the export
+       -- list, and there are no bindings in M, we don't bleat 
+       -- "unknown module M".
+
+
 defaultDefaultTys :: [Type]
 defaultDefaultTys = [integerTy, doubleTy]