[Git][ghc/ghc][wip/sand-witch/lazy-skol] Make tcExpr deal with expanded expressions directly

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Tue Jan 30 09:00:37 UTC 2024



Simon Peyton Jones pushed to branch wip/sand-witch/lazy-skol at Glasgow Haskell Compiler / GHC


Commits:
6b7c6acf by Simon Peyton Jones at 2024-01-30T09:00:02+00:00
Make tcExpr deal with expanded expressions directly

Going via tcApp is needlessly slow, and gives worse error messages

- - - - -


1 changed file:

- compiler/GHC/Tc/Gen/Expr.hs


Changes:

=====================================
compiler/GHC/Tc/Gen/Expr.hs
=====================================
@@ -287,7 +287,15 @@ 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@(HsRecSel {})           res_ty = tcApp e res_ty
-tcExpr e@(XExpr (HsExpanded {})) res_ty = tcApp e res_ty
+
+-- tcApp can deal with HsExpanded (because we might find one at the
+-- head of an application chain) but it is needlessly expensive to
+-- treat every HsExpanded as a nullary application; it it gives less
+-- good error messages because we infer the type of the head of the
+-- appication chain.  So we give it a case here.
+tcExpr (XExpr (HsExpanded orig expr)) res_ty
+ = do { expr' <- tcExpr expr res_ty
+      ; return (XExpr (ExpansionExpr (HsExpanded orig expr'))) }
 
 tcExpr e@(HsOverLit _ lit) res_ty
   = do { mb_res <- tcShortCutLit lit res_ty



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6b7c6acf7e3af81d490fcce5aa88cce7e2079ee8

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6b7c6acf7e3af81d490fcce5aa88cce7e2079ee8
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240130/05487283/attachment-0001.html>


More information about the ghc-commits mailing list