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
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:
| ... | ... | @@ -1158,7 +1158,8 @@ the typechecker: |
| 1158 | 1158 | ApplicativeStmt.
|
| 1159 | 1159 | * Expanded (via ExpandedThingRn) ExplicitList{}, where we give the SrcSpan of the original
|
| 1160 | 1160 | list expression to the expanded expression. The 'fromListN' is assigned
|
| 1161 | - a generated location span
|
|
| 1161 | + a generated location span with location span details to be of the original list expression
|
|
| 1162 | + c.f. GeneratedSrcSpan in GHC.Tc.Types.SrcLoc
|
|
| 1162 | 1163 | |
| 1163 | 1164 | In order for the implicit function calls to not be confused for actual
|
| 1164 | 1165 | occurrences of functions in the source code, most of this extra information
|
| ... | ... | @@ -307,7 +307,7 @@ tcExpr :: HsExpr GhcRn |
| 307 | 307 | -- - ones taken apart by GHC.Tc.Gen.Head.splitHsApps
|
| 308 | 308 | -- - ones understood by GHC.Tc.Gen.Head.tcInferAppHead_maybe
|
| 309 | 309 | -- See Note [Application chains and heads] in GHC.Tc.Gen.App
|
| 310 | --- Se Note [Overview of Typechecking an XExpr]
|
|
| 310 | +-- Se Note [Typechecking by expansion: overview]
|
|
| 311 | 311 | tcExpr e@(HsVar {}) res_ty = tcApp e res_ty
|
| 312 | 312 | tcExpr e@(HsApp {}) res_ty = tcApp e res_ty
|
| 313 | 313 | tcExpr e@(OpApp {}) res_ty = tcApp e res_ty
|
| ... | ... | @@ -823,10 +823,10 @@ The rest of this Note explains how that is done. |
| 823 | 823 | |
| 824 | 824 | * The type checker error-stack element `GHC.Tc.Types.ErrCtxt.ErrCtxt`
|
| 825 | 825 | has two fields
|
| 826 | - data ErrCtxt = EC ErrCtxt
|
|
| 826 | + data ErrCtxt = MkErrCtxt CodeSrcFlag ErrCtxt
|
|
| 827 | 827 | |
| 828 | 828 | * `CodeSrcFlag` says whether we are typechecking an expanded thing,
|
| 829 | - and what that expanded thing is
|
|
| 829 | + and what that expanded thing is.
|
|
| 830 | 830 | * `ErrCtxtMsgM` stores the pre-text error message itself.
|
| 831 | 831 | |
| 832 | 832 | When called on an `XExpr`, `addLExprCtxt`, adds the user written thing
|
| ... | ... | @@ -42,7 +42,6 @@ import GHC.Tc.Solver ( InferMode(..), simplifyInfer ) |
| 42 | 42 | import GHC.Tc.Utils.Env
|
| 43 | 43 | import GHC.Tc.Utils.TcMType
|
| 44 | 44 | import GHC.Tc.Types.Origin
|
| 45 | -import GHC.Tc.Types.ErrCtxt ( srcCodeOriginErrCtxMsg )
|
|
| 46 | 45 | import GHC.Tc.Types.Constraint( WantedConstraints )
|
| 47 | 46 | import GHC.Tc.Utils.TcType as TcType
|
| 48 | 47 | import GHC.Tc.Types.Evidence
|
| ... | ... | @@ -1368,7 +1368,7 @@ setErrCtxt ctxt = updLclEnv (setLclEnvErrCtxt ctxt) |
| 1368 | 1368 | -- do any tidying.
|
| 1369 | 1369 | -- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr
|
| 1370 | 1370 | addErrCtxt :: ErrCtxtMsg -> TcM a -> TcM a
|
| 1371 | -o{-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt]
|
|
| 1371 | +{-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt]
|
|
| 1372 | 1372 | addErrCtxt msg = addErrCtxtM (\env -> return (env, msg))
|
| 1373 | 1373 | |
| 1374 | 1374 | -- See Note [ErrCtxtStack Manipulation]
|
| ... | ... | @@ -19,7 +19,7 @@ import GHC.Hs.Expr () -- instance Outputable |
| 19 | 19 | import GHC.Types.Id
|
| 20 | 20 | import GHC.Types.Name
|
| 21 | 21 | import GHC.Types.Name.Reader (RdrName,ImpDeclSpec (..), rdrNameOcc, rdrNameSpace)
|
| 22 | -import GHC.Types.SrcLoc (SrcSpan(..), srcSpanStartLine, UnhelpfulSpanReason(..), pprGeneratedSrcSpanDetails)
|
|
| 22 | +import GHC.Types.SrcLoc (SrcSpan(..), srcSpanStartLine, pprGeneratedSrcSpanDetails)
|
|
| 23 | 23 | import GHC.Unit.Module.Imported (ImportedModsVal(..))
|
| 24 | 24 | import GHC.Unit.Types
|
| 25 | 25 | import GHC.Utils.Outputable
|
| ... | ... | @@ -396,10 +396,10 @@ data SrcSpan = |
| 396 | 396 | deriving (Eq, Show) -- Show is used by GHC.Parser.Lexer, because we
|
| 397 | 397 | -- derive Show for Token
|
| 398 | 398 | |
| 399 | --- Needed for HIE
|
|
| 399 | +-- Needed for HIE. See Note [Source locations for implicit function calls] in GHC.Iface.Ext.Ast
|
|
| 400 | 400 | data GeneratedSrcSpanDetails =
|
| 401 | 401 | OrigSpan !RealSrcSpan -- this the span of the user written thing
|
| 402 | - | UnhelpfulGenerated
|
|
| 402 | + | UnhelpfulGenerated -- we do not have the original location.
|
|
| 403 | 403 | deriving (Eq, Show)
|
| 404 | 404 | |
| 405 | 405 | data UnhelpfulSpanReason
|