
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC Commits: 285a4db0 by Apoorv Ingle at 2025-05-05T20:22:28-05:00 look through PopErrCtxt while splitting exprs in application chains - - - - - 2 changed files: - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Head.hs Changes: ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -413,11 +413,13 @@ tcApp rn_expr exp_res_ty -- Step 2: Infer the type of `fun`, the head of the application ; (tc_fun, fun_sigma) <- tcInferAppHead fun ; let tc_head = (tc_fun, fun_ctxt) - ; traceTc "tcApp:inferAppHead" $ - vcat [ text "tc_fun:" <+> ppr tc_fun - , text "fun_sigma:" <+> ppr fun_sigma] -- Step 3: Instantiate the function type (taking a quick look at args) ; do_ql <- wantQuickLook rn_fun + ; traceTc "tcApp:inferAppHead" $ + vcat [ text "tc_fun:" <+> ppr tc_fun + , text "fun_sigma:" <+> ppr fun_sigma + , text "do_ql:" <+> ppr do_ql] + ; (inst_args, app_res_rho) <- tcInstFun do_ql True (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -300,6 +300,7 @@ splitHsApps e = go e (top_ctxt 0 e) [] top_ctxt n (HsPragE _ _ fun) = top_lctxt n fun top_ctxt n (HsAppType _ fun _) = top_lctxt (n+1) fun top_ctxt n (HsApp _ fun _) = top_lctxt (n+1) fun + top_ctxt n (XExpr (PopErrCtxt fun)) = top_ctxt n fun top_ctxt n other_fun = VACall other_fun n noSrcSpan top_lctxt :: Int -> LHsExpr GhcRn -> AppCtxt @@ -332,6 +333,9 @@ splitHsApps e = go e (top_ctxt 0 e) [] -- and its hard to say exactly what that is : EWrap (EExpand e) : args ) + go (XExpr (PopErrCtxt fun)) ctxt args = go fun ctxt args + -- look through PopErrCtxt (cf. T17594f) we do not want to lose the opportunity of calling tcEValArgQL + -- unlike HsPar, it is okay to forget about the PopErrCtxts as it does not persist over in GhcTc land go e ctxt args = pure ((e,ctxt), args) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/285a4db0f397efbfbd8b4f4568cc3d14... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/285a4db0f397efbfbd8b4f4568cc3d14... You're receiving this email because of your account on gitlab.haskell.org.