Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC Commits: faaa724a by Apoorv Ingle at 2026-02-02T00:46:24-06:00 notes update Note [Typechecking by expansion: overview] - - - - - 6 changed files: - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/SrcLoc.hs Changes: ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1158,7 +1158,8 @@ the typechecker: ApplicativeStmt. * Expanded (via ExpandedThingRn) ExplicitList{}, where we give the SrcSpan of the original list expression to the expanded expression. The 'fromListN' is assigned - a generated location span + a generated location span with location span details to be of the original list expression + c.f. GeneratedSrcSpan in GHC.Tc.Types.SrcLoc In order for the implicit function calls to not be confused for actual occurrences of functions in the source code, most of this extra information ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -307,7 +307,7 @@ tcExpr :: HsExpr GhcRn -- - ones taken apart by GHC.Tc.Gen.Head.splitHsApps -- - ones understood by GHC.Tc.Gen.Head.tcInferAppHead_maybe -- See Note [Application chains and heads] in GHC.Tc.Gen.App --- Se Note [Overview of Typechecking an XExpr] +-- Se Note [Typechecking by expansion: overview] tcExpr e@(HsVar {}) res_ty = tcApp e res_ty tcExpr e@(HsApp {}) res_ty = tcApp e res_ty tcExpr e@(OpApp {}) res_ty = tcApp e res_ty @@ -823,10 +823,10 @@ The rest of this Note explains how that is done. * The type checker error-stack element `GHC.Tc.Types.ErrCtxt.ErrCtxt` has two fields - data ErrCtxt = EC ErrCtxt + data ErrCtxt = MkErrCtxt CodeSrcFlag ErrCtxt * `CodeSrcFlag` says whether we are typechecking an expanded thing, - and what that expanded thing is + and what that expanded thing is. * `ErrCtxtMsgM` stores the pre-text error message itself. When called on an `XExpr`, `addLExprCtxt`, adds the user written thing ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -42,7 +42,6 @@ import GHC.Tc.Solver ( InferMode(..), simplifyInfer ) import GHC.Tc.Utils.Env import GHC.Tc.Utils.TcMType import GHC.Tc.Types.Origin -import GHC.Tc.Types.ErrCtxt ( srcCodeOriginErrCtxMsg ) import GHC.Tc.Types.Constraint( WantedConstraints ) import GHC.Tc.Utils.TcType as TcType import GHC.Tc.Types.Evidence ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -1368,7 +1368,7 @@ setErrCtxt ctxt = updLclEnv (setLclEnvErrCtxt ctxt) -- do any tidying. -- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr addErrCtxt :: ErrCtxtMsg -> TcM a -> TcM a -o{-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt] +{-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt] addErrCtxt msg = addErrCtxtM (\env -> return (env, msg)) -- See Note [ErrCtxtStack Manipulation] ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -19,7 +19,7 @@ import GHC.Hs.Expr () -- instance Outputable import GHC.Types.Id import GHC.Types.Name import GHC.Types.Name.Reader (RdrName,ImpDeclSpec (..), rdrNameOcc, rdrNameSpace) -import GHC.Types.SrcLoc (SrcSpan(..), srcSpanStartLine, UnhelpfulSpanReason(..), pprGeneratedSrcSpanDetails) +import GHC.Types.SrcLoc (SrcSpan(..), srcSpanStartLine, pprGeneratedSrcSpanDetails) import GHC.Unit.Module.Imported (ImportedModsVal(..)) import GHC.Unit.Types import GHC.Utils.Outputable ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -396,10 +396,10 @@ data SrcSpan = deriving (Eq, Show) -- Show is used by GHC.Parser.Lexer, because we -- derive Show for Token --- Needed for HIE +-- Needed for HIE. See Note [Source locations for implicit function calls] in GHC.Iface.Ext.Ast data GeneratedSrcSpanDetails = OrigSpan !RealSrcSpan -- this the span of the user written thing - | UnhelpfulGenerated + | UnhelpfulGenerated -- we do not have the original location. deriving (Eq, Show) data UnhelpfulSpanReason View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/faaa724a6bbdbd534b0273e8a25a370f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/faaa724a6bbdbd534b0273e8a25a370f... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Apoorv Ingle (@ani)