[Git][ghc/ghc][wip/ani/tc-expand] kill addExpansionErrCtxt
Apoorv Ingle pushed to branch wip/ani/tc-expand at Glasgow Haskell Compiler / GHC Commits: d99340c0 by Apoorv Ingle at 2026-03-16T21:17:01-05:00 kill addExpansionErrCtxt - - - - - 4 changed files: - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Utils/Monad.hs Changes: ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -957,8 +957,8 @@ addArgCtxt arg_no (app_head, app_head_lspan) (L arg_loc arg) thing_inside , ppr arg , ppr arg_no]) ; setSrcSpanA arg_loc $ - addNthFunArgErrCtxt app_head arg arg_no $ - thing_inside + addErrCtxt (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $ + thing_inside } | otherwise = do { traceTc "addArgCtxt" (vcat [text "generated Head" @@ -969,16 +969,6 @@ addArgCtxt arg_no (app_head, app_head_lspan) (L arg_loc arg) thing_inside ; addLExprCtxt (locA arg_loc) arg $ thing_inside } - where - addNthFunArgErrCtxt :: HsExpr GhcRn -> HsExpr GhcRn -> Int -> TcM a -> TcM a - addNthFunArgErrCtxt app_head arg arg_no thing_inside - | XExpr (ExpandedThingRn _ _) <- arg - = addExpansionErrCtxt (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $ - thing_inside - | otherwise - = addErrCtxt (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $ - thing_inside - {- ********************************************************************* ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -76,7 +76,7 @@ expand_do_stmts flav [stmt@(L sloc (LastStmt _ body@(L body_loc _) _ ret_expr))] -- See `checkLastStmt` and `Syntax.Expr.StmtLR.LastStmt` | NoSyntaxExprRn <- ret_expr -- Last statement is just body if we are not in ListComp context. See Syntax.Expr.LastStmt - = return $ L sloc (mkExpandedStmt stmt flav (unLoc body)) -- TODO ANI: why not just body? + = return $ L sloc (mkExpandedStmt stmt flav (unLoc body)) | SyntaxExprRn ret <- ret_expr -- We have unfortunately lost the location on the return function :( -- ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -691,7 +691,7 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr ; (ds_expr, ds_res_ty, err_msg) <- expandRecordUpd record_expr possible_parents rbnds res_ty - ; addExpansionErrCtxt err_msg $ + ; setInGeneratedCode $ addErrCtxt err_msg $ do { -- Typecheck the expanded expression. expr' <- tcExpr ds_expr (Check ds_res_ty) -- NB: it's important to use ds_res_ty and not res_ty here. @@ -1861,7 +1861,7 @@ checkMissingFields con_like rbinds arg_tys fl `elemField` flds = any (\ fl' -> flSelector fl == fl') flds --- Expands the expression +-- Expands the expression on the fly tcExpandExpr :: HsExpr GhcRn -> TcM (HsExpr GhcRn) tcExpandExpr orig_expr@(HsDo _ flav (L _ stmts)) = do { expanded_expr <- expandDoStmts flav stmts ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -88,7 +88,7 @@ module GHC.Tc.Utils.Monad( -- * Context management for the type checker getErrCtxt, setErrCtxt, addErrCtxt, - addLExprCtxt, addExpansionErrCtxt, + addLExprCtxt, popErrCtxt, getCtLocM, setCtLocM, mkCtLocEnv, -- * Diagnostic message generation (type checker) @@ -1369,11 +1369,6 @@ addErrCtxt :: HsCtxt -> TcM a -> TcM a {-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt] addErrCtxt ctxt = pushCtxt ctxt --- See Note [ErrCtxtStack Manipulation] -addExpansionErrCtxt :: HsCtxt -> TcM a -> TcM a -{-# INLINE addExpansionErrCtxt #-} -- Note [Inlining addErrCtxt] -addExpansionErrCtxt ctxt thing_inside = setInGeneratedCode $ pushCtxt ctxt thing_inside - -- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr pushCtxt :: ErrCtxt -> TcM a -> TcM a {-# INLINE pushCtxt #-} -- Note [Inlining addErrCtxt] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d99340c02f798bcd5b796537927fcafc... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d99340c02f798bcd5b796537927fcafc... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Apoorv Ingle (@ani)