Simon Peyton Jones pushed to branch wip/spj-reinstallable-base at Glasgow Haskell Compiler / GHC Commits: d5e3ac97 by Simon Peyton Jones at 2026-04-07T17:33:40+01:00 More - - - - - 13 changed files: - compiler/GHC/Builtin.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/RdrNames.hs - compiler/GHC/Builtin/Names/TH.hs → compiler/GHC/Builtin/TH.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/ghc.cabal.in - libraries/base/src/GHC/KnownKeyNames.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs Changes: ===================================== compiler/GHC/Builtin.hs ===================================== @@ -21,7 +21,8 @@ module GHC.Builtin ( -- * Main exports wiredInNames, wiredInIds, ghcPrimIds, - knownKeyTable, knownKeyOccMap, knownKeyUniqMap, knownKeyOccName, + knownKeyTable, knownKeyOccMap, knownKeyUniqMap, + knownKeyOccName, knownKeyOccName_maybe, knownKeyRdrName, knownOccRdrName, knownVarOccRdrName, -- * Known-key names @@ -51,7 +52,7 @@ import GHC.Builtin.PrimOps.Ids import GHC.Builtin.Types import GHC.Builtin.Types.Literals ( typeNatTyCons ) import GHC.Builtin.Types.Prim -import GHC.Builtin.Names.TH ( templateHaskellNames, thKnownKeyTable ) +import GHC.Builtin.TH ( templateHaskellNames, thKnownKeyTable ) import GHC.Builtin.Names( basicKnownKeyTable, basicKnownKeyNames ) import GHC.Builtin.Names( charDataConKey, intDataConKey, numericClassKeys, standardClassKeys ) @@ -84,6 +85,7 @@ import GHC.Unit.Module.ModIface (IfaceExport) import GHC.Unit.Module.Warnings import GHC.Data.List.SetOps +import GHC.Data.Maybe( orElse ) import Control.Applicative ((<|>)) import Data.Maybe @@ -351,10 +353,14 @@ knownKeyTable = basicKnownKeyTable ++ knownKeyOccName :: HasDebugCallStack => KnownKey -> OccName -- Find the OccName from the KnownKey, -- by looking in the knownKeyUniqMap -knownKeyOccName std_uniq - = case lookupUFM knownKeyUniqMap std_uniq of - Just occ -> occ - Nothing -> pprPanic "knownKeyOccName" (pprKnownKey std_uniq) +knownKeyOccName key + = knownKeyOccName_maybe key `orElse` + pprPanic "knownKeyOccName" (pprKnownKey key) + +knownKeyOccName_maybe :: HasDebugCallStack + => KnownKey -> Maybe OccName +knownKeyOccName_maybe key + = lookupUFM knownKeyUniqMap key knownKeyRdrName :: KnownKey -> RdrName knownKeyRdrName key = knownOccRdrName (knownKeyOccName key) ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -1261,7 +1261,7 @@ hasFieldClassKey = mkPreludeClassUnique 50 ---------------- Template Haskell ------------------- --- GHC.Builtin.Names.TH: USES ClassUniques 200-299 +-- GHC.Builtin.TH: USES ClassUniques 200-299 ----------------------------------------------------- {- @@ -1507,7 +1507,7 @@ multMulTyConKey :: KnownKey multMulTyConKey = mkPreludeTyConUnique 199 ---------------- Template Haskell ------------------- --- GHC.Builtin.Names.TH: USES TyConUniques 200-299 +-- GHC.Builtin.TH: USES TyConUniques 200-299 ----------------------------------------------------- ----------------------- SIMD ------------------------ @@ -1734,7 +1734,7 @@ naturalNBDataConKey = mkPreludeDataConUnique 124 ---------------- Template Haskell ------------------- --- GHC.Builtin.Names.TH: USES DataUniques 200-250 +-- GHC.Builtin.TH: USES DataUniques 200-250 ----------------------------------------------------- @@ -1943,7 +1943,7 @@ proxyHashKey :: KnownKey proxyHashKey = mkPreludeMiscIdUnique 502 ---------------- Template Haskell ------------------- --- GHC.Builtin.Names.TH: USES IdUniques 200-499 +-- GHC.Builtin.TH: USES IdUniques 200-499 ----------------------------------------------------- -- Used to make `Typeable` dictionaries ===================================== compiler/GHC/Builtin/RdrNames.hs ===================================== @@ -18,7 +18,7 @@ import GHC.Builtin import GHC.Builtin.PrimOps import GHC.Builtin.Types -- A bunch of wired-in TyCons and DataCons import GHC.Builtin.PrimOps.Ids (primOpId) -import GHC.Builtin.Names.TH( unsafeCodeCoerceName, liftTypedName ) +import GHC.Builtin.TH( unsafeCodeCoerceName, liftTypedName ) import GHC.Builtin.Names import GHC.Types.Name.Reader( RdrName, mkVarUnqual, getRdrName ===================================== compiler/GHC/Builtin/Names/TH.hs → compiler/GHC/Builtin/TH.hs ===================================== @@ -4,7 +4,7 @@ -- %* * -- %************************************************************************ -module GHC.Builtin.Names.TH where +module GHC.Builtin.TH where import GHC.Prelude () ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -53,7 +53,7 @@ import GHC.Core.Make import GHC.Core.Utils import GHC.Builtin.Names -import GHC.Builtin.Names.TH +import GHC.Builtin.TH import GHC.Builtin.Types import GHC.Builtin.Types.Prim ===================================== compiler/GHC/Iface/Errors/Ppr.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Iface.Errors.Ppr import GHC.Prelude +import GHC.Builtin( knownKeyOccName_maybe ) import GHC.Types.Error import GHC.Types.Hint.Ppr () -- Outputable GhcHint import GHC.Types.Error.Codes @@ -295,12 +296,20 @@ interfaceErrorDiagnostic opts = \ case CircularImport mod -> text "Circular imports: module" <+> quotes (ppr mod) <+> text "depends on itself" + MissingKnownKey1 key -> hang (text "Could not find known key" <+> quotes (pprKnownKey key)) - 2 (text "in the exports of GHC.KnownKeys") + 2 (vcat [ text "in the exports of GHC.KnownKeys" + , text "occname:" <+> pp_occ (knownKeyOccName_maybe key) ]) + where + pp_occ (Just occ) = ppr occ + pp_occ Nothing = text "Yikes: that key isn't in the known-key table" + MissingKnownKey2 key -> hang (text "Could not find known key" <+> quotes (pprKnownKey key)) 2 (text "in the static known-key table") + MissingKnownKey3 occ -> hang (text "Could not find known occurrence" <+> quotes (ppr occ)) 2 (text "in the exports of GHC.KnownKeys") + KnownKeyScopeError occ gres | null gres -> hang (text "Could not find known-key entity" <+> quotes (ppr occ)) ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -51,7 +51,7 @@ import GHC.Data.FastString import GHC.Utils.Logger import GHC.Utils.Panic import GHC.Driver.Hooks -import GHC.Builtin.Names.TH +import GHC.Builtin.TH import {-# SOURCE #-} GHC.Tc.Gen.Expr ( tcCheckPolyExpr ) import {-# SOURCE #-} GHC.Tc.Gen.Splice ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -73,7 +73,7 @@ import GHC.Types.Var.Set import GHC.Builtin.Names import GHC.Builtin.RdrNames -import GHC.Builtin.Names.TH +import GHC.Builtin.TH import GHC.Builtin.Types.Prim import GHC.Builtin.Types ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -66,7 +66,7 @@ import GHC.Types.SrcLoc import GHC.Types.Var.Set import GHC.Builtin.Names -import GHC.Builtin.Names.TH (liftClassKey) +import GHC.Builtin.TH (liftClassKey) import GHC.Utils.Misc import GHC.Utils.Outputable ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -68,7 +68,7 @@ import GHC.Core.TyCo.Rep as TyCoRep import GHC.Core.FamInstEnv import GHC.Core.InstEnv as InstEnv -import GHC.Builtin.Names.TH +import GHC.Builtin.TH import GHC.Builtin.Names import GHC.Builtin.Types @@ -864,7 +864,7 @@ tcUntypedSplice q splice_name (XUntypedSplice ils) -- lift :: Quote m' => a -> m' Exp ; lift <- setSrcSpan (getLocA id_name) $ newKnownOccMethod (ImplicitLiftOrigin ils) - GHC.Builtin.Names.TH.liftIdOcc + GHC.Builtin.TH.liftIdOcc [getRuntimeRep id_ty, id_ty] ; let res = nlHsApp (mkLHsWrap (applyQuoteWrapper q) (noLocA lift)) v_expr' @@ -890,7 +890,7 @@ tcPendingSpliceTyped q splice_name (XTypedSplice ils) res_ty -- lift :: Quote m' => a -> m' Exp ; lift <- setSrcSpan (getLocA id_name) $ newKnownOccMethod (ImplicitLiftOrigin ils) - GHC.Builtin.Names.TH.liftIdOcc + GHC.Builtin.TH.liftIdOcc [rep, res_ty] ; let res = nlHsApp (mkLHsWrap (applyQuoteWrapper q) (noLocA lift)) v_expr' ; return (PendingTcSplice splice_name res) } @@ -3108,7 +3108,7 @@ tcGetInterp = do -- Note [Hard-wiring in-tree template-haskell for desugaring quotes] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- To desugar Template Haskell quotes, GHC needs to wire in a bunch of Names in the --- `ghc-internal` library as Note [Known-key names], in GHC.Builtin.Names.TH. +-- `ghc-internal` library as Note [Known-key names], in GHC.Builtin.TH. -- Consider -- > foo :: Q Exp -- > foo = [| unwords ["hello", "world"] |] ===================================== compiler/ghc.cabal.in ===================================== @@ -201,11 +201,11 @@ Library GHC GHC.Builtin GHC.Builtin.Names - GHC.Builtin.Names.TH GHC.Builtin.PrimOps GHC.Builtin.PrimOps.Casts GHC.Builtin.PrimOps.Ids GHC.Builtin.RdrNames + GHC.Builtin.TH GHC.Builtin.Types GHC.Builtin.Types.Literals GHC.Builtin.Types.Prim ===================================== libraries/base/src/GHC/KnownKeyNames.hs ===================================== @@ -81,7 +81,7 @@ module GHC.KnownKeyNames , arr, (>>>), first, app, (|||), loop -- IO - , thenIO, bindIO, returnIO, print + , IO, thenIO, bindIO, returnIO, print -- Unsatisfiable , Unsatisfiable, unsatisfiable @@ -112,8 +112,11 @@ module GHC.KnownKeyNames , integerComplement, integerBit#, integerTestBit#, integerShiftL#, integerShiftR# -- Template Haskell - , Q, Name, FieldExp, Decs, TH.Type, FunDep + , Q, DecsQ, ExpQ, TypeQ, PatQ + , Name, Decs, TH.Type, FunDep , Pred, Code, InjectivityAnn, Overlap, ModName, QuasiQuoter + , Stmt, Con, BangType, VarBangType, RuleBndr, TySynEqn, Role, DerivClause + , Kind, TyVarBndrUnit, TyVarBndrSpec, TyVarBndrVis, DerivStrategy , sequenceQ, newName, mkName, mkNameG_v, mkNameG_d, mkNameG_tc, mkNameG_fld, mkNameL , mkNameQ, mkNameS, mkModName, unType, unTypeCode, unsafeCodeCoerce , lift, liftString, liftTyped ===================================== libraries/ghc-internal/src/GHC/Internal/Base.hs ===================================== @@ -453,7 +453,7 @@ W6: in GHC.HsToCore.Foreign.Wasm. A complete list could probably be made by going through the known-key -names in GHC.Builtin.Names and GHC.Builtin.Names.TH. To test whether +names in GHC.Builtin.Names and GHC.Builtin.TH. To test whether the transitive imports are sufficient for any single module, instruct the build system to build /only/ that module in stage 2. For example, a command to check whether the transitive imports for GHC.Internal.Maybe View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5e3ac9746cb91a984c3b354fe03c01b... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5e3ac9746cb91a984c3b354fe03c01b... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Peyton Jones (@simonpj)