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 )
* *
*********************************************************
-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}
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
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}
*********************************************************
*********************************************************
* *
-\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 ] )
= 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}