[Git][ghc/ghc][wip/spj-apporv-Oct24] remove special case of tcbody from tcLambdaMatches

Apoorv Ingle (@ani) gitlab at gitlab.haskell.org
Mon Mar 10 19:29:23 UTC 2025


Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC


Commits:
cb8ce844 by Apoorv Ingle at 2025-03-10T14:29:05-05:00
remove special case of tcbody from tcLambdaMatches

- - - - -


3 changed files:

- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Match.hs


Changes:

=====================================
compiler/GHC/Hs/Expr.hs
=====================================
@@ -531,13 +531,6 @@ type instance XXExpr GhcTc = XXExprGhcTc
 data HsThingRn = OrigExpr (HsExpr GhcRn)                -- ^ The source, user written, expression
                | OrigStmt (ExprLStmt GhcRn) HsDoFlavour -- ^ which kind of do-block did this statement come from
 
-isHsThingRnExpr, isHsThingRnStmt :: HsThingRn -> Bool
-isHsThingRnExpr (OrigExpr{}) = True
-isHsThingRnExpr _ = False
-
-isHsThingRnStmt (OrigStmt{}) = True
-isHsThingRnStmt _ = False
-
 data XXExprGhcRn
   = ExpandedThingRn { xrn_orig     :: HsThingRn       -- The original source thing to be used for error messages
                     , xrn_expanded :: HsExpr GhcRn    -- The compiler generated expanded thing


=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -1252,5 +1252,4 @@ addExprCtxt e thing_inside
    -- when we don't want to say "In the expression: _",
    -- because it is mentioned in the error message itself
       HsUnboundVar {} -> thing_inside
-      XExpr (ExpandedThingRn {}) -> thing_inside
       _ -> addErrCtxt (ExprCtxt e) thing_inside


=====================================
compiler/GHC/Tc/Gen/Match.hs
=====================================
@@ -79,7 +79,7 @@ import GHC.Types.Name
 import GHC.Types.Name.Reader (LocalRdrEnv)
 import GHC.Types.Id
 import GHC.Types.SrcLoc
-import GHC.Types.Basic( VisArity, isDoExpansionGenerated )
+import GHC.Types.Basic( VisArity )
 
 import qualified GHC.Data.List.NonEmpty as NE
 
@@ -155,21 +155,13 @@ tcLambdaMatches e lam_variant matches invis_pat_tys res_ty
 
         ; (wrapper, r)
             <- matchExpectedFunTys herald GenSigCtxt arity res_ty $ \ pat_tys rhs_ty ->
-               tcMatches tc_body (invis_pat_tys ++ pat_tys) rhs_ty matches
+               tcMatches tcBody (invis_pat_tys ++ pat_tys) rhs_ty matches
 
         ; return (wrapper, r) }
   where
     herald = ExpectedFunTyLam lam_variant e
              -- See Note [Herald for matchExpectedFunTys] in GHC.Tc.Utils.Unify
 
-    tc_body | isDoExpansionGenerated (mg_ext matches)
-              -- See Part 3. B. of Note [Expanding HsDo with XXExprGhcRn] in
-              -- `GHC.Tc.Gen.Do`. Testcase: Typeable1
-            = tcBodyNC -- NB: Do not add any error contexts
-                       -- It has already been done
-            | otherwise
-            = tcBody
-
 {-
 @tcCaseMatches@ doesn't do the argument-count check because the
 parser guarantees that each equation has exactly one argument.



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb8ce8449cc59d4186bc8f1830c9da630c28fc53
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/20250310/b078029a/attachment-0001.html>


More information about the ghc-commits mailing list