[project @ 1996-06-11 13:18:54 by partain]
[ghc-hetmet.git] / ghc / compiler / rename / RnUtils.lhs
index 1825928..7e50792 100644 (file)
@@ -14,18 +14,15 @@ module RnUtils (
 
        lubExportFlag,
 
-       unknownNameErr,
-       badClassOpErr,
        qualNameErr,
-       dupNamesErr,
-       shadowedNameWarn,
-       multipleOccWarn
+       dupNamesErr
     ) where
 
-import Ubiq
+IMP_Ubiq(){-uitous-}
 
 import Bag             ( Bag, emptyBag, snocBag, unionBags )
-import ErrUtils                ( addShortErrLocLine, addShortWarnLocLine, addErrLoc )
+import CmdLineOpts     ( opt_CompilingPrelude )
+import ErrUtils                ( addShortErrLocLine )
 import FiniteMap       ( FiniteMap, emptyFM, isEmptyFM,
                          lookupFM, addListToFM, addToFM )
 import Maybes          ( maybeToBool )
@@ -42,7 +39,7 @@ import Util           ( assertPanic )
 *                                                      *
 *********************************************************
 
-Seperate FiniteMaps are kept for lookup up Qual names,
+Separate FiniteMaps are kept for lookup up Qual names,
 Unqual names and Local names.
 
 \begin{code}
@@ -131,7 +128,10 @@ extendLocalRnEnv report_shadows (global, stack) new_local
 lookupRnEnv ((qual, unqual, _, _), stack) rdr
   = case rdr of 
       Unqual str   -> lookup stack str (lookup unqual str Nothing)
-      Qual mod str -> lookup qual (str,mod) Nothing
+      Qual mod str -> lookup qual (str,mod)
+                       (if not opt_CompilingPrelude -- see below
+                        then Nothing
+                        else lookup unqual str Nothing)
   where
     lookup fm thing do_on_fail
       = case lookupFM fm thing of
@@ -141,12 +141,25 @@ lookupRnEnv ((qual, unqual, _, _), stack) rdr
 lookupGlobalRnEnv ((qual, unqual, _, _), _) rdr
   = case rdr of 
       Unqual str   -> lookupFM unqual str
-      Qual mod str -> lookupFM qual (str,mod)
+      Qual mod str -> case (lookupFM qual (str,mod)) of
+                       Just xx -> Just xx
+                       Nothing -> if not opt_CompilingPrelude then
+                                     Nothing
+                                  else -- "[]" may have turned into "Prelude.[]" and
+                                       -- we are actually compiling "data [] a = ...";
+                                       -- maybe the right thing is to get "Prelude.[]"
+                                       -- into the "qual" table...
+                                     lookupFM unqual str
 
 lookupTcRnEnv ((_, _, tc_qual, tc_unqual), _) rdr
   = case rdr of 
       Unqual str   -> lookupFM tc_unqual str
-      Qual mod str -> lookupFM tc_qual (str,mod)
+      Qual mod str -> case (lookupFM tc_qual (str,mod)) of -- as above
+                       Just xx -> Just xx
+                       Nothing -> if not opt_CompilingPrelude then
+                                     Nothing
+                                  else
+                                     lookupFM tc_unqual str
 \end{code}
 
 *********************************************************
@@ -164,20 +177,11 @@ lubExportFlag ExportAbs ExportAbs = ExportAbs
 
 *********************************************************
 *                                                      *
-\subsection{Errors used in RnMonad}
+\subsection{Errors used *more than once* in the renamer}
 *                                                      *
 *********************************************************
 
 \begin{code}
-unknownNameErr descriptor name locn
-  = addShortErrLocLine locn ( \ sty ->
-    ppBesides [ppStr "undefined ", ppStr descriptor, ppStr ": ", pprNonSym sty name] )
-
-badClassOpErr clas op locn
-  = addErrLoc locn "" ( \ sty ->
-    ppBesides [ppChar '`', pprNonSym sty op, ppStr "' is not an operation of class `",
-             ppr sty clas, ppStr "'"] )
-
 qualNameErr descriptor (name,locn)
   = addShortErrLocLine locn ( \ sty ->
     ppBesides [ppStr "invalid use of qualified ", ppStr descriptor, ppStr ": ", pprNonSym sty name ] )
@@ -194,13 +198,5 @@ dupNamesErr descriptor ((name1,locn1) : dup_things) sty
       = addShortErrLocLine locn (\ sty ->
        ppBesides [ppStr "here was another declaration of `",
                   pprNonSym sty name, ppStr "'" ]) sty
-
-shadowedNameWarn locn shadow
-  = addShortWarnLocLine locn ( \ sty ->
-    ppBesides [ppStr "more than one value with the same name (shadowing): ", ppr sty shadow] )
-
-multipleOccWarn (name, occs) sty
-  = ppBesides [ppStr "warning:multiple names used to refer to `", ppr sty name, ppStr "': ",
-              ppInterleave ppComma (map (ppr sty) occs)]
 \end{code}