[Git][ghc/ghc][wip/spj-apporv-Oct24] 2 commits: make add_expr_ctxt handle error messages for HsPar more appropriately
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC Commits: 92af1dc5 by Apoorv Ingle at 2025-11-23T17:04:07-06:00 make add_expr_ctxt handle error messages for HsPar more appropriately - - - - - 3426b48f by Apoorv Ingle at 2025-11-23T17:13:55-06:00 fix overloaded list error message. Expanded Expressions head listFromN should be wrapped in a generated source span - - - - - 3 changed files: - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs Changes: ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -512,7 +512,7 @@ rnExpr (ExplicitList _ exps) ; let rn_list = ExplicitList noExtField exps' lit_n = mkIntegralLit (length exps) hs_lit = genHsIntegralLit lit_n - exp_list = genHsApps' (L (noAnnSrcSpan loc) from_list_n_name) [hs_lit, wrapGenSpan rn_list] + exp_list = genHsApps' (wrapGenSpan from_list_n_name) [hs_lit, wrapGenSpan rn_list] ; return ( mkExpandedExpr rn_list exp_list , fvs `plusFV` fvs') } } ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -334,7 +334,7 @@ tcExpr e@(HsLit x lit) res_ty ; tcWrapResult e (HsLit x (convertLit lit)) lit_ty res_ty } tcExpr (HsPar x expr) res_ty - = do { expr' <- tcMonoLExprNC expr res_ty + = do { expr' <- tcMonoLExpr expr res_ty ; return (HsPar x expr') } tcExpr (HsPragE x prag expr) res_ty ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -1090,19 +1090,18 @@ add_expr_ctxt e thing_inside -- f x = _ -- when we don't want to say "In the expression: _", -- because it is mentioned in the error message itself - HsPar{} -> thing_inside + HsPar _ e -> add_expr_ctxt (unLoc e) thing_inside -- We don't want to say 'In the expression (e)', -- we just want to say 'In the expression, 'e' -- which will be handeled by the recursive call in thing_inside + -- This may be a little inefficient with nested parens exprs, eg. (((e))) + -- But it should be okay as I do not expect too many parens to be nested consecutively XExpr (ExpandedThingRn o _) -> addExpansionErrCtxt o (srcCodeOriginErrCtxMsg o) thing_inside _ -> addErrCtxt (ExprCtxt e) thing_inside -- no op in generated code addLExprCtxt :: SrcSpan -> HsExpr GhcRn -> TcRn a -> TcRn a addLExprCtxt lspan e thing_inside - | not (isGeneratedSrcSpan lspan) - , (HsPar _ e') <- e - = setSrcSpan lspan $ add_expr_ctxt (unLoc e') thing_inside | not (isGeneratedSrcSpan lspan) = setSrcSpan lspan $ add_expr_ctxt e thing_inside | otherwise View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/32ac5a0589a73993ecc6b5e2601b9d3... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/32ac5a0589a73993ecc6b5e2601b9d3... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Apoorv Ingle (@ani)