Simon Peyton Jones pushed to branch wip/spj-reinstallable-base at Glasgow Haskell Compiler / GHC
Commits:
-
88d760d9
by Simon Peyton Jones at 2026-03-15T00:53:33+00:00
28 changed files:
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Builtin/Utils.hs
- compiler/GHC/Driver/Env/KnotVars.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Env.hs
- − compiler/GHC/Iface/Env.hs-boot
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Tc/Deriv/Generics.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Instance/Typeable.hs
- compiler/GHC/Tc/TyCl/Build.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Types/Name/Cache.hs
- compiler/GHC/Unit/External.hs
- libraries/base/base.cabal.in
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/LanguageExtensions.hs
- libraries/ghc-internal/src/GHC/Internal/Real.hs
Changes:
| ... | ... | @@ -188,8 +188,8 @@ names with uniques. These ones are the *non* wired-in ones. The |
| 188 | 188 | wired in ones are defined in GHC.Builtin.Types etc.
|
| 189 | 189 | -}
|
| 190 | 190 | |
| 191 | -basicKnownKeyOccs :: [(OccName, Unique)]
|
|
| 192 | -basicKnownKeyOccs
|
|
| 191 | +basicKnownKeyTable :: [(OccName, Unique)]
|
|
| 192 | +basicKnownKeyTable
|
|
| 193 | 193 | = [ (mkTcOcc "Rational", rationalTyConKey) ]
|
| 194 | 194 | |
| 195 | 195 | basicKnownKeyNames :: [Name] -- See Note [Known-key names]
|
| ... | ... | @@ -25,8 +25,8 @@ import Language.Haskell.Syntax.Module.Name |
| 25 | 25 | -- 2) Make a "Name"
|
| 26 | 26 | -- 3) Add the name to templateHaskellNames
|
| 27 | 27 | |
| 28 | -templateHaskellOccs :: [(OccName,Unique)]
|
|
| 29 | -templateHaskellOccs = []
|
|
| 28 | +thKnownKeyTable :: [(OccName,Unique)]
|
|
| 29 | +thKnownKeyTable = []
|
|
| 30 | 30 | |
| 31 | 31 | templateHaskellNames :: [Name]
|
| 32 | 32 | -- The names that are implicitly mentioned by ``bracket''
|
| ... | ... | @@ -28,7 +28,7 @@ module GHC.Builtin.Utils ( |
| 28 | 28 | -- if you find yourself wanting to look at it you might consider using
|
| 29 | 29 | -- 'lookupKnownKeyName' or 'isKnownKeyName'.
|
| 30 | 30 | knownKeyNames,
|
| 31 | - KnownKeyOccMap, knownKeyOccMap,
|
|
| 31 | + knownKeyOccMap, knownKeyUniqMap,
|
|
| 32 | 32 | |
| 33 | 33 | -- * Miscellaneous
|
| 34 | 34 | wiredInIds, ghcPrimIds,
|
| ... | ... | @@ -54,7 +54,7 @@ import GHC.Builtin.PrimOps.Ids |
| 54 | 54 | import GHC.Builtin.Types
|
| 55 | 55 | import GHC.Builtin.Types.Literals ( typeNatTyCons )
|
| 56 | 56 | import GHC.Builtin.Types.Prim
|
| 57 | -import GHC.Builtin.Names.TH ( templateHaskellNames, templateHaskellOccs )
|
|
| 57 | +import GHC.Builtin.Names.TH ( templateHaskellNames, thKnownKeyTable )
|
|
| 58 | 58 | import GHC.Builtin.Names
|
| 59 | 59 | |
| 60 | 60 | import GHC.Core.ConLike ( ConLike(..) )
|
| ... | ... | @@ -205,12 +205,13 @@ isKnownKeyName :: Name -> Bool |
| 205 | 205 | isKnownKeyName n =
|
| 206 | 206 | isJust (knownUniqueName $ nameUnique n) || elemUFM n knownKeysMap
|
| 207 | 207 | |
| 208 | -type KnownKeyOccMap = OccEnv Name
|
|
| 209 | - -- See Note [Overview of known-key Names]
|
|
| 210 | - |
|
| 211 | 208 | -- | `knownKeyOccMap` maps the OccName of a known-key to its Unique
|
| 212 | 209 | knownKeyOccMap :: OccEnv Unique
|
| 213 | -knownKeyOccMap = mkOccEnv (basicKnownKeyOccs ++ templateHaskellOccs)
|
|
| 210 | +knownKeyOccMap = mkOccEnv (basicKnownKeyTable ++ thKnownKeyTable)
|
|
| 211 | + |
|
| 212 | +knownKeyUniqMap :: UniqFM Unique OccName
|
|
| 213 | +knownKeyUniqMap = listToUFM [ (uniq, occ)
|
|
| 214 | + | (occ, uniq) <- basicKnownKeyTable ++ thKnownKeyTable ]
|
|
| 214 | 215 | |
| 215 | 216 | -- | Maps 'Unique's to known-key names.
|
| 216 | 217 | --
|
| ... | ... | @@ -16,9 +16,12 @@ import GHC.Utils.Outputable |
| 16 | 16 | |
| 17 | 17 | -- See Note [Why is KnotVars not a ModuleEnv]
|
| 18 | 18 | -- See Note [KnotVars invariants]
|
| 19 | -data KnotVars a = KnotVars { kv_domain :: [Module] -- Domain of the function , Note [KnotVars: Why store the domain?]
|
|
| 20 | - -- Invariant: kv_lookup is surjective relative to kv_domain
|
|
| 19 | +data KnotVars a = KnotVars { kv_domain :: [Module]
|
|
| 20 | + -- Domain of kv_lookup
|
|
| 21 | + -- See Note [KnotVars: Why store the domain?]
|
|
| 22 | + |
|
| 21 | 23 | , kv_lookup :: Module -> Maybe a -- Lookup function
|
| 24 | + -- Invariant: kv_lookup is surjective relative to kv_domain
|
|
| 22 | 25 | }
|
| 23 | 26 | | NoKnotVars
|
| 24 | 27 | deriving Functor
|
| ... | ... | @@ -150,6 +150,7 @@ extensionName = \case |
| 150 | 150 | LangExt.ImplicitParams -> "ImplicitParams"
|
| 151 | 151 | LangExt.ImplicitPrelude -> "ImplicitPrelude"
|
| 152 | 152 | LangExt.ImplicitKnownKeyNames -> "ImplicitKnownKeyNames"
|
| 153 | + LangExt.DefinesKnownKeyNames -> "DefinesKnownKeyNames"
|
|
| 153 | 154 | LangExt.ScopedTypeVariables -> "ScopedTypeVariables"
|
| 154 | 155 | LangExt.AllowAmbiguousTypes -> "AllowAmbiguousTypes"
|
| 155 | 156 | LangExt.UnboxedTuples -> "UnboxedTuples"
|
| ... | ... | @@ -81,6 +81,7 @@ import GHC.Core.Type |
| 81 | 81 | import GHC.Core.Multiplicity
|
| 82 | 82 | |
| 83 | 83 | import GHC.IfaceToCore
|
| 84 | +import GHC.Iface.Load( lookupKnownKeyThing )
|
|
| 84 | 85 | |
| 85 | 86 | import GHC.Tc.Utils.Monad
|
| 86 | 87 | |
| ... | ... | @@ -117,7 +118,11 @@ import GHC.Utils.Error |
| 117 | 118 | import GHC.Utils.Outputable
|
| 118 | 119 | import GHC.Utils.Panic
|
| 119 | 120 | import GHC.Utils.Misc( HasDebugCallStack )
|
| 121 | + |
|
| 122 | +import qualified GHC.LanguageExtensions as LangExt
|
|
| 123 | + |
|
| 120 | 124 | import qualified GHC.Data.Strict as Strict
|
| 125 | +import GHC.Data.Maybe
|
|
| 121 | 126 | import GHC.Data.OrdList
|
| 122 | 127 | |
| 123 | 128 | import Data.IORef
|
| ... | ... | @@ -396,16 +401,22 @@ mkDsEnvs :: UnitEnv -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv |
| 396 | 401 | mkDsEnvs unit_env mod rdr_env type_env fam_inst_env ptc msg_var cc_st_var
|
| 397 | 402 | statics_var next_wrapper_num complete_matches
|
| 398 | 403 | = let if_genv = IfGblEnv { if_doc = text "mkDsEnvs"
|
| 399 | - -- Failing tests here are `ghci` and `T11985` if you get this wrong.
|
|
| 400 | - -- this is very very "at a distance" because the reason for this check is that the type_env in interactive
|
|
| 401 | - -- mode is the smushed together of all the interactive modules.
|
|
| 402 | - -- See Note [Why is KnotVars not a ModuleEnv]
|
|
| 403 | - , if_rec_types = KnotVars [mod] (\that_mod -> if that_mod == mod || isInteractiveModule mod
|
|
| 404 | - then Just (return type_env)
|
|
| 405 | - else Nothing) }
|
|
| 404 | + , if_rec_types = KnotVars [mod] knot_var_fun }
|
|
| 405 | + -- Failing tests here are `ghci` and `T11985` if you get this wrong.
|
|
| 406 | + -- This is very very "at a distance" because the reason for this check
|
|
| 407 | + -- is that the type_env in interactive mode is the smushed together
|
|
| 408 | + -- of all the interactive modules.
|
|
| 409 | + -- See Note [Why is KnotVars not a ModuleEnv]
|
|
| 410 | + |
|
| 411 | + knot_var_fun :: Module -> Maybe (IfG TypeEnv)
|
|
| 412 | + knot_var_fun that_mod
|
|
| 413 | + | that_mod == mod || isInteractiveModule mod = Just (return type_env)
|
|
| 414 | + | otherwise = Nothing
|
|
| 415 | + |
|
| 406 | 416 | if_lenv = mkIfLclEnv mod (text "GHC error in desugarer lookup in" <+> ppr mod)
|
| 407 | 417 | NotBoot
|
| 408 | 418 | real_span = realSrcLocSpan (mkRealSrcLoc (moduleNameFS (moduleName mod)) 1 1)
|
| 419 | + |
|
| 409 | 420 | gbl_env = DsGblEnv { ds_mod = mod
|
| 410 | 421 | , ds_fam_inst_env = fam_inst_env
|
| 411 | 422 | , ds_gbl_rdr_env = rdr_env
|
| ... | ... | @@ -426,7 +437,7 @@ mkDsEnvs unit_env mod rdr_env type_env fam_inst_env ptc msg_var cc_st_var |
| 426 | 437 | |
| 427 | 438 | dsToIfL :: IfL a -> DsM a
|
| 428 | 439 | -- Run an Iface action in the Ds monad
|
| 429 | -dsToIfl iface_action
|
|
| 440 | +dsToIfL iface_action
|
|
| 430 | 441 | = do { env <- getGblEnv
|
| 431 | 442 | ; setEnvs (ds_if_env env) iface_action }
|
| 432 | 443 | |
| ... | ... | @@ -554,28 +565,21 @@ mkNamePprCtxDs = ds_name_ppr_ctx <$> getGblEnv |
| 554 | 565 | instance MonadThings (IOEnv (Env DsGblEnv DsLclEnv)) where
|
| 555 | 566 | lookupThing = dsLookupGlobal
|
| 556 | 567 | |
| 557 | -dsLookupKnownKey :: OccName -> DsM TyThing
|
|
| 558 | -dsLookupKnownKey occ
|
|
| 559 | - = do { normal_path <- xoptM ImplicitKnownKeyNames
|
|
| 560 | - ; if normal_path
|
|
| 561 | - then dsToIfL $
|
|
| 562 | - lookupImportedKnownKey occ
|
|
| 563 | - else
|
|
| 564 | - lookupKnownKeyOcc occ
|
|
| 565 | - }
|
|
| 566 | - |
|
| 567 | -dsLookupKnownKeyOcc :: OccName -> DsM TyThing
|
|
| 568 | --- Look up the known-key OccName in the current top-level GlobalRdrEnv
|
|
| 569 | --- If we get a unique hit, use it; if not, panic.
|
|
| 570 | -dsLookupKnownKeyOcc occ
|
|
| 571 | - = do { gbl_rdr_env <- dsGetGlobalRdrEnv
|
|
| 572 | - ; case lookupGRE gbl_rdr_env (lookupOccName occ SameNameSpace) of
|
|
| 573 | - [name] -> dsLookupGlobal name
|
|
| 574 | - gres -> pprPanic "lookupKnownKeyOcc" (ppr occ $$ ppr gres) }
|
|
| 575 | - |
|
| 576 | -dsLookupKnownKeyTyCon :: Name -> DsM TyCon
|
|
| 577 | -dsLookupKnownKeyTyCon name
|
|
| 578 | - = tyThingTyCon <$> dsLookupKnownKey name
|
|
| 568 | +dsLookupKnownKey :: Unique -> DsM TyThing
|
|
| 569 | +dsLookupKnownKey uniq
|
|
| 570 | + = do { normal_path <- xoptM LangExt.ImplicitKnownKeyNames
|
|
| 571 | + ; mb_rdr_env <- if normal_path
|
|
| 572 | + then return Nothing
|
|
| 573 | + else Just <$> dsGetGlobalRdrEnv
|
|
| 574 | + ; dsToIfL $
|
|
| 575 | + do { mb_res <- lookupKnownKeyThing mb_rdr_env uniq
|
|
| 576 | + ; case mb_res of
|
|
| 577 | + Succeeded thing -> return thing
|
|
| 578 | + Failed msg -> failIfM (pprDiagnostic msg) } }
|
|
| 579 | + |
|
| 580 | +dsLookupKnownKeyTyCon :: Unique -> DsM TyCon
|
|
| 581 | +dsLookupKnownKeyTyCon uniq
|
|
| 582 | + = tyThingTyCon <$> dsLookupKnownKey uniq
|
|
| 579 | 583 | |
| 580 | 584 | dsLookupGlobal :: Name -> DsM TyThing
|
| 581 | 585 | -- Very like GHC.Tc.Utils.Env.tcLookupGlobal
|
| ... | ... | @@ -21,7 +21,7 @@ import GHC.Types.Id |
| 21 | 21 | import GHC.Core.ConLike
|
| 22 | 22 | import GHC.Types.Name
|
| 23 | 23 | import GHC.Builtin.Types
|
| 24 | -import GHC.Builtin.Names (rationalTyConName, toListName)
|
|
| 24 | +import GHC.Builtin.Names (rationalTyConKey, toListName)
|
|
| 25 | 25 | import GHC.Types.SrcLoc
|
| 26 | 26 | import GHC.Utils.Outputable
|
| 27 | 27 | import GHC.Utils.Panic
|
| ... | ... | @@ -253,7 +253,7 @@ desugarPat x pat = case pat of |
| 253 | 253 | , (HsFractional f) <- val
|
| 254 | 254 | , negates <- if fl_neg f then 1 else 0
|
| 255 | 255 | -> do
|
| 256 | - rat_tc <- dsLookupTyCon rationalTyConName
|
|
| 256 | + rat_tc <- dsLookupKnownKeyTyCon rationalTyConKey
|
|
| 257 | 257 | let rat_ty = mkTyConTy rat_tc
|
| 258 | 258 | return $ Just $ PmLit rat_ty (PmLitOverRat negates f)
|
| 259 | 259 | | otherwise
|
| ... | ... | @@ -2351,6 +2351,12 @@ lookupType :: Name -- Name of type constructor (e.g. (M TH.Exp)) |
| 2351 | 2351 | lookupType tc_name = do { tc <- lift $ dsLookupTyCon tc_name ;
|
| 2352 | 2352 | return (mkTyConApp tc []) }
|
| 2353 | 2353 | |
| 2354 | +lookupKnownKeyType :: Unique -- Unique of type constructor (e.g. (M TH.Exp))
|
|
| 2355 | + -> MetaM Type -- The type
|
|
| 2356 | +lookupKnownKeyType tc_key
|
|
| 2357 | + = do { tc <- lift $ dsLookupKnownKeyTyCon tc_key
|
|
| 2358 | + ; return (mkTyConApp tc []) }
|
|
| 2359 | + |
|
| 2354 | 2360 | wrapGenSyms :: [GenSymBind]
|
| 2355 | 2361 | -> Core (M a) -> MetaM (Core (M a))
|
| 2356 | 2362 | -- wrapGenSyms [(nm1,id1), (nm2,id2)] y
|
| ... | ... | @@ -3086,7 +3092,7 @@ mk_integer :: Integer -> MetaM (HsLit GhcTc) |
| 3086 | 3092 | mk_integer i = return $ XLit $ HsInteger NoSourceText i integerTy
|
| 3087 | 3093 | |
| 3088 | 3094 | mk_rational :: FractionalLit -> MetaM (HsLit GhcTc)
|
| 3089 | -mk_rational r = do rat_ty <- lookupType rationalTyConName
|
|
| 3095 | +mk_rational r = do rat_ty <- lookupKnownKeyType rationalTyConKey
|
|
| 3090 | 3096 | return $ XLit $ HsRat r rat_ty
|
| 3091 | 3097 | |
| 3092 | 3098 | mk_string :: FastString -> MetaM (HsLit GhcRn)
|
| ... | ... | @@ -41,7 +41,10 @@ import GHC.Types.Avail |
| 41 | 41 | import GHC.Types.Name.Cache
|
| 42 | 42 | import GHC.Types.Unique.Supply
|
| 43 | 43 | import GHC.Types.SrcLoc
|
| 44 | +import GHC.Types.Unique
|
|
| 44 | 45 | |
| 46 | +import GHC.Utils.Misc( HasDebugCallStack )
|
|
| 47 | +import GHC.Utils.Panic( callStackDoc )
|
|
| 45 | 48 | import GHC.Utils.Outputable
|
| 46 | 49 | import GHC.Utils.Error
|
| 47 | 50 | import GHC.Utils.Logger
|
| ... | ... | @@ -59,20 +62,21 @@ import Control.Monad |
| 59 | 62 | See Also: Note [The Name Cache] in GHC.Types.Name.Cache
|
| 60 | 63 | -}
|
| 61 | 64 | |
| 62 | -newGlobalBinder :: Module -> OccName -> SrcSpan -> TcRnIf a b Name
|
|
| 65 | +newGlobalBinder :: HasDebugCallStack => Module -> OccName -> Maybe Unique
|
|
| 66 | + -> SrcSpan -> TcRnIf a b Name
|
|
| 63 | 67 | -- Used for source code and interface files, to make the
|
| 64 | 68 | -- Name for a thing, given its Module and OccName
|
| 65 | 69 | -- See Note [The Name Cache] in GHC.Types.Name.Cache
|
| 66 | 70 | --
|
| 67 | 71 | -- The cache may already have a binding for this thing,
|
| 68 | --- because we may have seen an occurrence before, but now is the
|
|
| 72 | +-- because we may have seen an /occurrence/ before, but now is the
|
|
| 69 | 73 | -- moment when we know its Module and SrcLoc in their full glory
|
| 70 | 74 | |
| 71 | -newGlobalBinder mod occ loc
|
|
| 75 | +newGlobalBinder mod occ mb_uniq loc
|
|
| 72 | 76 | = do { hsc_env <- getTopEnv
|
| 73 | - ; name <- liftIO $ allocateGlobalBinder (hsc_NC hsc_env) mod occ loc
|
|
| 77 | + ; name <- liftIO $ allocateGlobalBinder (hsc_NC hsc_env) mod occ mb_uniq loc
|
|
| 74 | 78 | ; traceIf (text "newGlobalBinder" <+>
|
| 75 | - (vcat [ ppr mod <+> ppr occ <+> ppr loc, ppr name]))
|
|
| 79 | + vcat [ ppr mod <+> ppr occ <+> ppr loc, ppr name, callStackDoc])
|
|
| 76 | 80 | ; return name }
|
| 77 | 81 | |
| 78 | 82 | newInteractiveBinder :: HscEnv -> OccName -> SrcSpan -> IO Name
|
| ... | ... | @@ -80,14 +84,14 @@ newInteractiveBinder :: HscEnv -> OccName -> SrcSpan -> IO Name |
| 80 | 84 | -- from the interactive context
|
| 81 | 85 | newInteractiveBinder hsc_env occ loc = do
|
| 82 | 86 | let mod = icInteractiveModule (hsc_IC hsc_env)
|
| 83 | - allocateGlobalBinder (hsc_NC hsc_env) mod occ loc
|
|
| 87 | + allocateGlobalBinder (hsc_NC hsc_env) mod occ Nothing loc
|
|
| 84 | 88 | |
| 85 | 89 | allocateGlobalBinder
|
| 86 | 90 | :: NameCache
|
| 87 | - -> Module -> OccName -> SrcSpan
|
|
| 91 | + -> Module -> OccName -> Maybe Unique -> SrcSpan
|
|
| 88 | 92 | -> IO Name
|
| 89 | 93 | -- See Note [The Name Cache] in GHC.Types.Name.Cache
|
| 90 | -allocateGlobalBinder nc mod occ loc
|
|
| 94 | +allocateGlobalBinder nc mod occ mb_uniq loc
|
|
| 91 | 95 | = updateNameCache nc mod occ $ \cache0 -> do
|
| 92 | 96 | case lookupOrigNameCache cache0 mod occ of
|
| 93 | 97 | -- A hit in the cache! We are at the binding site of the name.
|
| ... | ... | @@ -109,17 +113,23 @@ allocateGlobalBinder nc mod occ loc |
| 109 | 113 | Just name | isWiredInName name
|
| 110 | 114 | -> pure (cache0, name)
|
| 111 | 115 | | otherwise
|
| 112 | - -> pure (new_cache, name')
|
|
| 116 | + -> warnPprTrace wrong_unique "allocateGlobalBinder" (ppr mb_uniq $$ ppr name) $
|
|
| 117 | + pure (new_cache, name')
|
|
| 113 | 118 | where
|
| 114 | 119 | uniq = nameUnique name
|
| 115 | 120 | name' = mkExternalName uniq mod occ loc
|
| 116 | 121 | -- name' is like name, but with the right SrcSpan
|
| 117 | 122 | new_cache = extendOrigNameCache cache0 mod occ name'
|
| 123 | + wrong_unique = case mb_uniq of
|
|
| 124 | + Nothing -> False
|
|
| 125 | + Just kn_uniq -> kn_uniq /= uniq
|
|
| 118 | 126 | |
| 119 | 127 | -- Miss in the cache!
|
| 120 | 128 | -- Build a completely new Name, and put it in the cache
|
| 121 | 129 | _ -> do
|
| 122 | - uniq <- takeUniqFromNameCache nc
|
|
| 130 | + uniq <- case mb_uniq of
|
|
| 131 | + Just uniq -> return uniq
|
|
| 132 | + Nothing -> takeUniqFromNameCache nc
|
|
| 123 | 133 | let name = mkExternalName uniq mod occ loc
|
| 124 | 134 | let new_cache = extendOrigNameCache cache0 mod occ name
|
| 125 | 135 | pure (new_cache, name)
|
| ... | ... | @@ -178,7 +188,7 @@ externaliseName mod name |
| 178 | 188 | setNameModule :: Maybe Module -> Name -> TcRnIf m n Name
|
| 179 | 189 | setNameModule Nothing n = return n
|
| 180 | 190 | setNameModule (Just m) n =
|
| 181 | - newGlobalBinder m (nameOccName n) (nameSrcSpan n)
|
|
| 191 | + newGlobalBinder m (nameOccName n) Nothing (nameSrcSpan n)
|
|
| 182 | 192 | |
| 183 | 193 | {-
|
| 184 | 194 | ************************************************************************
|
| 1 | -module GHC.Iface.Env where
|
|
| 2 | - |
|
| 3 | -import GHC.Unit.Module
|
|
| 4 | -import GHC.Types.Name.Occurrence
|
|
| 5 | -import GHC.Tc.Utils.Monad
|
|
| 6 | -import GHC.Types.Name
|
|
| 7 | -import GHC.Types.SrcLoc
|
|
| 8 | - |
|
| 9 | -newGlobalBinder :: Module -> OccName -> SrcSpan -> TcRnIf a b Name |
| ... | ... | @@ -9,13 +9,14 @@ |
| 9 | 9 | |
| 10 | 10 | {-# OPTIONS_GHC -fno-warn-orphans #-}
|
| 11 | 11 | {-# LANGUAGE ViewPatterns #-}
|
| 12 | +{-# LANGUAGE ScopedTypeVariables #-}
|
|
| 12 | 13 | |
| 13 | 14 | -- | Loading interface files
|
| 14 | 15 | module GHC.Iface.Load (
|
| 15 | 16 | -- Importing one thing
|
| 16 | - tcLookupImported_maybe, importDecl,
|
|
| 17 | + importDecl,
|
|
| 17 | 18 | checkWiredInTyCon, ifCheckWiredInThing,
|
| 18 | - lookupImportedKnownKey,
|
|
| 19 | + lookupKnownKeyThing, loadGlobalName,
|
|
| 19 | 20 | |
| 20 | 21 | -- RnM/TcM functions
|
| 21 | 22 | loadModuleInterface, loadModuleInterfaces,
|
| ... | ... | @@ -71,6 +72,7 @@ import GHC.Utils.Outputable as Outputable |
| 71 | 72 | import GHC.Utils.Panic
|
| 72 | 73 | import GHC.Utils.Constants (debugIsOn)
|
| 73 | 74 | import GHC.Utils.Logger
|
| 75 | +import GHC.Utils.Misc( HasDebugCallStack )
|
|
| 74 | 76 | |
| 75 | 77 | import GHC.Settings.Constants
|
| 76 | 78 | |
| ... | ... | @@ -86,6 +88,7 @@ import GHC.Types.Annotations |
| 86 | 88 | import GHC.Types.Name
|
| 87 | 89 | import GHC.Types.Name.Cache
|
| 88 | 90 | import GHC.Types.Name.Env
|
| 91 | +import GHC.Types.Name.Reader
|
|
| 89 | 92 | import GHC.Types.Avail
|
| 90 | 93 | import GHC.Types.Fixity
|
| 91 | 94 | import GHC.Types.Fixity.Env
|
| ... | ... | @@ -94,6 +97,7 @@ import GHC.Types.SourceFile |
| 94 | 97 | import GHC.Types.SafeHaskell
|
| 95 | 98 | import GHC.Types.TypeEnv
|
| 96 | 99 | import GHC.Types.Unique.DSet
|
| 100 | +import GHC.Types.Unique.FM( listToUFM, lookupUFM )
|
|
| 97 | 101 | import GHC.Types.SrcLoc
|
| 98 | 102 | import GHC.Types.TyThing
|
| 99 | 103 | import GHC.Types.PkgQual
|
| ... | ... | @@ -122,10 +126,158 @@ import Data.Function ((&)) |
| 122 | 126 | import GHC.Unit.Module.Graph
|
| 123 | 127 | import qualified GHC.Unit.Home.Graph as HUG
|
| 124 | 128 | |
| 129 | + |
|
| 130 | +{- *********************************************************************
|
|
| 131 | +* *
|
|
| 132 | +* Known-key things *
|
|
| 133 | +* *
|
|
| 134 | +********************************************************************* -}
|
|
| 135 | + |
|
| 136 | +lookupKnownKeyThing :: HasDebugCallStack
|
|
| 137 | + => Maybe GlobalRdrEnv -> Unique
|
|
| 138 | + -> IfM lcl (MaybeErr IfaceMessage TyThing)
|
|
| 139 | +lookupKnownKeyThing Nothing uniq
|
|
| 140 | + = do { known_key_name_map <- loadKnownKeyOccMap
|
|
| 141 | + ; let name = lookupUFM known_key_name_map uniq
|
|
| 142 | + `orElse` pprPanic "lookupKnownKeyThing" (ppr uniq)
|
|
| 143 | + ; lookupGlobalName name }
|
|
| 144 | + |
|
| 145 | +lookupKnownKeyThing (Just gbl_rdr_env) uniq
|
|
| 146 | + -- Look up the known-key OccName in the current top-level GlobalRdrEnv
|
|
| 147 | + -- If we get a unique hit, use it; if not, panic.
|
|
| 148 | + = case lookupGRE gbl_rdr_env (LookupOccName occ SameNameSpace) of
|
|
| 149 | + [gre] -> lookupGlobalName (greName gre)
|
|
| 150 | + gres -> pprPanic "lookupKnownKeyOcc" (ppr occ $$ ppr gres)
|
|
| 151 | + where
|
|
| 152 | + occ = lookupUFM knownKeyUniqMap uniq
|
|
| 153 | + `orElse` pprPanic "lookupKnownKeyThing" (ppr uniq)
|
|
| 154 | + |
|
| 155 | +loadKnownKeyOccMap :: IfM lcl KnownKeyNameMap
|
|
| 156 | +loadKnownKeyOccMap
|
|
| 157 | + = do { eps <- getEps
|
|
| 158 | + ; case eps_known_keys eps of {
|
|
| 159 | + Just occ_map -> return occ_map ;
|
|
| 160 | + Nothing ->
|
|
| 161 | + |
|
| 162 | + -- We don't have a KnownKeyOccMap yet, so create it
|
|
| 163 | + -- from the interface file for KnownKeyName
|
|
| 164 | + do { hsc_env <- getTopEnv
|
|
| 165 | + ; mb_res <- liftIO $ findImportedModule hsc_env kNOWN_KEY_NAMES NoPkgQual
|
|
| 166 | + ; iface <- case mb_res of
|
|
| 167 | + Found _ mod -> loadInterfaceWithException doc mod ImportBySystem
|
|
| 168 | + _ -> panic "loadKnownKeyOccMap" -- ToDo tidy up
|
|
| 169 | + |
|
| 170 | + ; let occ_map :: KnownKeyNameMap
|
|
| 171 | + occ_map = listToUFM [ (getUnique nm, nm)
|
|
| 172 | + | avail <- mi_exports iface
|
|
| 173 | + , nm <- availNames avail ]
|
|
| 174 | + |
|
| 175 | + -- Record the KnownKeyOccMap in the EPS, so we will find it next time
|
|
| 176 | + ; updateEps_ (\eps -> eps { eps_known_keys = Just occ_map })
|
|
| 177 | + |
|
| 178 | + ; return occ_map } } }
|
|
| 179 | + where
|
|
| 180 | + doc = text "Need interface for KnonwKeyNames"
|
|
| 181 | + |
|
| 182 | + |
|
| 183 | +{- *********************************************************************
|
|
| 184 | +* *
|
|
| 185 | +* Global things
|
|
| 186 | +* *
|
|
| 187 | +********************************************************************* -}
|
|
| 188 | + |
|
| 189 | +lookupGlobalName :: Name -> IfM lcl (MaybeErr IfaceMessage TyThing)
|
|
| 190 | +-- Only works for External Names that have a Module
|
|
| 191 | +lookupGlobalName name = loadGlobalName name (nameModule name)
|
|
| 192 | + |
|
| 193 | +loadGlobalName :: forall lcl.
|
|
| 194 | + Name
|
|
| 195 | + -> Module -- Use this for non-External Names (maybe Backpack-related?)
|
|
| 196 | + -> IfM lcl (MaybeErr IfaceMessage TyThing)
|
|
| 197 | +loadGlobalName name mod
|
|
| 198 | + = do { env <- getGblEnv
|
|
| 199 | + ; case lookupKnotVars (if_rec_types env) mod of
|
|
| 200 | + -- Note [Tying the knot]
|
|
| 201 | + Just get_type_env
|
|
| 202 | + -> do -- It's defined in a module in the hs-boot loop
|
|
| 203 | + { type_env <- setLclEnv () get_type_env -- yuk
|
|
| 204 | + ; case lookupNameEnv type_env name of
|
|
| 205 | + Just thing -> return (Succeeded thing)
|
|
| 206 | + -- See Note [Knot-tying fallback on boot]
|
|
| 207 | + Nothing -> via_external
|
|
| 208 | + }
|
|
| 209 | + |
|
| 210 | + _ -> via_external }
|
|
| 211 | + where
|
|
| 212 | + via_external = do { hsc_env <- getTopEnv
|
|
| 213 | + ; mb_thing <- liftIO (lookupType hsc_env name)
|
|
| 214 | + ; case mb_thing of
|
|
| 215 | + Just thing -> return (Succeeded thing)
|
|
| 216 | + Nothing -> importDecl name }
|
|
| 217 | + |
|
| 218 | +-- Note [Tying the knot]
|
|
| 219 | +-- ~~~~~~~~~~~~~~~~~~~~~
|
|
| 220 | +-- The if_rec_types field is used when we are compiling M.hs, which indirectly
|
|
| 221 | +-- imports Foo.hi, which mentions M.T Then we look up M.T in M's type
|
|
| 222 | +-- environment, which is splatted into if_rec_types after we've built M's type
|
|
| 223 | +-- envt.
|
|
| 224 | +--
|
|
| 225 | +-- This is a dark and complicated part of GHC type checking, with a lot
|
|
| 226 | +-- of moving parts. Interested readers should also look at:
|
|
| 227 | +--
|
|
| 228 | +-- * Note [Knot-tying typecheckIface]
|
|
| 229 | +-- * Note [DFun knot-tying]
|
|
| 230 | +-- * Note [hsc_type_env_var hack]
|
|
| 231 | +-- * Note [Knot-tying fallback on boot]
|
|
| 232 | +-- * Note [Hydrating Modules]
|
|
| 233 | +--
|
|
| 234 | +-- There is also a wiki page on the subject, see:
|
|
| 235 | +--
|
|
| 236 | +-- https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/tying-the-knot
|
|
| 237 | + |
|
| 238 | +-- Note [Knot-tying fallback on boot]
|
|
| 239 | +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 240 | +-- Suppose that you are typechecking A.hs, which transitively imports,
|
|
| 241 | +-- via B.hs, A.hs-boot. When we poke on B.hs and discover that it
|
|
| 242 | +-- has a reference to a type T from A, what TyThing should we wire
|
|
| 243 | +-- it up with? Clearly, if we have already typechecked T and
|
|
| 244 | +-- added it into the type environment, we should go ahead and use that
|
|
| 245 | +-- type. But what if we haven't typechecked it yet?
|
|
| 246 | +--
|
|
| 247 | +-- For the longest time, GHC adopted the policy that this was
|
|
| 248 | +-- *an error condition*; that you MUST NEVER poke on B.hs's reference
|
|
| 249 | +-- to a T defined in A.hs until A.hs has gotten around to kind-checking
|
|
| 250 | +-- T and adding it to the env. However, actually ensuring this is the
|
|
| 251 | +-- case has proven to be a bug farm, because it's really difficult to
|
|
| 252 | +-- actually ensure this never happens. The problem was especially poignant
|
|
| 253 | +-- with type family consistency checks, which eagerly happen before any
|
|
| 254 | +-- typechecking takes place.
|
|
| 255 | +--
|
|
| 256 | +-- Today, we take a different strategy: if we ever try to access
|
|
| 257 | +-- an entity from A which doesn't exist, we just fall back on the
|
|
| 258 | +-- definition of A from the hs-boot file. This is complicated in
|
|
| 259 | +-- its own way: it means that you may end up with a mix of A.hs and
|
|
| 260 | +-- A.hs-boot TyThings during the course of typechecking. We don't
|
|
| 261 | +-- think (and have not observed) any cases where this would cause
|
|
| 262 | +-- problems, but the hypothetical situation one might worry about
|
|
| 263 | +-- is something along these lines in Core:
|
|
| 264 | +--
|
|
| 265 | +-- case x of
|
|
| 266 | +-- A -> e1
|
|
| 267 | +-- B -> e2
|
|
| 268 | +--
|
|
| 269 | +-- If, when typechecking this, we find x :: T, and the T we are hooked
|
|
| 270 | +-- up with is the abstract one from the hs-boot file, rather than the
|
|
| 271 | +-- one defined in this module with constructors A and B. But it's hard
|
|
| 272 | +-- to see how this could happen, especially because the reference to
|
|
| 273 | +-- the constructor (A and B) means that GHC will always typecheck
|
|
| 274 | +-- this expression *after* typechecking T.
|
|
| 275 | + |
|
| 276 | + |
|
| 125 | 277 | {-
|
| 126 | 278 | ************************************************************************
|
| 127 | 279 | * *
|
| 128 | -* tcImportDecl is the key function for "faulting in" *
|
|
| 280 | +* importDecl is the key function for "faulting in" *
|
|
| 129 | 281 | * imported things
|
| 130 | 282 | * *
|
| 131 | 283 | ************************************************************************
|
| ... | ... | @@ -148,61 +300,8 @@ where the code that e1 expands to might import some defns that |
| 148 | 300 | also turn out to be needed by the code that e2 expands to.
|
| 149 | 301 | -}
|
| 150 | 302 | |
| 151 | -tcLookupImported_maybe :: Name -> TcM (MaybeErr IfaceMessage TyThing)
|
|
| 152 | --- Returns (Failed err) if we can't find the interface file for the thing
|
|
| 153 | -tcLookupImported_maybe name
|
|
| 154 | - = do { hsc_env <- getTopEnv
|
|
| 155 | - ; mb_thing <- liftIO (lookupType hsc_env name)
|
|
| 156 | - ; case mb_thing of
|
|
| 157 | - Just thing -> return (Succeeded thing)
|
|
| 158 | - Nothing -> tcImportDecl_maybe name }
|
|
| 159 | - |
|
| 160 | -tcImportDecl_maybe :: Name -> TcM (MaybeErr IfaceMessage TyThing)
|
|
| 161 | --- Entry point for *source-code* uses of importDecl
|
|
| 162 | -tcImportDecl_maybe name
|
|
| 163 | - | Just thing <- wiredInNameTyThing_maybe name
|
|
| 164 | - = do { when (needWiredInHomeIface thing)
|
|
| 165 | - (initIfaceTcRn (loadWiredInHomeIface name))
|
|
| 166 | - -- See Note [Loading instances for wired-in things]
|
|
| 167 | - ; return (Succeeded thing) }
|
|
| 168 | - | otherwise
|
|
| 169 | - = initIfaceTcRn (importDecl name)
|
|
| 170 | - |
|
| 171 | -lookupImportedKnownKey :: OccName -> IfM lcl (MaybeErr IfaceMessage TyThing)
|
|
| 172 | -lookupImportedKnownKey occ
|
|
| 173 | - = do { known_key_occ_map <- loadKnownKeyOccMap
|
|
| 174 | - ; let name = lookupOccEnv known_key_occ_map occ
|
|
| 175 | - `orElse` pprPanic "lookupImportedKnownKey" (ppr occ)
|
|
| 176 | - ; importDecl name }
|
|
| 177 | - |
|
| 178 | -loadKnownKeyOccMap :: IfM lcl KnownKeyOccMap
|
|
| 179 | -loadKnownKeyOccMap
|
|
| 180 | - = do { eps <- getEps
|
|
| 181 | - ; case eps_known_keys eps of {
|
|
| 182 | - Just occ_map -> return occ_map ;
|
|
| 183 | - Nothing ->
|
|
| 184 | - |
|
| 185 | - -- We don't have a KnownKeyOccMap yet, so created it
|
|
| 186 | - -- from the interface file for KnownKeyName
|
|
| 187 | - do { hsc_env <- getTopEnv
|
|
| 188 | - ; mb_res <- liftIO $ findImportedModule hsc_env kNOWN_KEY_NAMES NoPkgQual
|
|
| 189 | - ; iface <- case mb_res of
|
|
| 190 | - Found _ mod -> loadInterfaceWithException doc mod ImportBySystem
|
|
| 191 | - _ -> panic "loadKnownKeyOccMap" -- ToDo tidy up
|
|
| 192 | - |
|
| 193 | - ; let occ_map :: KnownKeyOccMap
|
|
| 194 | - occ_map = mkOccEnv [ (getOccName nm, nm)
|
|
| 195 | - | avail <- mi_exports iface
|
|
| 196 | - , nm <- availNames avail ]
|
|
| 197 | - |
|
| 198 | - -- Record the KnownKeyOccMap in the EPS, so we will find it next time
|
|
| 199 | - ; updateEps_ (\eps -> eps { eps_known_keys = Just occ_map })
|
|
| 200 | - |
|
| 201 | - ; return occ_map } } }
|
|
| 202 | - where
|
|
| 203 | - doc = text "Need interface for KnonwKeyNames"
|
|
| 204 | 303 | |
| 205 | -importDecl :: Name -> IfM lcl (MaybeErr IfaceMessage TyThing)
|
|
| 304 | +importDecl :: HasDebugCallStack => Name -> IfM lcl (MaybeErr IfaceMessage TyThing)
|
|
| 206 | 305 | -- Get the TyThing for this Name from an interface file
|
| 207 | 306 | -- It's not a wired-in thing -- the caller caught that
|
| 208 | 307 | importDecl name
|
| ... | ... | @@ -222,7 +321,8 @@ importDecl name |
| 222 | 321 | { eps <- getEps
|
| 223 | 322 | ; case lookupTypeEnv (eps_PTE eps) name of
|
| 224 | 323 | Just thing -> return $ Succeeded thing
|
| 225 | - Nothing -> return $ Failed $
|
|
| 324 | + Nothing -> pprTrace "importDecl" (ppr name $$ callStackDoc) $
|
|
| 325 | + return $ Failed $
|
|
| 226 | 326 | Can'tFindNameInInterface name
|
| 227 | 327 | (filter is_interesting $ nonDetNameEnvElts $ eps_PTE eps)
|
| 228 | 328 | }}}
|
| ... | ... | @@ -1107,7 +1107,7 @@ tidyTopName mod name_cache maybe_ref occ_env id |
| 1107 | 1107 | -- This is necessary because the byte-code generator the byte-code
|
| 1108 | 1108 | -- generator builds a system-wide Name->BCO symbol table.
|
| 1109 | 1109 | |
| 1110 | - | local && external = do new_external_name <- allocateGlobalBinder name_cache mod occ' loc
|
|
| 1110 | + | local && external = do new_external_name <- allocateGlobalBinder name_cache mod occ' Nothing loc
|
|
| 1111 | 1111 | return (occ_env', new_external_name)
|
| 1112 | 1112 | -- If we want to externalise a currently-local name, check
|
| 1113 | 1113 | -- whether we have already assigned a unique for it.
|
| ... | ... | @@ -12,7 +12,6 @@ Type checking of type signatures in interface files |
| 12 | 12 | {-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
|
| 13 | 13 | |
| 14 | 14 | module GHC.IfaceToCore (
|
| 15 | - tcLookupImported_maybe,
|
|
| 16 | 15 | importDecl, checkWiredInTyCon, tcHiBootIface, typecheckIface,
|
| 17 | 16 | typecheckWholeCoreBindings,
|
| 18 | 17 | tcIfaceDefaults,
|
| ... | ... | @@ -33,7 +32,6 @@ import GHC.Prelude |
| 33 | 32 | |
| 34 | 33 | import GHC.ByteCode.Types
|
| 35 | 34 | |
| 36 | -import GHC.Driver.Env
|
|
| 37 | 35 | import GHC.Driver.Session
|
| 38 | 36 | import GHC.Driver.Config.Core.Lint ( initLintConfig )
|
| 39 | 37 | |
| ... | ... | @@ -2046,91 +2044,13 @@ tcIfaceGlobal name |
| 2046 | 2044 | = do { ifCheckWiredInThing thing; return thing }
|
| 2047 | 2045 | |
| 2048 | 2046 | | otherwise
|
| 2049 | - = do { env <- getGblEnv
|
|
| 2050 | - ; cur_mod <- if_mod <$> getLclEnv
|
|
| 2051 | - ; case lookupKnotVars (if_rec_types env) (fromMaybe cur_mod (nameModule_maybe name)) of
|
|
| 2052 | - -- Note [Tying the knot]
|
|
| 2053 | - Just get_type_env
|
|
| 2054 | - -> do -- It's defined in a module in the hs-boot loop
|
|
| 2055 | - { type_env <- setLclEnv () get_type_env -- yuk
|
|
| 2056 | - ; case lookupNameEnv type_env name of
|
|
| 2057 | - Just thing -> return thing
|
|
| 2058 | - -- See Note [Knot-tying fallback on boot]
|
|
| 2059 | - Nothing -> via_external
|
|
| 2060 | - }
|
|
| 2061 | - |
|
| 2062 | - _ -> via_external }
|
|
| 2063 | - where
|
|
| 2064 | - via_external = do
|
|
| 2065 | - { hsc_env <- getTopEnv
|
|
| 2066 | - ; mb_thing <- liftIO (lookupType hsc_env name)
|
|
| 2067 | - ; case mb_thing of {
|
|
| 2068 | - Just thing -> return thing ;
|
|
| 2069 | - Nothing -> do
|
|
| 2070 | - |
|
| 2071 | - { mb_thing <- importDecl name -- It's imported; go get it
|
|
| 2072 | - ; case mb_thing of
|
|
| 2047 | + = do { mod <- case nameModule_maybe name of
|
|
| 2048 | + Just mod -> return mod
|
|
| 2049 | + Nothing -> if_mod <$> getLclEnv
|
|
| 2050 | + ; mb_thing <- loadGlobalName name mod
|
|
| 2051 | + ; case mb_thing of
|
|
| 2073 | 2052 | Failed err -> failIfM (ppr name <+> pprDiagnostic err)
|
| 2074 | - Succeeded thing -> return thing
|
|
| 2075 | - }}}
|
|
| 2076 | - |
|
| 2077 | --- Note [Tying the knot]
|
|
| 2078 | --- ~~~~~~~~~~~~~~~~~~~~~
|
|
| 2079 | --- The if_rec_types field is used when we are compiling M.hs, which indirectly
|
|
| 2080 | --- imports Foo.hi, which mentions M.T Then we look up M.T in M's type
|
|
| 2081 | --- environment, which is splatted into if_rec_types after we've built M's type
|
|
| 2082 | --- envt.
|
|
| 2083 | ---
|
|
| 2084 | --- This is a dark and complicated part of GHC type checking, with a lot
|
|
| 2085 | --- of moving parts. Interested readers should also look at:
|
|
| 2086 | ---
|
|
| 2087 | --- * Note [Knot-tying typecheckIface]
|
|
| 2088 | --- * Note [DFun knot-tying]
|
|
| 2089 | --- * Note [hsc_type_env_var hack]
|
|
| 2090 | --- * Note [Knot-tying fallback on boot]
|
|
| 2091 | --- * Note [Hydrating Modules]
|
|
| 2092 | ---
|
|
| 2093 | --- There is also a wiki page on the subject, see:
|
|
| 2094 | ---
|
|
| 2095 | --- https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/tying-the-knot
|
|
| 2096 | - |
|
| 2097 | --- Note [Knot-tying fallback on boot]
|
|
| 2098 | --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 2099 | --- Suppose that you are typechecking A.hs, which transitively imports,
|
|
| 2100 | --- via B.hs, A.hs-boot. When we poke on B.hs and discover that it
|
|
| 2101 | --- has a reference to a type T from A, what TyThing should we wire
|
|
| 2102 | --- it up with? Clearly, if we have already typechecked T and
|
|
| 2103 | --- added it into the type environment, we should go ahead and use that
|
|
| 2104 | --- type. But what if we haven't typechecked it yet?
|
|
| 2105 | ---
|
|
| 2106 | --- For the longest time, GHC adopted the policy that this was
|
|
| 2107 | --- *an error condition*; that you MUST NEVER poke on B.hs's reference
|
|
| 2108 | --- to a T defined in A.hs until A.hs has gotten around to kind-checking
|
|
| 2109 | --- T and adding it to the env. However, actually ensuring this is the
|
|
| 2110 | --- case has proven to be a bug farm, because it's really difficult to
|
|
| 2111 | --- actually ensure this never happens. The problem was especially poignant
|
|
| 2112 | --- with type family consistency checks, which eagerly happen before any
|
|
| 2113 | --- typechecking takes place.
|
|
| 2114 | ---
|
|
| 2115 | --- Today, we take a different strategy: if we ever try to access
|
|
| 2116 | --- an entity from A which doesn't exist, we just fall back on the
|
|
| 2117 | --- definition of A from the hs-boot file. This is complicated in
|
|
| 2118 | --- its own way: it means that you may end up with a mix of A.hs and
|
|
| 2119 | --- A.hs-boot TyThings during the course of typechecking. We don't
|
|
| 2120 | --- think (and have not observed) any cases where this would cause
|
|
| 2121 | --- problems, but the hypothetical situation one might worry about
|
|
| 2122 | --- is something along these lines in Core:
|
|
| 2123 | ---
|
|
| 2124 | --- case x of
|
|
| 2125 | --- A -> e1
|
|
| 2126 | --- B -> e2
|
|
| 2127 | ---
|
|
| 2128 | --- If, when typechecking this, we find x :: T, and the T we are hooked
|
|
| 2129 | --- up with is the abstract one from the hs-boot file, rather than the
|
|
| 2130 | --- one defined in this module with constructors A and B. But it's hard
|
|
| 2131 | --- to see how this could happen, especially because the reference to
|
|
| 2132 | --- the constructor (A and B) means that GHC will always typecheck
|
|
| 2133 | --- this expression *after* typechecking T.
|
|
| 2053 | + Succeeded thing -> return thing }
|
|
| 2134 | 2054 | |
| 2135 | 2055 | tcIfaceTyCon :: IfaceTyCon -> IfL TyCon
|
| 2136 | 2056 | tcIfaceTyCon (IfaceTyCon name _info)
|
| ... | ... | @@ -68,7 +68,11 @@ import GHC.Tc.Utils.Env |
| 68 | 68 | import GHC.Tc.Types.LclEnv
|
| 69 | 69 | import GHC.Tc.Utils.Monad
|
| 70 | 70 | import GHC.Parser.PostProcess ( setRdrNameSpace )
|
| 71 | + |
|
| 71 | 72 | import GHC.Builtin.Types
|
| 73 | +import GHC.Builtin.Utils( knownKeyOccMap )
|
|
| 74 | +import GHC.Builtin.Names( rOOT_MAIN )
|
|
| 75 | + |
|
| 72 | 76 | import GHC.Types.Name
|
| 73 | 77 | import GHC.Types.Name.Set
|
| 74 | 78 | import GHC.Types.Name.Env
|
| ... | ... | @@ -79,11 +83,11 @@ import GHC.Unit.Module.ModIface |
| 79 | 83 | import GHC.Core.ConLike
|
| 80 | 84 | import GHC.Core.DataCon
|
| 81 | 85 | import GHC.Core.TyCon
|
| 82 | -import GHC.Builtin.Names( rOOT_MAIN )
|
|
| 83 | 86 | import GHC.Types.Basic ( TupleSort(..), tupleSortBoxity )
|
| 84 | 87 | import GHC.Types.TyThing ( tyThingGREInfo )
|
| 85 | 88 | import GHC.Types.SrcLoc as SrcLoc
|
| 86 | 89 | import GHC.Utils.Outputable as Outputable
|
| 90 | +import GHC.Types.Unique
|
|
| 87 | 91 | import GHC.Types.Unique.FM
|
| 88 | 92 | import GHC.Types.Unique.DSet
|
| 89 | 93 | import GHC.Types.Unique.Set
|
| ... | ... | @@ -224,11 +228,11 @@ newTopSrcBinder (L loc rdr_name) |
| 224 | 228 | -- the RdrName, not from the environment. In principle, it'd be fine to
|
| 225 | 229 | -- have an arbitrary mixture of external core definitions in a single module,
|
| 226 | 230 | -- (apart from module-initialisation issues, perhaps).
|
| 227 | - ; newGlobalBinder rdr_mod rdr_occ (locA loc) }
|
|
| 231 | + ; newGlobalBinder rdr_mod rdr_occ Nothing (locA loc) }
|
|
| 228 | 232 | |
| 229 | 233 | | otherwise
|
| 230 | - = do { when (isQual rdr_name)
|
|
| 231 | - (addErrAt (locA loc) (badQualBndrErr rdr_name))
|
|
| 234 | + = do { when (isQual rdr_name) $
|
|
| 235 | + addErrAt (locA loc) (badQualBndrErr rdr_name)
|
|
| 232 | 236 | -- Binders should not be qualified; if they are, and with a different
|
| 233 | 237 | -- module name, we get a confusing "M.T is not in scope" error later
|
| 234 | 238 | |
| ... | ... | @@ -239,11 +243,30 @@ newTopSrcBinder (L loc rdr_name) |
| 239 | 243 | do { uniq <- newUnique
|
| 240 | 244 | ; return (mkInternalName uniq (rdrNameOcc rdr_name) (locA loc)) }
|
| 241 | 245 | else
|
| 242 | - do { this_mod <- getModule
|
|
| 243 | - ; traceRn "newTopSrcBinder" (ppr this_mod $$ ppr rdr_name $$ ppr (locA loc))
|
|
| 244 | - ; newGlobalBinder this_mod (rdrNameOcc rdr_name) (locA loc) }
|
|
| 246 | + -- Finally we get the "normal path"; an ordinary, top-level binding
|
|
| 247 | + newTopVanillaSrcBinder (rdrNameOcc rdr_name) (locA loc)
|
|
| 245 | 248 | }
|
| 246 | 249 | |
| 250 | +newTopVanillaSrcBinder :: OccName -> SrcSpan -> RnM Name
|
|
| 251 | +newTopVanillaSrcBinder occ loc
|
|
| 252 | + = do { this_mod <- getModule
|
|
| 253 | + |
|
| 254 | + -- See if this bindings is for a known-key name, and if so get its Unique
|
|
| 255 | + ; defines_known_keys <- xoptM LangExt.DefinesKnownKeyNames
|
|
| 256 | + ; let mb_uniq :: Maybe Unique
|
|
| 257 | + mb_uniq | defines_known_keys = lookupOccEnv knownKeyOccMap occ
|
|
| 258 | + | otherwise = Nothing
|
|
| 259 | + |
|
| 260 | + ; name <- newGlobalBinder this_mod occ mb_uniq loc
|
|
| 261 | + ; traceRn "newTopSrcBinder" $
|
|
| 262 | + vcat [ text "module:" <+> ppr this_mod
|
|
| 263 | + , text "occ:" <+> ppr occ
|
|
| 264 | + , text "mb_uniq:" <+> ppr mb_uniq
|
|
| 265 | + , text "loc:" <+> ppr loc
|
|
| 266 | + , text "name:" <+> ppr name ]
|
|
| 267 | + ; return name
|
|
| 268 | + }
|
|
| 269 | + |
|
| 247 | 270 | {-
|
| 248 | 271 | *********************************************************
|
| 249 | 272 | * *
|
| ... | ... | @@ -445,7 +445,7 @@ gen_Generic_fam_inst gk get_fixity loc |
| 445 | 445 | ; mod <- getModule
|
| 446 | 446 | ; let tc_occ = nameOccName (tyConName tycon)
|
| 447 | 447 | rep_occ = case gk of Gen0 -> mkGenR tc_occ; Gen1 -> mkGen1R tc_occ
|
| 448 | - ; rep_name <- newGlobalBinder mod rep_occ loc
|
|
| 448 | + ; rep_name <- newGlobalBinder mod rep_occ Nothing loc
|
|
| 449 | 449 | |
| 450 | 450 | ; let tcv = tyCoVarsOfTypeList inst_ty
|
| 451 | 451 | (tv, cv) = partition isTyVar tcv
|
| ... | ... | @@ -76,7 +76,6 @@ import GHC.ThToHs |
| 76 | 76 | import GHC.HsToCore.Docs
|
| 77 | 77 | import GHC.HsToCore.Expr
|
| 78 | 78 | import GHC.HsToCore.Monad
|
| 79 | -import GHC.IfaceToCore
|
|
| 80 | 79 | import GHC.Iface.Load
|
| 81 | 80 | |
| 82 | 81 | import GHCi.Message
|
| ... | ... | @@ -188,7 +188,7 @@ mkModIdBindings :: TcM TcGblEnv |
| 188 | 188 | mkModIdBindings
|
| 189 | 189 | = do { mod <- getModule
|
| 190 | 190 | ; loc <- getSrcSpanM
|
| 191 | - ; mod_nm <- newGlobalBinder mod (mkVarOccFS (fsLit "$trModule")) loc
|
|
| 191 | + ; mod_nm <- newGlobalBinder mod (mkVarOccFS (fsLit "$trModule")) Nothing loc
|
|
| 192 | 192 | ; trModuleTyCon <- tcLookupTyCon trModuleTyConName
|
| 193 | 193 | ; let mod_id = mkExportedVanillaId mod_nm (mkTyConApp trModuleTyCon [])
|
| 194 | 194 | ; mod_bind <- mkVarBind mod_id <$> mkModIdRHS mod
|
| ... | ... | @@ -429,7 +429,7 @@ newImplicitBinderLoc :: Name -- Base name |
| 429 | 429 | -- Just the same, but lets you specify the SrcSpan
|
| 430 | 430 | newImplicitBinderLoc base_name mk_sys_occ loc
|
| 431 | 431 | | Just mod <- nameModule_maybe base_name
|
| 432 | - = newGlobalBinder mod occ loc
|
|
| 432 | + = newGlobalBinder mod occ Nothing loc
|
|
| 433 | 433 | | otherwise -- When typechecking a [d| decl bracket |],
|
| 434 | 434 | -- TH generates types, classes etc with Internal names,
|
| 435 | 435 | -- so we follow suit for the implicit binders
|
| ... | ... | @@ -443,6 +443,6 @@ newTyConRepName :: Name -> TcRnIf gbl lcl TyConRepName |
| 443 | 443 | newTyConRepName tc_name
|
| 444 | 444 | | Just mod <- nameModule_maybe tc_name
|
| 445 | 445 | , (mod, occ) <- tyConRepModOcc mod (nameOccName tc_name)
|
| 446 | - = newGlobalBinder mod occ noSrcSpan
|
|
| 446 | + = newGlobalBinder mod occ Nothing noSrcSpan
|
|
| 447 | 447 | | otherwise
|
| 448 | 448 | = newImplicitBinder tc_name mkTyConRepOcc |
| ... | ... | @@ -355,10 +355,9 @@ data IfGblEnv |
| 355 | 355 | -- We need the module name so we can test when it's appropriate
|
| 356 | 356 | -- to look in this env.
|
| 357 | 357 | -- See Note [Tying the knot] in GHC.IfaceToCore
|
| 358 | - if_rec_types :: (KnotVars (IfG TypeEnv))
|
|
| 358 | + if_rec_types :: KnotVars (IfG TypeEnv)
|
|
| 359 | 359 | -- Allows a read effect, so it can be in a mutable
|
| 360 | 360 | -- variable; c.f. handling the external package type env
|
| 361 | - -- Nothing => interactive stuff, no loops possible
|
|
| 362 | 361 | }
|
| 363 | 362 | |
| 364 | 363 | data IfLclEnv
|
| ... | ... | @@ -24,6 +24,7 @@ module GHC.Tc.Utils.Env( |
| 24 | 24 | tcLookupRecSelParent,
|
| 25 | 25 | tcLookupLocatedGlobalId, tcLookupLocatedTyCon,
|
| 26 | 26 | tcLookupLocatedClass, tcLookupAxiom,
|
| 27 | + tcLookupImported_maybe,
|
|
| 27 | 28 | lookupGlobal, lookupGlobal_maybe,
|
| 28 | 29 | addTypecheckedBinds, addEvBinds, addTopEvBinds,
|
| 29 | 30 | failIllegalTyCon, failIllegalTyVar,
|
| ... | ... | @@ -58,8 +59,8 @@ module GHC.Tc.Utils.Env( |
| 58 | 59 | |
| 59 | 60 | -- Template Haskell stuff
|
| 60 | 61 | LevelCheckReason(..),
|
| 61 | - tcMetaTy, thLevelIndex,
|
|
| 62 | - isBrackLevel,
|
|
| 62 | + tcMetaTy, tcMetaKnownKeyTy,
|
|
| 63 | + thLevelIndex, isBrackLevel,
|
|
| 63 | 64 | |
| 64 | 65 | -- New Ids
|
| 65 | 66 | newDFunName,
|
| ... | ... | @@ -268,6 +269,26 @@ tcLookupGlobal name |
| 268 | 269 | Failed msg -> failWithTc (TcRnInterfaceError msg)
|
| 269 | 270 | }}}
|
| 270 | 271 | |
| 272 | +tcLookupImported_maybe :: Name -> TcM (MaybeErr IfaceMessage TyThing)
|
|
| 273 | +-- Returns (Failed err) if we can't find the interface file for the thing
|
|
| 274 | +tcLookupImported_maybe name
|
|
| 275 | + = do { hsc_env <- getTopEnv
|
|
| 276 | + ; mb_thing <- liftIO (lookupType hsc_env name)
|
|
| 277 | + ; case mb_thing of
|
|
| 278 | + Just thing -> return (Succeeded thing)
|
|
| 279 | + Nothing -> tcImportDecl_maybe name }
|
|
| 280 | + |
|
| 281 | +tcImportDecl_maybe :: Name -> TcM (MaybeErr IfaceMessage TyThing)
|
|
| 282 | +-- Entry point for *source-code* uses of importDecl
|
|
| 283 | +tcImportDecl_maybe name
|
|
| 284 | + | Just thing <- wiredInNameTyThing_maybe name
|
|
| 285 | + = do { when (needWiredInHomeIface thing)
|
|
| 286 | + (initIfaceTcRn (loadWiredInHomeIface name))
|
|
| 287 | + -- See Note [Loading instances for wired-in things]
|
|
| 288 | + ; return (Succeeded thing) }
|
|
| 289 | + | otherwise
|
|
| 290 | + = initIfaceTcRn (importDecl name)
|
|
| 291 | + |
|
| 271 | 292 | -- Look up only in this module's global env't. Don't look in imports, etc.
|
| 272 | 293 | -- Panic if it's not there.
|
| 273 | 294 | tcLookupGlobalOnly :: Name -> TcM TyThing
|
| ... | ... | @@ -932,13 +953,25 @@ tcExtendRules lcl_rules thing_inside |
| 932 | 953 | ************************************************************************
|
| 933 | 954 | -}
|
| 934 | 955 | |
| 956 | +tcMetaKnownKeyTy :: HasDebugCallStack => Unique -> TcM Type
|
|
| 957 | +tcMetaKnownKeyTy uniq
|
|
| 958 | + = do { normal_path <- xoptM LangExt.ImplicitKnownKeyNames
|
|
| 959 | + ; mb_rdr_env <- if normal_path
|
|
| 960 | + then return Nothing
|
|
| 961 | + else Just <$> getGlobalRdrEnv
|
|
| 962 | + ; mb_thing <- initIfaceTcRn (lookupKnownKeyThing mb_rdr_env uniq)
|
|
| 963 | + ; case mb_thing of
|
|
| 964 | + Succeeded (ATyCon tc) -> return (mkTyConTy tc)
|
|
| 965 | + Succeeded thing -> wrongThingErr WrongThingTyCon (AGlobal thing) (getName thing)
|
|
| 966 | + Failed msg -> failWithTc (TcRnInterfaceError msg) }
|
|
| 967 | + |
|
| 935 | 968 | tcMetaTy :: Name -> TcM Type
|
| 936 | 969 | -- Given the name of a Template Haskell data type,
|
| 937 | 970 | -- return the type
|
| 938 | 971 | -- E.g. given the name "Expr" return the type "Expr"
|
| 939 | -tcMetaTy tc_name = do
|
|
| 940 | - t <- tcLookupTyCon tc_name
|
|
| 941 | - return (mkTyConTy t)
|
|
| 972 | +tcMetaTy tc_name
|
|
| 973 | + = do { t <- tcLookupTyCon tc_name
|
|
| 974 | + ; return (mkTyConTy t) }
|
|
| 942 | 975 | |
| 943 | 976 | isBrackLevel :: ThLevel -> Bool
|
| 944 | 977 | isBrackLevel (Brack {}) = True
|
| ... | ... | @@ -1135,7 +1168,7 @@ newDFunName clas tys loc |
| 1135 | 1168 | ; let info_string = occNameString (getOccName clas) ++
|
| 1136 | 1169 | concatMap (occNameString . getDFunTyKey) tys
|
| 1137 | 1170 | ; dfun_occ <- chooseUniqueOccTc (mkDFunOcc info_string is_boot)
|
| 1138 | - ; newGlobalBinder mod dfun_occ loc }
|
|
| 1171 | + ; newGlobalBinder mod dfun_occ Nothing loc }
|
|
| 1139 | 1172 | |
| 1140 | 1173 | newFamInstTyConName :: LocatedN Name -> [Type] -> TcM Name
|
| 1141 | 1174 | newFamInstTyConName (L loc name) tys = mk_fam_inst_name id (locA loc) name [tys]
|
| ... | ... | @@ -1150,7 +1183,7 @@ mk_fam_inst_name adaptOcc loc tc_name tyss |
| 1150 | 1183 | ; let info_string = occNameString (getOccName tc_name) ++
|
| 1151 | 1184 | intercalate "|" ty_strings
|
| 1152 | 1185 | ; occ <- chooseUniqueOccTc (mkInstTyTcOcc info_string)
|
| 1153 | - ; newGlobalBinder mod (adaptOcc occ) loc }
|
|
| 1186 | + ; newGlobalBinder mod (adaptOcc occ) Nothing loc }
|
|
| 1154 | 1187 | where
|
| 1155 | 1188 | ty_strings = map (concatMap (occNameString . getDFunTyKey)) tyss
|
| 1156 | 1189 | |
| ... | ... | @@ -1262,8 +1295,8 @@ notFound name |
| 1262 | 1295 | }
|
| 1263 | 1296 | |
| 1264 | 1297 | wrongThingErr :: WrongThingSort -> TcTyThing -> Name -> TcM a
|
| 1265 | -wrongThingErr expected thing name =
|
|
| 1266 | - failWithTc (TcRnTyThingUsedWrong expected thing name)
|
|
| 1298 | +wrongThingErr expected thing name
|
|
| 1299 | + = failWithTc (TcRnTyThingUsedWrong expected thing name)
|
|
| 1267 | 1300 | |
| 1268 | 1301 | {- Note [Out of scope might be a staging error]
|
| 1269 | 1302 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ... | ... | @@ -796,7 +796,7 @@ mkOverLit (HsIntegral i) |
| 796 | 796 | ; return (XLit $ HsInteger (il_text i) (il_value i) integer_ty) }
|
| 797 | 797 | |
| 798 | 798 | mkOverLit (HsFractional r)
|
| 799 | - = do { rat_ty <- tcMetaTy rationalTyConName
|
|
| 799 | + = do { rat_ty <- tcMetaKnownKeyTy rationalTyConKey
|
|
| 800 | 800 | ; return (XLit $ HsRat r rat_ty) }
|
| 801 | 801 | |
| 802 | 802 | mkOverLit (HsIsString src s) = return (HsString src s)
|
| ... | ... | @@ -2391,8 +2391,8 @@ initIfaceTcRn thing_inside |
| 2391 | 2391 | -- bangs to avoid leaking the envs (#19356)
|
| 2392 | 2392 | ; let !mhome_unit = hsc_home_unit_maybe hsc_env
|
| 2393 | 2393 | !knot_vars = tcg_type_env_var tcg_env
|
| 2394 | - -- When we are instantiating a signature, we DEFINITELY
|
|
| 2395 | - -- do not want to knot tie.
|
|
| 2394 | + -- When we are instantiating a signature,
|
|
| 2395 | + -- we DEFINITELY do not want to knot tie.
|
|
| 2396 | 2396 | is_instantiate = fromMaybe False (isHomeUnitInstantiating <$> mhome_unit)
|
| 2397 | 2397 | ; let { if_env = IfGblEnv {
|
| 2398 | 2398 | if_doc = text "initIfaceTcRn",
|
| ... | ... | @@ -32,6 +32,7 @@ import GHC.Builtin.Utils |
| 32 | 32 | |
| 33 | 33 | import GHC.Utils.Outputable
|
| 34 | 34 | import GHC.Utils.Panic
|
| 35 | +import GHC.Utils.Misc( HasDebugCallStack )
|
|
| 35 | 36 | |
| 36 | 37 | import Control.Applicative
|
| 37 | 38 | import Control.Concurrent.MVar
|
| ... | ... | @@ -134,12 +135,12 @@ lookupOrigNameCache nc mod occ = lookup_infinite <|> lookup_normal |
| 134 | 135 | occ_env <- lookupModuleEnv nc mod
|
| 135 | 136 | lookupOccEnv occ_env occ
|
| 136 | 137 | |
| 137 | -extendOrigNameCache' :: OrigNameCache -> Name -> OrigNameCache
|
|
| 138 | +extendOrigNameCache' :: HasDebugCallStack => OrigNameCache -> Name -> OrigNameCache
|
|
| 138 | 139 | extendOrigNameCache' nc name
|
| 139 | 140 | = assertPpr (isExternalName name) (ppr name) $
|
| 140 | 141 | extendOrigNameCache nc (nameModule name) (nameOccName name) name
|
| 141 | 142 | |
| 142 | -extendOrigNameCache :: OrigNameCache -> Module -> OccName -> Name -> OrigNameCache
|
|
| 143 | +extendOrigNameCache :: HasDebugCallStack => OrigNameCache -> Module -> OccName -> Name -> OrigNameCache
|
|
| 143 | 144 | extendOrigNameCache nc mod occ name
|
| 144 | 145 | = extendModuleEnvWith combine nc mod (unitOccEnv occ name)
|
| 145 | 146 | where
|
| ... | ... | @@ -3,6 +3,7 @@ module GHC.Unit.External |
| 3 | 3 | , initExternalUnitCache
|
| 4 | 4 | , eucEPS
|
| 5 | 5 | , ExternalPackageState (..)
|
| 6 | + , KnownKeyNameMap
|
|
| 6 | 7 | , initExternalPackageState
|
| 7 | 8 | , EpsStats(..)
|
| 8 | 9 | , addEpsInStats
|
| ... | ... | @@ -21,8 +22,6 @@ import GHC.Prelude |
| 21 | 22 | import GHC.Unit
|
| 22 | 23 | import GHC.Unit.Module.ModIface
|
| 23 | 24 | |
| 24 | -import GHC.Builtin.Utils( KnownKeyOccMap)
|
|
| 25 | - |
|
| 26 | 25 | import GHC.Core.FamInstEnv
|
| 27 | 26 | import GHC.Core.InstEnv ( InstEnv, emptyInstEnv )
|
| 28 | 27 | import GHC.Core.Opt.ConstantFold
|
| ... | ... | @@ -32,7 +31,10 @@ import GHC.Types.Annotations ( AnnEnv, emptyAnnEnv ) |
| 32 | 31 | import GHC.Types.CompleteMatch
|
| 33 | 32 | import GHC.Types.DefaultEnv (DefaultEnv)
|
| 34 | 33 | import GHC.Types.TypeEnv
|
| 34 | +import GHC.Types.Name( Name )
|
|
| 35 | +import GHC.Types.Unique( Unique )
|
|
| 35 | 36 | import GHC.Types.Unique.DSet
|
| 37 | +import GHC.Types.Unique.FM( UniqFM )
|
|
| 36 | 38 | |
| 37 | 39 | import GHC.Linker.Types (Linkable)
|
| 38 | 40 | |
| ... | ... | @@ -153,7 +155,7 @@ data ExternalPackageState |
| 153 | 155 | -- See Note [Interface Files with Core Definitions]
|
| 154 | 156 | eps_iface_bytecode :: !(ModuleEnv (IO Linkable)),
|
| 155 | 157 | |
| 156 | - eps_known_keys :: Maybe KnownKeyOccMap, -- ^ See Note [Overview of KnownKeyNames]
|
|
| 158 | + eps_known_keys :: Maybe KnownKeyNameMap, -- ^ See Note [Overview of KnownKeyNames]
|
|
| 157 | 159 | |
| 158 | 160 | eps_inst_env :: !PackageInstEnv, -- ^ The total 'InstEnv' accumulated
|
| 159 | 161 | -- from all the external-package modules
|
| ... | ... | @@ -174,6 +176,8 @@ data ExternalPackageState |
| 174 | 176 | eps_defaults :: !(ModuleEnv DefaultEnv) -- ^ Default declarations exported by external packages
|
| 175 | 177 | }
|
| 176 | 178 | |
| 179 | +type KnownKeyNameMap = UniqFM Unique Name -- See Note [Overview of known-key Names]
|
|
| 180 | + |
|
| 177 | 181 | -- | Accumulated statistics about what we are putting into the 'ExternalPackageState'.
|
| 178 | 182 | -- \"In\" means stuff that is just /read/ from interface files,
|
| 179 | 183 | -- \"Out\" means actually sucked in and type-checked
|
| ... | ... | @@ -28,7 +28,7 @@ extra-doc-files: |
| 28 | 28 | |
| 29 | 29 | Library
|
| 30 | 30 | default-language: Haskell2010
|
| 31 | - default-extensions: NoImplicitPrelude
|
|
| 31 | + default-extensions: NoImplicitPrelude, NoImplicitKnownKeyNames
|
|
| 32 | 32 | build-depends:
|
| 33 | 33 | ghc-internal == @ProjectVersionForLib@.*,
|
| 34 | 34 | ghc-prim,
|
| ... | ... | @@ -81,6 +81,7 @@ Library |
| 81 | 81 | default-language: Haskell2010
|
| 82 | 82 | default-extensions:
|
| 83 | 83 | NoImplicitPrelude
|
| 84 | + NoImplicitKnownKeyNames
|
|
| 84 | 85 | other-extensions:
|
| 85 | 86 | BangPatterns
|
| 86 | 87 | CApiFFI
|
| ... | ... | @@ -55,7 +55,8 @@ data Extension |
| 55 | 55 | | QuasiQuotes
|
| 56 | 56 | | ImplicitParams
|
| 57 | 57 | | ImplicitPrelude
|
| 58 | - | ImplicitKnownKeyNames -- TODO: Note for knownkey names
|
|
| 58 | + | ImplicitKnownKeyNames -- See Note [Overview of known-key names]
|
|
| 59 | + | DefinesKnownKeyNames -- See Note [Overview of known-key names]
|
|
| 59 | 60 | | ScopedTypeVariables
|
| 60 | 61 | | AllowAmbiguousTypes
|
| 61 | 62 | | UnboxedTuples
|
| 1 | 1 | {-# LANGUAGE Trustworthy #-}
|
| 2 | +{-# LANGUAGE DefinesKnownKeyNames #-}
|
|
| 2 | 3 | {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples, BangPatterns #-}
|
| 3 | 4 | {-# OPTIONS_GHC -Wno-orphans #-}
|
| 4 | 5 | {-# OPTIONS_HADDOCK not-home #-}
|