[Git][ghc/ghc][wip/spj-apporv-Oct24] some comments and review changes
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC Commits: 97ca9953 by Apoorv Ingle at 2026-03-29T23:02:17-05:00 some comments and review changes - - - - - 3 changed files: - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Types/Origin.hs Changes: ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -539,7 +539,10 @@ checkResultTy rn_expr (tc_fun, fun_loc) inst_args app_res_rho (Check res_ty) thing_inside ---------------- -tcValArgs :: QLFlag -> (HsExpr GhcRn, SrcSpan) -> [HsExprArg 'TcpInst] -> TcM [HsExprArg 'TcpTc] +tcValArgs :: QLFlag + -> (HsExpr GhcRn, SrcSpan) -- Head of the application chain (used only for error message generation) + -> [HsExprArg 'TcpInst] + -> TcM [HsExprArg 'TcpTc] -- Importantly, tcValArgs works left-to-right, so that by the time we -- encounter an argument, we have monomorphised all the instantiation -- variables that its type contains. All that is left to do is an ordinary @@ -553,7 +556,7 @@ tcValArgs do_ql (fun, fun_lspan) args = go do_ql 0 args ; return (arg' : args') } where -- increment position if the argument is user written type or value argument - pos' | EValArg{} <- arg + !pos' | EValArg{} <- arg = pos + 1 | EValArgQL{} <- arg = pos + 1 @@ -564,7 +567,10 @@ tcValArgs do_ql (fun, fun_lspan) args = go do_ql 0 args = pos -tcValArg :: QLFlag -> Int -> (HsExpr GhcRn, SrcSpan) -> HsExprArg 'TcpInst -- Actual argument +tcValArg :: QLFlag + -> Int -- argument position (used only for error message generation) + -> (HsExpr GhcRn, SrcSpan) -- Head of the application chain (used only for error message generation) + -> HsExprArg 'TcpInst -- Actual argument -> TcM (HsExprArg 'TcpTc) -- Resulting argument tcValArg _ _ _ (EPrag l p) = return (EPrag l (tcExprPrag p)) tcValArg _ _ _ (ETypeArg l hty ty) = return (ETypeArg l hty ty) ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -306,22 +306,25 @@ tcExpr :: HsExpr GhcRn -- - HsAppType type applications -- - ExprWithTySig (e :: type) -- - HsRecSel overloaded record fields --- - ExpandedThingRn renamer/pre-typechecker expansions -- - HsOpApp operator applications -- - HsOverLit overloaded literals -- These constructors are the union of -- - 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 [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 tcExpr e@(HsAppType {}) res_ty = tcApp e res_ty tcExpr e@(ExprWithTySig {}) res_ty = tcApp e res_ty +tcExpr e@(XExpr (HsRecSelRn{})) res_ty = tcApp e res_ty +-- Renamer expanded expressions (eg. Right/Left sections) +-- or tcExpr expanded expressions (eg. Do statements and Record updates) +-- are type checked using tcHsExpansion. +-- See Note [Typechecking by expansion: overview] tcExpr (XExpr (ExpandedThingRn hse)) res_ty = tcHsExpansion hse res_ty -tcExpr e@(XExpr{}) res_ty = tcApp e res_ty + -- Typecheck an occurrence of an unbound Id -- ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -1530,13 +1530,17 @@ data ExpectedFunTyCtxt -- | A rebindable syntax operator is expected to have a function type. -- -- Test cases for representation-polymorphism checks: - -- RepPolyDoBind, RepPolyDoBody{1,2}, RepPolyMc{Bind,Body,Guard}, RepPolyNPlusK + -- RepPolyMc{Bind,Body,Guard}, RepPolyNPlusK = forall (p :: Pass) . (OutputableBndrId p) => ExpectedFunTySyntaxOp !CtOrigin !(HsExpr (GhcPass p)) -- ^ rebindable syntax operator - -- | + -- | A rebindable syntax operator is expected to have a function type. + -- + -- Test cases for representation-polymorphism checks: + -- RepPolyDoBind, RepPolyDoBody{1,2}, + -- This constructor will merge with ExpectedFunTySyntaxOp when tcSyntaxOp is retired. | ExpectedTySyntax !CtOrigin !(HsExpr GhcRn) -- | A view pattern must have a function type. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97ca9953268ad58a9f381dc4aeb47aa5... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97ca9953268ad58a9f381dc4aeb47aa5... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Apoorv Ingle (@ani)