[Git][ghc/ghc][wip/ani/T27156] HsQualLit via Expand
Apoorv Ingle pushed to branch wip/ani/T27156 at Glasgow Haskell Compiler / GHC Commits: c6ae25eb by Apoorv Ingle at 2026-04-19T20:59:43-05:00 HsQualLit via Expand - - - - - 3 changed files: - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Gen/Expand.hs Changes: ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -40,7 +40,6 @@ import GHC.Rename.Unbound ( reportUnboundName ) import GHC.Rename.Splice ( rnTypedBracket, rnUntypedBracket, rnTypedSplice , rnUntypedSpliceExpr, checkThLocalNameWithLift, checkThLocalNameNoLift ) import GHC.Rename.HsType -import GHC.Rename.Lit import GHC.Rename.Pat import GHC.Driver.DynFlags @@ -369,10 +368,11 @@ rnExpr (HsOverLit x lit) return (HsApp noExtField (noLocA neg) (noLocA (HsOverLit x lit')) , fvs ) } -rnExpr (HsQualLit x lit) = do - ((lit', desugaredExpr), fvs) <- rnQualLit lit - let origExpr = HsQualLit x lit' - return (mkExpandedExpr origExpr desugaredExpr, fvs) +rnExpr (HsQualLit x QualLit{..}) + = do { (funName, fvs) <- lookupNameWithQualifier fromStringName ql_mod + ; let lit' = QualLit{ql_ext = L noAnn funName, ..} + ; return (HsQualLit x lit', fvs) + } rnExpr (HsApp x fun arg) = do { (fun',fvFun) <- rnLExpr fun ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -41,7 +41,7 @@ module GHC.Rename.Utils ( where -import GHC.Prelude hiding (init, last, scanl, tail) +import GHC.Prelude import GHC.Core.Type import GHC.Hs ===================================== compiler/GHC/Tc/Gen/Expand.hs ===================================== @@ -131,6 +131,20 @@ tcExpand e@(HsOverLabel (_, rs_table) v) | otherwise = pprPanic "tcExpand" (vcat [ text "Should Never Happen: could not find fromLabel in rs_table" , ppr e] ) + +------------------------------------------ +-- Qualified Literals +tcExpand e@(HsQualLit _ QualLit{ql_val = ql_val, ql_ext = (L _ fromStringName)}) + = do { let hsLit = case ql_val of + -- See Note [Implementation of QualifiedStrings] + HsQualString st s -> HsString st s + ; return $ Just $ + HSE { hse_ctxt = ExprCtxt e + , hse_exp = wrapGenSpan $ genHsApps fromStringName [genLHsLit hsLit] + } + } + + ------------------------------------------ -- Operator Applications tcExpand e@(OpApp _ arg1 op arg2) @@ -186,7 +200,7 @@ tcExpand (HsDo _ do_or_lc stmts) -- ApplicativeDo are typechecked using tcDoStmts = do isApplicativeDo <- xoptM LangExt.ApplicativeDo if isApplicativeDo - then return Nothing + then return Nothing -- to be fixed by #24406 -- Expand expression on the fly otherwise -- See Note [Typechecking by expansion: overview] else do { hse <- expandDoStmts do_or_lc stmts @@ -254,10 +268,9 @@ tcExpand e@(RecordUpd (Just rs_table) (L l expr) (OverloadedRecUpdFields { olRec ---------- --- We return ExpandedThingRn as is for now, --- but after removing all the calls to mkExpandExpr in the renamer, --- this case should never happen, as the renamer will never produce an ExpandedThingRn +------------------------ +-- XExpr +-- Expansions are idempotent, XExprs do not expand again tcExpand (XExpr (ExpandedThingRn hse)) = return (Just hse) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6ae25ebd38670897679bdaf24f1c597... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6ae25ebd38670897679bdaf24f1c597... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Apoorv Ingle (@ani)