import BasicTypes ( Fixity(..), FixityDirection(..), NewOrData(..), IfaceFlavour(..) )
import PrefixToHs
-import CmdLineOpts ( opt_PprUserLength )
+import CmdLineOpts ( opt_PprUserLength, opt_NoImplicitPrelude )
import ErrUtils ( addErrLoc, ghcExit )
import FiniteMap ( elemFM, FiniteMap )
import Name ( OccName(..), SYN_IE(Module) )
import Lex ( isLexConId )
import Outputable ( Outputable(..), PprStyle(..) )
-import PrelMods
+import PrelMods ( pRELUDE )
import Pretty
import SrcLoc ( mkGeneratedSrcLoc, noSrcLoc, SrcLoc )
import Util ( nOfThem, pprError, panic )
else VarOcc occ)
wlkQid :: (FAST_STRING -> OccName) -> U_qid -> UgnM RdrName
+
+-- There are three kinds of qid:
+-- qualified name (aqual) A.x
+-- unqualified name (noqual) x
+-- special name (gid) [], (), ->, (,,,)
+-- The special names always mean "Prelude.whatever"; that's why
+-- they are distinct. So if you write "()", it's just as if you
+-- had written "Prelude.()".
+-- NB: The (qualified) prelude is always in scope, so the renamer will find it.
+
+-- EXCEPT: when we're compiling with -fno-implicit-prelude, in which
+-- case we need to unqualify these things. -- SDM.
+
wlkQid mk_occ_name (U_noqual name)
= returnUgn (Unqual (mk_occ_name name))
wlkQid mk_occ_name (U_aqual mod name)
= returnUgn (Qual mod (mk_occ_name name) HiFile)
-
- -- I don't understand this one! It is what shows up when we meet (), [], or (,,,).
wlkQid mk_occ_name (U_gid n name)
- = returnUgn (Unqual (mk_occ_name name))
+ | opt_NoImplicitPrelude
+ = returnUgn (Unqual (mk_occ_name name))
+ | otherwise
+ = returnUgn (Qual pRELUDE (mk_occ_name name) HiFile)
rdTCId pt = rdU_qid pt `thenUgn` \ qid -> wlkTCId qid
rdVarId pt = rdU_qid pt `thenUgn` \ qid -> wlkVarId qid
#if __GLASGOW_HASKELL__ == 201
ioToUgnM (GHCbase.ioToPrimIO (hPutStr stderr msg)) `thenUgn` \ _ ->
ioToUgnM (GHCbase.ioToPrimIO (ghcExit 1)) `thenUgn` \ _ ->
-#elif __GLASGOW_HASKELL__ >= 202
+#elif __GLASGOW_HASKELL__ >= 202 && __GLASGOW_HASKELL__ < 209
ioToUgnM (IOBase.ioToPrimIO (hPutStr stderr msg)) `thenUgn` \ _ ->
ioToUgnM (IOBase.ioToPrimIO (ghcExit 1)) `thenUgn` \ _ ->
#else