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
3 changed files:
Changes:
| ... | ... | @@ -539,7 +539,10 @@ checkResultTy rn_expr (tc_fun, fun_loc) inst_args app_res_rho (Check res_ty) |
| 539 | 539 | thing_inside
|
| 540 | 540 | |
| 541 | 541 | ----------------
|
| 542 | -tcValArgs :: QLFlag -> (HsExpr GhcRn, SrcSpan) -> [HsExprArg 'TcpInst] -> TcM [HsExprArg 'TcpTc]
|
|
| 542 | +tcValArgs :: QLFlag
|
|
| 543 | + -> (HsExpr GhcRn, SrcSpan) -- Head of the application chain (used only for error message generation)
|
|
| 544 | + -> [HsExprArg 'TcpInst]
|
|
| 545 | + -> TcM [HsExprArg 'TcpTc]
|
|
| 543 | 546 | -- Importantly, tcValArgs works left-to-right, so that by the time we
|
| 544 | 547 | -- encounter an argument, we have monomorphised all the instantiation
|
| 545 | 548 | -- 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 |
| 553 | 556 | ; return (arg' : args') }
|
| 554 | 557 | where
|
| 555 | 558 | -- increment position if the argument is user written type or value argument
|
| 556 | - pos' | EValArg{} <- arg
|
|
| 559 | + !pos' | EValArg{} <- arg
|
|
| 557 | 560 | = pos + 1
|
| 558 | 561 | | EValArgQL{} <- arg
|
| 559 | 562 | = pos + 1
|
| ... | ... | @@ -564,7 +567,10 @@ tcValArgs do_ql (fun, fun_lspan) args = go do_ql 0 args |
| 564 | 567 | = pos
|
| 565 | 568 | |
| 566 | 569 | |
| 567 | -tcValArg :: QLFlag -> Int -> (HsExpr GhcRn, SrcSpan) -> HsExprArg 'TcpInst -- Actual argument
|
|
| 570 | +tcValArg :: QLFlag
|
|
| 571 | + -> Int -- argument position (used only for error message generation)
|
|
| 572 | + -> (HsExpr GhcRn, SrcSpan) -- Head of the application chain (used only for error message generation)
|
|
| 573 | + -> HsExprArg 'TcpInst -- Actual argument
|
|
| 568 | 574 | -> TcM (HsExprArg 'TcpTc) -- Resulting argument
|
| 569 | 575 | tcValArg _ _ _ (EPrag l p) = return (EPrag l (tcExprPrag p))
|
| 570 | 576 | tcValArg _ _ _ (ETypeArg l hty ty) = return (ETypeArg l hty ty)
|
| ... | ... | @@ -306,22 +306,25 @@ tcExpr :: HsExpr GhcRn |
| 306 | 306 | -- - HsAppType type applications
|
| 307 | 307 | -- - ExprWithTySig (e :: type)
|
| 308 | 308 | -- - HsRecSel overloaded record fields
|
| 309 | --- - ExpandedThingRn renamer/pre-typechecker expansions
|
|
| 310 | 309 | -- - HsOpApp operator applications
|
| 311 | 310 | -- - HsOverLit overloaded literals
|
| 312 | 311 | -- These constructors are the union of
|
| 313 | 312 | -- - ones taken apart by GHC.Tc.Gen.Head.splitHsApps
|
| 314 | 313 | -- - ones understood by GHC.Tc.Gen.Head.tcInferAppHead_maybe
|
| 315 | 314 | -- See Note [Application chains and heads] in GHC.Tc.Gen.App
|
| 316 | --- Se Note [Typechecking by expansion: overview]
|
|
| 317 | 315 | tcExpr e@(HsVar {}) res_ty = tcApp e res_ty
|
| 318 | 316 | tcExpr e@(HsApp {}) res_ty = tcApp e res_ty
|
| 319 | 317 | tcExpr e@(OpApp {}) res_ty = tcApp e res_ty
|
| 320 | 318 | tcExpr e@(HsAppType {}) res_ty = tcApp e res_ty
|
| 321 | 319 | tcExpr e@(ExprWithTySig {}) res_ty = tcApp e res_ty
|
| 320 | +tcExpr e@(XExpr (HsRecSelRn{})) res_ty = tcApp e res_ty
|
|
| 322 | 321 | |
| 322 | +-- Renamer expanded expressions (eg. Right/Left sections)
|
|
| 323 | +-- or tcExpr expanded expressions (eg. Do statements and Record updates)
|
|
| 324 | +-- are type checked using tcHsExpansion.
|
|
| 325 | +-- See Note [Typechecking by expansion: overview]
|
|
| 323 | 326 | tcExpr (XExpr (ExpandedThingRn hse)) res_ty = tcHsExpansion hse res_ty
|
| 324 | -tcExpr e@(XExpr{}) res_ty = tcApp e res_ty
|
|
| 327 | + |
|
| 325 | 328 | |
| 326 | 329 | -- Typecheck an occurrence of an unbound Id
|
| 327 | 330 | --
|
| ... | ... | @@ -1530,13 +1530,17 @@ data ExpectedFunTyCtxt |
| 1530 | 1530 | -- | A rebindable syntax operator is expected to have a function type.
|
| 1531 | 1531 | --
|
| 1532 | 1532 | -- Test cases for representation-polymorphism checks:
|
| 1533 | - -- RepPolyDoBind, RepPolyDoBody{1,2}, RepPolyMc{Bind,Body,Guard}, RepPolyNPlusK
|
|
| 1533 | + -- RepPolyMc{Bind,Body,Guard}, RepPolyNPlusK
|
|
| 1534 | 1534 | = forall (p :: Pass)
|
| 1535 | 1535 | . (OutputableBndrId p)
|
| 1536 | 1536 | => ExpectedFunTySyntaxOp !CtOrigin !(HsExpr (GhcPass p))
|
| 1537 | 1537 | -- ^ rebindable syntax operator
|
| 1538 | 1538 | |
| 1539 | - -- |
|
|
| 1539 | + -- | A rebindable syntax operator is expected to have a function type.
|
|
| 1540 | + --
|
|
| 1541 | + -- Test cases for representation-polymorphism checks:
|
|
| 1542 | + -- RepPolyDoBind, RepPolyDoBody{1,2},
|
|
| 1543 | + -- This constructor will merge with ExpectedFunTySyntaxOp when tcSyntaxOp is retired.
|
|
| 1540 | 1544 | | ExpectedTySyntax !CtOrigin !(HsExpr GhcRn)
|
| 1541 | 1545 | |
| 1542 | 1546 | -- | A view pattern must have a function type.
|