Apoorv Ingle pushed to branch wip/ani/T27156 at Glasgow Haskell Compiler / GHC Commits: d56976e2 by Apoorv Ingle at 2026-04-06T18:39:54-05:00 move SectionL and SectionR into tcExpand Work on #27156 - - - - - 2 changed files: - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expand.hs Changes: ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -50,7 +50,6 @@ import GHC.Unit.Module ( isInteractiveModule ) import GHC.Types.Basic (TypeOrKind (TypeLevel)) import GHC.Types.FieldLabel -import GHC.Types.Id.Make import GHC.Types.Name import GHC.Types.Name.Set import GHC.Types.Name.Reader @@ -714,25 +713,14 @@ rnSection section@(SectionR x op expr) = do { (op', fvs_op) <- rnLExpr op ; (expr', fvs_expr) <- rnLExpr expr ; checkSectionPrec InfixR section op' expr' - ; let rn_section = SectionR x op' expr' - ds_section = genHsApps rightSectionName [op',expr'] - ; return ( mkExpandedExpr rn_section ds_section - , fvs_op `plusFN` fvs_expr) } + ; return $ (SectionR x op' expr' , fvs_op `plusFN` fvs_expr) } rnSection section@(SectionL x expr op) -- See Note [Left and right sections] = do { (expr', fvs_expr) <- rnLExpr expr ; (op', fvs_op) <- rnLExpr op ; checkSectionPrec InfixL section op' expr' - ; postfix_ops <- xoptM LangExt.PostfixOperators - -- Note [Left and right sections] - ; let rn_section = SectionL x expr' op' - ds_section - | postfix_ops = HsApp noExtField op' expr' - | otherwise = genHsApps leftSectionName - [wrapGenSpan $ HsApp noExtField op' expr'] - ; return ( mkExpandedExpr rn_section ds_section - , fvs_op `plusFN` fvs_expr) } + ; return $ (SectionL x expr' op', fvs_op `plusFN` fvs_expr) } rnSection other = pprPanic "rnSection" (ppr other) ===================================== compiler/GHC/Tc/Gen/Expand.hs ===================================== @@ -16,8 +16,12 @@ import GHC.Hs import GHC.Tc.Utils.Monad import GHC.Tc.Types.ErrCtxt +import GHC.Types.Id.Make + import GHC.Rename.Utils +import qualified GHC.LanguageExtensions as LangExt + {- Note [Typechecking by expansion: overview] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For many constructs, rather than typechecking the user-written code @@ -110,6 +114,23 @@ tcExpand e@(OpApp _ arg1 op arg2) where ap f a = wrapGenSpan (HsApp noExtField f a) +tcExpand e@(SectionR _ op expr) + = return $ Just $ + HSE { hse_ctxt = ExprCtxt e + , hse_exp = wrapGenSpan $ genHsApps rightSectionName [op, expr] } + +tcExpand e@(SectionL _ expr op) + = do { postfix_ops <- xoptM LangExt.PostfixOperators + -- Note [Left and right sections] + ; let ds_section + | postfix_ops = HsApp noExtField op expr + | otherwise = genHsApps leftSectionName + [wrapGenSpan $ HsApp noExtField op expr] + ; return $ Just $ + HSE { hse_ctxt = ExprCtxt e + , hse_exp = wrapGenSpan ds_section } } + + tcExpand (XExpr (ExpandedThingRn hse)) = return (Just hse) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d56976e240ef0126160a6d9771d8272e... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d56976e240ef0126160a6d9771d8272e... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Apoorv Ingle (@ani)