[Git][ghc/ghc][master] hadrian: Include transitive dependencies in Haddock builds
by Marge Bot (@marge-bot) 24 Oct '26
by Marge Bot (@marge-bot) 24 Oct '26
24 Oct '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
92848e61 by Evgeny Malyshev at 2026-10-23T20:26:04-04:00
hadrian: Include transitive dependencies in Haddock builds
Haddock needs indirect dependency interfaces to resolve references to
definitions outside a package's direct dependencies. Expose Cabal's
configured dependency closure through ContextData and use it alongside
the direct list, preserving direct-interface precedence.
Bump Shake's cache version for the serialized oracle change. Add a
Hadrian selftest requiring template-haskell's indirect ghc-prim interface.
Fixes #25850.
Fixes #27786.
Assisted-By: OpenAI Codex
Metric Increase:
haddock.Cabal
- - - - -
6 changed files:
- + changelog.d/25850
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Hadrian/Haskell/Cabal/Type.hs
- hadrian/src/Main.hs
- hadrian/src/Rules/Documentation.hs
- hadrian/src/Rules/Selftest.hs
Changes:
=====================================
changelog.d/25850
=====================================
@@ -0,0 +1,5 @@
+section: packaging
+synopsis: Include transitive dependencies when building library documentation with
+ Hadrian, so Haddock can resolve references to indirect dependencies.
+issues: #25850 #27786
+mrs: !16638
=====================================
hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
=====================================
@@ -321,6 +321,7 @@ resolveContextData context@Context {..} = do
(C.hsSourceDirs buildInfo)
, depIds = depIds
, depNames = map (C.display . C.mungedName . snd) extDeps
+ , transitiveDepNames = map (C.display . C.mungedName') depPkgs
, includeDirs = map C.getSymbolicPath (C.includeDirs buildInfo)
, includes = map C.getSymbolicPath (C.includes buildInfo)
, installIncludes = map C.getSymbolicPath (C.installIncludes buildInfo)
=====================================
hadrian/src/Hadrian/Haskell/Cabal/Type.hs
=====================================
@@ -48,6 +48,7 @@ data ContextData = ContextData
, srcDirs :: [String]
, depIds :: [String]
, depNames :: [String]
+ , transitiveDepNames :: [String]
, includeDirs :: [String]
, includes :: [String]
, installIncludes :: [String]
=====================================
hadrian/src/Main.hs
=====================================
@@ -68,7 +68,7 @@ main = do
-- from PackageData or other oracle value types). This forces
-- Shake to wipe the stale database instead of crashing on
-- deserialisation.
- shakeVersion = "3"
+ shakeVersion = "4"
, shakeChange = ChangeModtimeAndDigest
, shakeFiles = buildRoot -/- Base.shakeFilesDir
, shakeProgress = Progress.hadrianProgress cwd
=====================================
hadrian/src/Rules/Documentation.hs
=====================================
@@ -422,9 +422,12 @@ buildManPage = do
checkSphinxWarnings dir
copyFileUntracked (dir -/- "ghc.1") file
--- | Find the Haddock files for the dependencies of the current library.
+-- | Find the Haddock files for the direct and indirect dependencies of the current library.
haddockDependencies :: Context -> Action [(Package, FilePath)]
haddockDependencies context = do
- depNames <- interpretInContext context (getContextData depNames)
+ directDeps <- interpretInContext context (getContextData depNames)
+ transitiveDeps <- interpretInContext context (getContextData transitiveDepNames)
+ -- Preserve the preference for direct dependencies when resolving links.
+ let depNames = nub (directDeps ++ transitiveDeps)
sequence [ (,) <$> pure depPkg <*> (pkgHaddockFile $ vanillaContext (stage context) depPkg)
| Just depPkg <- map findPackageByName depNames, (pkgName depPkg) `notElem` haddockExclude ]
=====================================
hadrian/src/Rules/Selftest.hs
=====================================
@@ -8,6 +8,7 @@ import Base
import Context
import Oracles.ModuleFiles
import Packages
+import Rules.Documentation (haddockDependencies)
import Settings
import Target
import Utilities
@@ -71,6 +72,11 @@ testDependencies = do
test $ stage1Deps /= stage0Deps
test $ stage1Deps == stage2Deps
+ putBuild "==== T25850: Transitive Haddock dependencies"
+ haddockDeps <- map fst <$> haddockDependencies (vanillaContext Stage1 templateHaskell)
+ unless (ghcPrim `elem` haddockDeps) $
+ fail "T25850: Haddock is missing the indirect ghc-prim dependency of template-haskell"
+
testLookupAll :: Action ()
testLookupAll = do
putBuild "==== lookupAll"
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/92848e6186123d5820bcfb2f4ef5059…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/92848e6186123d5820bcfb2f4ef5059…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
23 Oct '26
Apoorv Ingle pushed to branch wip/ani/T27156 at Glasgow Haskell Compiler / GHC
Commits:
122e97c6 by Apoorv Ingle at 2026-07-31T16:23:49-05:00
Work on #27156
- Add `RebindableSyntaxTable` to store function/operator names while renaming in the XBlah fields
- Expand the following expressions right before typechecking instead of in the renamer
* OverloadedLabel
* RecordDotSyntax: HsGetField and HsProjection
* ExplicitList
* RecordUpd
* HsIf
* HsDo (Vanilla cases)
- - - - -
0582455a by Apoorv Ingle at 2026-07-31T16:23:49-05:00
update notes
- - - - -
c9ce3acb by Apoorv Ingle at 2026-07-31T16:23:49-05:00
rebase changes
- - - - -
ba9730bd by Apoorv Ingle at 2026-07-31T16:51:29-05:00
revert th test
- - - - -
c22f51ed by Apoorv Ingle at 2026-10-23T17:54:33-05:00
make a new ReSynBinds to store the module name
- - - - -
18 changed files:
- + changelog.d/T27156
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Expand.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/ThToHs.hs
- libraries/ghc-boot-th/GHC/Boot/TH/Ppr.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
- testsuite/tests/ghc-api/T25121_status.stdout
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail9.stderr
- testsuite/tests/rebindable/T19918.stdout
- testsuite/tests/th/T18102b.stdout
Changes:
=====================================
changelog.d/T27156
=====================================
@@ -0,0 +1,10 @@
+section: compiler
+issues: #27156
+mrs: !15868
+synopsis:
+ Refactor code, to perform expansions related to rebindable sytax in their own pass
+description:
+ Expansions for some constructs (HsIf, Record Dot Syntax, Sections)
+ was done in the renamer while for others it was done in
+ the type checker. This patch moves all the expansions out of the renamer into its own pass.
+ This patch changes the behavior of typed template haskell with rebindable syntax turned on.
\ No newline at end of file
=====================================
compiler/GHC/Hs/Expr.hs
=====================================
@@ -221,7 +221,9 @@ type instance XRecSel GhcTc = NoExtField
-- OverLabel not present in GhcTc pass; see GHC.Rename.Expr
-- Note [Handling overloaded and rebindable constructs]
type instance XOverLabel GhcPs = SourceText
-type instance XOverLabel GhcRn = SourceText
+type instance XOverLabel GhcRn = ( SourceText -- Needed for pretty printing
+ , RebindableSyntaxTable) -- contains the fromLabel Name
+
type instance XOverLabel GhcTc = DataConCantHappen
-- ---------------------------------------------------------------------
@@ -278,7 +280,7 @@ type instance XCase GhcRn = HsMatchContextRn
type instance XCase GhcTc = HsMatchContextRn
type instance XIf GhcPs = AnnsIf
-type instance XIf GhcRn = NoExtField
+type instance XIf GhcRn = RebindableSyntaxTable -- NoRebindable <=> RebindableSyntax is off
type instance XIf GhcTc = NoExtField
type instance XMultiIf GhcPs = (EpToken "if", EpToken "{", EpToken "}")
@@ -294,7 +296,7 @@ type instance XDo GhcRn = NoExtField
type instance XDo GhcTc = Type
type instance XExplicitList GhcPs = AnnList ()
-type instance XExplicitList GhcRn = NoExtField
+type instance XExplicitList GhcRn = RebindableSyntaxTable -- NoRebindable <=> RebindableSyntax is off
type instance XExplicitList GhcTc = Type
-- GhcPs: ExplicitList includes all source-level
-- list literals, including overloaded ones
@@ -308,8 +310,9 @@ type instance XRecordCon GhcPs = NoExtField
type instance XRecordCon GhcRn = NoExtField
type instance XRecordCon GhcTc = PostTcExpr -- Instantiated constructor function
+
type instance XRecordUpd GhcPs = (EpToken "{", EpToken "}")
-type instance XRecordUpd GhcRn = NoExtField
+type instance XRecordUpd GhcRn = RebindableSyntaxTable -- NoRebindable <=> RebindableSyntaxTable is off
type instance XRecordUpd GhcTc = DataConCantHappen
-- We desugar record updates in the typechecker.
-- See [Handling overloaded and rebindable constructs],
@@ -341,16 +344,16 @@ type instance XLHsRecUpdLabels GhcTc = DataConCantHappen
type instance XLHsOLRecUpdLabels p = NoExtField
type instance XGetField GhcPs = NoExtField
-type instance XGetField GhcRn = NoExtField
+type instance XGetField GhcRn = RebindableSyntaxTable
type instance XGetField GhcTc = DataConCantHappen
--- HsGetField is eliminated by the renamer. See [Handling overloaded
--- and rebindable constructs].
+-- HsGetField is eliminated by the expansion in GHC.Tc.Expand
+-- See [Handling overloaded and rebindable constructs].
type instance XProjection GhcPs = AnnProjection
-type instance XProjection GhcRn = NoExtField
+type instance XProjection GhcRn = RebindableSyntaxTable
type instance XProjection GhcTc = DataConCantHappen
--- HsProjection is eliminated by the renamer. See [Handling overloaded
--- and rebindable constructs].
+-- HsProjection is eliminated by the expansion in GHC.Tc.Expand
+-- See [Handling overloaded and rebindable constructs].
type instance XExprWithTySig GhcPs = TokDcolon
type instance XExprWithTySig GhcRn = NoExtField
@@ -644,7 +647,7 @@ tupArgsPresent_maybe = traverse tupArgPresent_maybe
* *
********************************************************************* -}
-type instance XXExpr GhcPs = DataConCantHappen
+type instance XXExpr GhcPs = XXExprGhcPs
type instance XXExpr GhcRn = XXExprGhcRn
type instance XXExpr GhcTc = XXExprGhcTc
-- XXExprGhcRn: see Note [Rebindable syntax and XXExprGhcRn] below
@@ -657,6 +660,10 @@ type instance XXExpr GhcTc = XXExprGhcTc
* *
********************************************************************* -}
+data XXExprGhcPs
+ = ReSynBinds ModuleName (HsExpr GhcPs)
+
+
-- See Note [Rebindable syntax and XXExprGhcRn]
-- See Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do`
-- See Note [Typechecking by expansion: overview]
@@ -673,6 +680,7 @@ data XXExprGhcRn
-- See Note [Non-overloaded record field selectors] and
-- Note [Record selectors in the AST]
+
data XXExprGhcTc
= WrapExpr -- Type and evidence application and abstractions
HsWrapper (HsExpr GhcTc)
@@ -817,7 +825,7 @@ ppr_expr (HsHole x) = case (ghcPass @p, x) of
(GhcTc, (HoleError, _)) -> pprPrefixOcc unnamedHoleRdrName
ppr_expr (HsOverLabel s l) = case ghcPass @p of
GhcPs -> helper s
- GhcRn -> helper s
+ GhcRn -> helper (fst s)
GhcTc -> dataConCantHappen s
where helper :: SourceText -> SDoc
@@ -1021,9 +1029,12 @@ ppr_expr (HsFunArr _ arr arg res)
= sep [ppr_lexpr arg, pprHsModifiedFunArr arr <+> ppr_lexpr res]
ppr_expr (XExpr x) = case ghcPass @p of
+ GhcPs -> ppr x
GhcRn -> ppr x
GhcTc -> ppr x
+instance Outputable XXExprGhcPs where
+ ppr (ReSynBinds m e) = text "{{" <+> ppr m <+> text "}}" <+> ppr e
ppr_hse :: forall p. (IsPass p) => HsExpansion (GhcPass p) -> SDoc
ppr_hse hse
@@ -1080,10 +1091,14 @@ ppr_infix_expr (HsHole x) = Just $ pprInfixOcc $ case (ghcPass @p, x) of
(GhcTc, (HoleVar (L _ v), _)) -> v
_ -> unnamedHoleRdrName -- TODO: this is the HoleError case; this should print the source text instead of "_".
ppr_infix_expr (XExpr x) = case ghcPass @p of
+ GhcPs -> ppr_infix_expr_ps x
GhcRn -> ppr_infix_expr_rn x
GhcTc -> ppr_infix_expr_tc x
ppr_infix_expr _ = Nothing
+ppr_infix_expr_ps :: XXExprGhcPs -> Maybe SDoc
+ppr_infix_expr_ps (ReSynBinds{}) = Nothing
+
ppr_infix_expr_rn :: XXExprGhcRn -> Maybe SDoc
ppr_infix_expr_rn (ExpandedThingRn (HSE thing _)) = ppr_infix_hs_expansion thing
ppr_infix_expr_rn (HsRecSelRn f) = Just (pprInfixOcc f)
@@ -1174,9 +1189,13 @@ hsExprNeedsParens prec = go
go (HsQual{}) = prec >= funPrec
go (HsFunArr{}) = prec >= funPrec
go (XExpr x) = case ghcPass @p of
+ GhcPs -> go_x_ps x
GhcTc -> go_x_tc x
GhcRn -> go_x_rn x
+ go_x_ps :: XXExprGhcPs -> Bool
+ go_x_ps (ReSynBinds _ e) = hsExprNeedsParens prec e
+
go_x_tc :: XXExprGhcTc -> Bool
go_x_tc (WrapExpr _ e) = hsExprNeedsParens prec e
go_x_tc (ExpandedThingTc (HSE thing _)) = hsExpandedNeedsParens thing
@@ -1264,7 +1283,8 @@ instance Outputable (HsPragE (GhcPass p)) where
{- Note [Rebindable syntax and XXExprGhcRn]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We implement rebindable syntax (RS) support by performing an expansion
-in the renamer. We transform GhcPs expressions and patterns affected by
+right before typechecking and after renaming.
+We transform GhcRn expressions and patterns affected by
RS into the appropriate expanded form, but **annotated with the original
expression/pattern**.
@@ -1297,7 +1317,7 @@ original 'if' expression around too, using the TTG
XExpr extension point to allow GHC to construct an
'XXExprGhcRn' value that will keep track of the original
expression in its first field, and the desugared one in the
-second field. The resulting renamed AST would look like:
+second field. The resulting expanded AST would look like:
L locif (XExpr
(ExpandedThingRn (HSE
@@ -1357,25 +1377,26 @@ tcl_in_gen_code Bool to False.
---
-An overview of the constructs that are desugared in this way is laid out in
+An overview of the constructs that are expanded in this way is laid out in
Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr.
A general recipe to follow this approach for new constructs could go as follows:
- Remove any GhcRn-time SyntaxExpr extensions to the relevant constructor for your
construct, in HsExpr or related syntax data types.
-- At renaming-time:
+- At renaming-time (GHC.Tc.Gen.Rename.rnExpr) :
- take your original node of interest (HsIf above)
- rename its subexpressions/subpatterns (condition and true/false
branches above)
- construct the suitable "rebound"-and-renamed result (ifThenElse call
above), where the 'SrcSpan' attached to any _fabricated node_ (the
HsVar/HsApp nodes, above) is set to 'generatedSrcSpan'
+- At Expansion time (GHC.Tc.Gen.Expand.tcExpand)
- take both the original node and that rebound-and-renamed result and wrap
them into an expansion construct:
- for expressions, XExpr (ExpandedThingRn <original node> <desugared>)
+ for expressions, XExpr (ExpandedThingRn (HSE { hse_ctxt = <original node> hse_exp = <desugared> }))
for patterns, XPat (HsPatExpanded <original node> <desugared>)
- - At typechecking-time:
+ - At typechecking-time (GHC.Tc.Gen.tcExpr):
- remove any logic that was previously dealing with your rebindable
construct, typically involving [tc]SyntaxOp, SyntaxExpr and friends.
- the XExpr (ExpandedThingRn ... ...) case in tcExpr already makes sure that we
@@ -1482,6 +1503,14 @@ type instance XXCmd GhcTc = HsWrap HsCmd
type CmdSyntaxTable p = [(Name, HsExpr p)]
-- See Note [CmdSyntaxTable]
+-- | Syntax lookup table for rebindable constructs
+data RebindableSyntaxTable = NoRebindable | Rebindable [(OccName, Name)]
+-- See Note [RebindableSyntaxTable]
+
+isNoRebindable :: RebindableSyntaxTable -> Bool
+isNoRebindable NoRebindable = True
+isNoRebindable Rebindable{} = False
+
{-
Note [CmdSyntaxTable]
~~~~~~~~~~~~~~~~~~~~~
@@ -1518,6 +1547,32 @@ is Less Cool because
typecheck do-notation with (>>=) :: m1 a -> (a -> m2 b) -> m2 b.)
-}
+{-
+Note [RebindableSyntaxTable]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+During renaming of constructs that support rebindable syntax (eg. HsIf),
+we store the function (eg. ifThenElse) in a rebindable syntax table. Then
+in the the expansion phase, right before typechecking, we use the
+function (eg. ifThenElse) to build the actual expression to be typechecked.
+
+Why do we need to do this?
+The renamer identifies the free variables of the expressions to perform dependency analysis.
+When rebindable sytax is turned on, we want to treat the expression
+
+ HsIf b e1 e2
+
+As if it is
+
+ ifThenElse b e1 e2
+
+Thus the renamer needs to return `ifThenElse` as a free variable.
+
+Rebindable syntax stores this `ifThenElse` name so that it can be
+used to build the correct expanded expression in GHC.Tc.Gen.Expand.tcExpand.
+
+-}
+
+
data CmdTopTc
= CmdTopTc
-- | Nested tuple of inputs on the command's stack
=====================================
compiler/GHC/Hs/Instances.hs
=====================================
@@ -355,6 +355,8 @@ deriving instance Data (RoleAnnotDecl GhcTc)
-- ---------------------------------------------------------------------
-- Data derivations from GHC.Hs.Expr -----------------------------------
+deriving instance Data RebindableSyntaxTable -- maybe don't traverse?
+
deriving instance Data (FieldLabelStrings GhcPs)
deriving instance Data (FieldLabelStrings GhcRn)
deriving instance Data (FieldLabelStrings GhcTc)
@@ -728,7 +730,7 @@ deriving instance Data (HsExpansion GhcTc)
deriving instance Data a => Data (WithUserRdr a)
-- -------------------------------
---------------------------------------
+deriving instance Data XXExprGhcPs
deriving instance Data XXExprGhcTc
deriving instance Data XXPatGhcTc
=====================================
compiler/GHC/Rename/Expr.hs
=====================================
@@ -3,6 +3,7 @@
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
+{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
@@ -39,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
@@ -49,7 +49,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
@@ -72,7 +71,7 @@ import qualified GHC.LanguageExtensions as LangExt
import Control.Monad
import qualified Data.Foldable as Partial (maximum)
import Data.List (unzip4)
-import Data.List.NonEmpty ( NonEmpty(..), head, init, last, nonEmpty, scanl, tail )
+import Data.List.NonEmpty ( NonEmpty(..), head, nonEmpty, scanl, tail )
import Control.Arrow (first)
import Data.Ord
import Data.Array
@@ -84,20 +83,34 @@ import Data.Foldable (toList)
Nomenclature
-------------
-* Expansion (`HsExpr GhcRn -> HsExpr GhcRn`): expand between renaming and
- typechecking, using the `XXExprGhcRn` constructor of `HsExpr`.
-* Desugaring (`HsExpr GhcTc -> Core.Expr`): convert the typechecked `HsSyn` to Core. This is done in GHC.HsToCore
+* Expansion (`HsExpr GhcRn -> HsExpansion GhcRn`): expand after renaming and
+ right before typechecking, using the `XXExprGhcRn` constructor of `HsExpr`.
+* Desugaring (`HsExpr GhcTc -> Core.Expr`): convert the typechecked `HsSyn` to Core.
+ This is done in GHC.HsToCore
For overloaded constructs (overloaded literals, lists, strings), and
rebindable constructs (e.g. if-then-else), our general plan is this,
using overloaded labels #foo as an example:
-* In the RENAMER: transform
+* In the RENAMER (GHC.Tc.Rename.rnExpr):
+ Identify if we need to transform the rebindable construct
+ and store the appropriate `fromLabel` function in the RebindableSyntaxTable
+ field associated with HsOverLabel.
+
HsOverLabel "foo"
- ==> XExpr (ExpandedThingRn (HsOverLabel #foo)
- (fromLabel `HsAppType` "foo"))
+ ==> HsOverLabel (Rebindable [("fromLabel", fromLabelClassOpName)]) "foo"
+
+* In the EXPANSION (GHC.Tc.Gen.Expand.tcExpand):
+ Expand the HsOverLabel to an Expanded expression
+ using the fromLabel function stored in the rebindable syntax table
+
+ HsOverLabel (Rebindable [("fromLabel", fromLabelClassOpName)]) "foo"
+ ==> XExpr (ExpandedThingRn HSE { hse_ctxt = (HsOverLabel #foo)
+ , hse_exp = L genLoc (fromLabel `HsAppType` "foo") })
+
We write this more compactly in concrete-syntax form like this
+
#foo ==> fromLabel @"foo"
Recall that in (ExpandedThingRn orig expanded), 'orig' is the original term
@@ -107,16 +120,18 @@ using overloaded labels #foo as an example:
* In the TYPECHECKER: typecheck the expansion, in this case
fromLabel @"foo"
The typechecker (and desugarer) will never see HsOverLabel
+ See Note [Typechecking by expansion: overview]
-In effect, the renamer does a bit of desugaring. Recall GHC.Hs.Expr
-Note [Rebindable syntax and XXExprGhcRn], which describes the use of XXExprGhcRn.
+In effect, the renamer stores the rebindable syntax functions (ifThenElse, fromLabel, etc).
+in the rebindable syntax table, the expander build the actual AST before typechecking.
+Recall GHC.Hs.Expr Note [Rebindable syntax and XXExprGhcRn], which describes the use of XXExprGhcRn.
RebindableSyntax:
If RebindableSyntax is off we use the built-in 'fromLabel', defined in
GHC.Builtin.Names.fromLabelClassOpName
If RebindableSyntax if ON, we look up "fromLabel" in the environment
to get whichever one is in scope.
-This is accomplished by lookupSyntaxName, and it applies to all the
+This is accomplished by `lookupSyntaxName`, and it applies to all the
constructs below.
See also Note [Handling overloaded and rebindable patterns] in GHC.Rename.Pat
@@ -149,9 +164,6 @@ but several have a little bit of special treatment:
where `leftSection` and `rightSection` are representation-polymorphic
wired-in Ids. See Note [Left and right sections]
-* To understand why expansions for `OpApp` is done in `GHC.Tc.Gen.Head.splitHsApps`
- see Note [Doing XXExprGhcRn in the Renamer vs Typechecker] below.
-
* RecordUpd: we desugar record updates into case expressions,
in GHC.Tc.Gen.Expr.tcExpr.
@@ -172,8 +184,23 @@ but several have a little bit of special treatment:
See Note [Record Updates] in GHC.Tc.Gen.Expr for more details.
- To understand Why is this done in the typechecker, and not in the renamer
- see Note [Doing XXExprGhcRn in the Renamer vs Typechecker]
+ This expansion is done in the typechecker on the fly (`GHC.Tc.Gen.tcExpr`), (until #27160 is fixed)
+ and not in the renamer for two reasons:
+
+ - (Until we implement GHC proposal #366)
+ We need to know the type of the record to disambiguate its fields.
+
+ - We use the type signature of the data constructor to provide `IdSigs`
+ to the let-bound variables (x', y' in the example of
+ See Note [Handling overloaded and rebindable constructs]).
+ This is needed to accept programs such as
+
+ data R b = MkR { f :: (forall a. a -> a) -> (Int,b), c :: Int }
+ foo r = r { f = \ k -> (k 3, k 'x') }
+
+ in which an updated field has a higher-rank type.
+ See Wrinkle [Using IdSig] in Note [Record Updates] in GHC.Tc.Gen.Expr.
+
* HsDo: We expand `HsDo` statements in `Ghc.Tc.Gen.Do`.
@@ -188,8 +215,22 @@ but several have a little bit of special treatment:
(return (f x))))
See Note [Expanding HsDo with XXExprGhcRn] in `Ghc.Tc.Gen.Do` for more details.
- To understand why is this done in the typechecker and not in the renamer.
- See Note [Doing XXExprGhcRn in the Renamer vs Typechecker]
+
+ - The expansion for do block statements is done on the fly right before typechecking
+ in `GHC.Tc.Gen.Expand.tcExpand` using `GHC.Tc.Gen.Do.expandDoStmts`.
+ There are 2 main reasons:
+
+ 1. During the renaming phase, we may not have all the constructor details `HsConDetails` populated in the
+ data structure. This would result in an inaccurate irrefutability analysis causing
+ the continuation lambda body to be wrapped with `fail` alternatives when not needed.
+ See Part 1. of Note [Expanding HsDo with XXExprGhcRn] (test pattern-fails.hs)
+
+ 2. If the expansion is done on the fly during renaming, expressions that
+ have explicit type applications using (-XTypeApplciations) will not work (cf. Let statements expansion)
+ as the name freshening happens from the root of the AST to the leaves,
+ but the expansion happens in the opposite direction (from leaves to the root),
+ causing the renamer to miss the scoped type variables.
+
Note [Overloaded labels]
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -209,66 +250,6 @@ type-applying to "foo", so we get
And those inferred kind quantifiers will indeed be instantiated when we
typecheck the renamed-syntax call (fromLabel @"foo").
-
-Note [Doing XXExprGhcRn in the Renamer vs Typechecker]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-We expand some `HsExpr GhcRn` code at various places, usually, on the fly,
-depending on when it is more convenient. It may be beneficial to have a
-separate `HsExpr GhcRn -> HsExpr GhcRn` pass that does this expansion uniformly
-in the future when we have enough cases to cater for. For the time being,
-this note documents which language feature is expanded at which phase,
-and the reasons for doing so.
-
- ** `HsIf` Expansions
- --------------------
- `HsIf` expansions are expanded in the Renamer becuase it is more convinent
- to do so there and then not worry about it in the later stage.
- `-XRebindableSyntax` is used to decide whether we use the `HsIf` or user defined if
-
-
- ** `OpApp` Expansions
- ---------------------
- The typechecker turns `OpApp` into a use of `XXExprGhcRn`
- on the fly, in `GHC.Tc.Gen.Head.splitHsApps`.
- The language extension `RebindableSyntax` does not affect this behaviour.
-
- It's a bit painful to transform `OpApp e1 op e2` to a `XXExprGhcRn`
- form, because the renamer does precedence rearrangement after name
- resolution. So the renamer leaves an `OpApp` as an `OpApp`.
-
- ** Record Update Syntax `RecordUpd` Expansions
- ----------------------------------------------
- This is done in the typechecker on the fly (`GHC.Tc.Expr.tcExpr`), and not the renamer, for two reasons:
-
- - (Until we implement GHC proposal #366)
- We need to know the type of the record to disambiguate its fields.
-
- - We use the type signature of the data constructor to provide `IdSigs`
- to the let-bound variables (x', y' in the example of
- Note [Handling overloaded and rebindable constructs] above).
- This is needed to accept programs such as
-
- data R b = MkR { f :: (forall a. a -> a) -> (Int,b), c :: Int }
- foo r = r { f = \ k -> (k 3, k 'x') }
-
- in which an updated field has a higher-rank type.
- See Wrinkle [Using IdSig] in Note [Record Updates] in GHC.Tc.Gen.Expr.
-
- ** `HsDo` Statement Expansions
- -----------------------------------
- The expansion for do block statements is done on the fly right before typechecking in `GHC.Tc.Gen.Expr`
- using `GHC.Tc.Gen.Do.expandDoStmts`. There are 2 main reasons:
-
- - During the renaming phase, we may not have all the constructor details `HsConDetails` populated in the
- data structure. This would result in an inaccurate irrefutability analysis causing
- the continuation lambda body to be wrapped with `fail` alternatives when not needed.
- See Part 1. of Note [Expanding HsDo with XXExprGhcRn] (test pattern-fails.hs)
-
- - If the expansion is done on the fly during renaming, expressions that
- have explicit type applications using (-XTypeApplciations) will not work (cf. Let statements expansion)
- as the name freshening happens from the root of the AST to the leaves,
- but the expansion happens in the opposite direction (from leaves to the root),
- causing the renamer to miss the scoped type variables.
-}
{-
@@ -345,12 +326,9 @@ rnExpr (HsHole h)
-- HsOverLabel: see Note [Handling overloaded and rebindable constructs]
rnExpr (HsOverLabel src v)
= do { (from_label, fvs) <- lookupSyntaxName fromLabelClassOpName
- ; return ( mkExpandedExpr (HsOverLabel src v) $
- HsAppType noExtField (genLHsVar from_label) hs_ty_arg
- , fvs ) }
- where
- hs_ty_arg = mkEmptyWildCardBndrs $ wrapGenSpan $
- HsTyLit noExtField (HsString NoSourceText v)
+ ; let rs_table = Rebindable [(nameOccName fromLabelClassOpName, from_label)]
+ ; return (HsOverLabel (src, rs_table) v, fvs)
+ }
rnExpr (HsLit x lit) | HsString src s <- lit
= do { opt_OverloadedStrings <- xoptM LangExt.OverloadedStrings
@@ -372,10 +350,12 @@ 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 ql_val' = case ql_val of
+ HsQualString st s -> HsQualString st s
+ ; return (HsQualLit x (QualLit (L noAnn funName) ql_mod ql_val'), fvs)
+ }
rnExpr (HsApp x fun arg)
= do { (fun',fvFun) <- rnLExpr fun
@@ -419,19 +399,15 @@ rnExpr (HsGetField _ e f)
= do { (getField, fv_getField) <- lookupSyntaxName getFieldName
; (e, fv_e) <- rnLExpr e
; let f' = rnDotFieldOcc <$> f
- ; return ( mkExpandedExpr
- (HsGetField noExtField e f')
- (mkGetField getField e (fmap (unLoc . dfoLabel) f'))
- , fv_e `plusFN` fv_getField ) }
+ rs_table = Rebindable [(nameOccName getFieldName, getField)]
+ ; return (HsGetField rs_table e f', fv_e `plusFN` fv_getField) }
rnExpr (HsProjection _ fs)
- = do { (getField, fv_getField) <- lookupSyntaxName getFieldName
- ; circ <- lookupOccRn WL_TermVariable compose_RDR
+ = do { (getFieldName, fv_getField) <- lookupSyntaxName getFieldName
+ ; circName <- lookupOccRn WL_TermVariable compose_RDR
; let fs' = NE.map rnDotFieldOcc fs
- ; return ( mkExpandedExpr
- (HsProjection noExtField fs')
- (mkProjection getField circ $ NE.map (unLoc . dfoLabel) fs')
- , unitFN circ `plusFN` fv_getField) }
+ rs_table = Rebindable [(nameOccName getFieldName , getFieldName), (rdrNameOcc compose_RDR, circName)]
+ ; return (HsProjection rs_table fs', unitFN circName `plusFN` fv_getField) }
------------------------------------------
-- Template Haskell extensions
@@ -494,15 +470,12 @@ rnExpr (ExplicitList _ exps)
= do { (exps', fvs) <- rnExprs exps
; opt_OverloadedLists <- xoptM LangExt.OverloadedLists
; if not opt_OverloadedLists
- then return (ExplicitList noExtField exps', fvs)
+ then return (ExplicitList NoRebindable exps', fvs)
else
do { (from_list_n_name, fvs') <- lookupSyntaxName fromListNName
- ; loc <- getSrcSpanM -- See Note [Source locations for implicit function calls]
- ; let rn_list = ExplicitList noExtField exps'
- lit_n = mkIntegralLit (length exps)
- hs_lit = genHsIntegralLit lit_n
- exp_list = genHsApps' (wrapGenSpan' loc from_list_n_name) [hs_lit, wrapGenSpan rn_list]
- ; return ( mkExpandedExpr rn_list exp_list
+ ; let rs_table = Rebindable [(nameOccName fromListNName, from_list_n_name)]
+ rn_list = ExplicitList rs_table exps'
+ ; return ( rn_list
, fvs `plusFN` fvs') } }
rnExpr (ExplicitTuple _ tup_args boxity)
@@ -546,7 +519,7 @@ rnExpr (RecordUpd { rupd_expr = L l expr, rupd_flds = rbinds })
RegularRecUpdFields
{ xRecUpdFields = parents
, recUpdFields = flds }
- ; return ( RecordUpd noExtField (L l e) upd_flds
+ ; return ( RecordUpd NoRebindable (L l e) upd_flds
, fv_e `plusFN` fv_flds ) }
-- 'OverloadedRecordUpdate' is in effect. Record dot update desugaring.
@@ -561,13 +534,13 @@ rnExpr (RecordUpd { rupd_expr = L l expr, rupd_flds = rbinds })
; (setField, fv_setField) <- lookupSyntaxName setFieldName
; (e, fv_e) <- rnExpr expr
; (us, fv_us) <- rnHsUpdProjs flds
- ; let upd_flds = OverloadedRecUpdFields
+ ; let upd_flds = OverloadedRecUpdFields
{ xOLRecUpdFields = noExtField
, olRecUpdFields = us }
- ; return ( mkExpandedExpr
- (RecordUpd noExtField (L l e) upd_flds)
- (mkRecordDotUpd getField setField (L l e) us)
- , plusFNs [fv_getField, fv_setField, fv_e, fv_us] ) }
+ rs_table = Rebindable [(nameOccName getField, getField) , (nameOccName setField, setField)]
+ ; return (RecordUpd rs_table (L l e) upd_flds
+ , plusFNs [fv_getField, fv_setField, fv_e, fv_us] )
+ }
rnExpr (ExprWithTySig _ expr pty)
@@ -632,6 +605,12 @@ rnExpr (HsFunArr _ mult arg res)
_ -> False
oneType = noLocA $ HsVar noExtField $ noLocA $ noUserRdr oneDataConName
+rnExpr (XExpr (ReSynBinds m e'))
+ = do { traceRn "XExpr ReSynBinds" (text "module:" <+> ppr m)
+ ; rnExpr e' -- for now just return the renamed expression
+ -- TODO: Bring into scope top level environment of the module m
+ }
+
{-
************************************************************************
* *
@@ -717,155 +696,20 @@ rnSection :: HsExpr GhcPs -> RnM (HsExpr GhcRn, FreeNames)
-- Also see Note [Handling overloaded and rebindable constructs]
rnSection section@(SectionR x op expr)
- -- See Note [Left and right sections]
= 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)
-{- Note [Left and right sections]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Dealing with left sections (x *) and right sections (* x) is
-surprisingly fiddly. We expand like this
- (`op` e) ==> rightSection op e
- (e `op`) ==> leftSection (op e)
-
-Using an auxiliary function in this way avoids the awkwardness of
-generating a lambda, esp if `e` is a redex, so we *don't* want
-to generate `(\x -> op x e)`. See Historical
-Note [Desugaring operator sections]
-
-Here are their definitions:
- leftSection :: forall r1 r2 n (a::TYPE r1) (b::TYPE r2).
- (a %n-> b) -> a %n-> b
- leftSection f x = f x
-
- rightSection :: forall r1 r2 r3 n1 n2 (a::TYPE r1) (b::TYPE r2) (c::TYPE r3).
- (a %n1 -> b %n2-> c) -> b %n2-> a %n1-> c
- rightSection f y x = f x y
-
-Note the wrinkles:
-
-* We do /not/ use lookupSyntaxName, which would make left and right
- section fall under RebindableSyntax. Reason: it would be a user-
- facing change, and there are some tricky design choices (#19354).
- Plus, infix operator applications would be trickier to make
- rebindable, so it'd be inconsistent to do so for sections.
-
- TL;DR: we still use the renamer-expansion mechanism for operator
- sections, but only to eliminate special-purpose code paths in the
- renamer and desugarer.
-
-* leftSection and rightSection must be representation-polymorphic, to allow
- (+# 4#) and (4# +#) to work. See
- Note [Wired-in Ids for rebindable syntax] in GHC.Types.Id.Make.
-
-* leftSection and rightSection must be multiplicity-polymorphic.
- (Test linear/should_compile/OldList showed this up.)
-
-* Because they are representation-polymorphic, we have to define them
- as wired-in Ids, with compulsory inlining. See
- GHC.Types.Id.Make.leftSectionId, rightSectionId.
-
-* leftSection is just ($) really; but unlike ($) it is
- representation-polymorphic in the result type, so we can write
- `(x +#)`, say.
-
-* The type of leftSection must have an arrow in its first argument,
- because (x `ord`) should be rejected, because ord does not take two
- arguments
-
-* It's important that we define leftSection in an eta-expanded way,
- (i.e. not leftSection f = f), so that
- (True `undefined`) `seq` ()
- = (leftSection (undefined True) `seq` ())
- evaluates to () and not undefined
-
-* If PostfixOperators is ON, then we expand a left section like this:
- (e `op`) ==> op e
- with no auxiliary function at all. Simple!
-
-* leftSection and rightSection switch on ImpredicativeTypes locally,
- during Quick Look; see GHC.Tc.Gen.App.wantQuickLook. Consider
- test DeepSubsumption08:
- type Setter st t a b = forall f. Identical f => blah
- (.~) :: Setter s t a b -> b -> s -> t
- clear :: Setter a a' b (Maybe b') -> a -> a'
- clear = (.~ Nothing)
- The expansion look like (rightSection (.~) Nothing). So we must
- instantiate `rightSection` first type argument to a polytype!
- Hence the special magic in App.wantQuickLook.
-
-Historical Note [Desugaring operator sections]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-This Note explains some historical trickiness in desugaring left and
-right sections. That trickiness has completely disappeared now that
-we desugar to calls to 'leftSection` and `rightSection`, but I'm
-leaving it here to remind us how nice the new story is.
-
-Desugaring left sections with -XPostfixOperators is straightforward: convert
-(expr `op`) to (op expr).
-
-Without -XPostfixOperators it's a bit more tricky. At first it looks as if we
-can convert
-
- (expr `op`)
-
-naively to
-
- \x -> op expr x
-
-But no! expr might be a redex, and we can lose laziness badly this
-way. Consider
-
- map (expr `op`) xs
-
-for example. If expr were a redex then eta-expanding naively would
-result in multiple evaluations where the user might only have expected one.
-
-So we convert instead to
-
- let y = expr in \x -> op y x
-
-Also, note that we must do this for both right and (perhaps surprisingly) left
-sections. Why are left sections necessary? Consider the program (found in #18151),
-
- seq (True `undefined`) ()
-
-according to the Haskell Report this should reduce to () (as it specifies
-desugaring via eta expansion). However, if we fail to eta expand we will rather
-bottom. Consequently, we must eta expand even in the case of a left section.
-
-If `expr` is actually just a variable, say, then the simplifier
-will inline `y`, eliminating the redundant `let`.
-
-Note that this works even in the case that `expr` is unlifted. In this case
-bindNonRec will automatically do the right thing, giving us:
-
- case expr of y -> (\x -> op y x)
-
-See #18151.
-
+{-
Note [Reporting unbound names]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Faced with an out-of-scope `RdrName` there are two courses of action
@@ -2839,77 +2683,16 @@ rnHsIf p b1 b2
; (b1', fvB1) <- rnLExpr b1
; (b2', fvB2) <- rnLExpr b2
; let fvs_if = plusFNs [fvP, fvB1, fvB2]
- rn_if = HsIf noExtField p' b1' b2'
-
-- Deal with rebindable syntax
; mb_ite <- lookupIfThenElse
; case mb_ite of
Nothing -- Non rebindable-syntax case
- -> return (rn_if, fvs_if)
+ -> return (HsIf NoRebindable p' b1' b2', fvs_if)
Just ite_name -- Rebindable-syntax case
- -> do { let ds_if = genHsApps ite_name [p', b1', b2']
- fvs = plusFNs [fvs_if, unitFN ite_name]
- ; return (mkExpandedExpr rn_if ds_if, fvs) } }
+ -> do { let fvs = plusFNs [fvs_if, unitFN ite_name]
+ ; return (HsIf (Rebindable [(rdrNameOcc $ mkVarUnqual (fsLit "ifThenElse"), ite_name)]) p' b1' b2', fvs) } }
------------------------------------------
--- Bits and pieces for RecordDotSyntax.
---
--- See Note [Overview of record dot syntax] in GHC.Hs.Expr.
-
--- mkGetField arg field calculates a get_field @field arg expression.
--- e.g. z.x = mkGetField z x = get_field @x z
-mkGetField :: Name -> LHsExpr GhcRn -> LocatedAn NoEpAnns FieldLabelString -> HsExpr GhcRn
-mkGetField get_field arg field = unLoc (head $ mkGet get_field (arg :| []) field)
-
--- mkSetField a field b calculates a set_field @field expression.
--- e.g mkSetSetField a field b = set_field @"field" a b (read as "set field 'field' to a on b").
--- NB: the order of aruments is specified by GHC Proposal 583: HasField redesign.
-mkSetField :: Name -> LHsExpr GhcRn -> LocatedAn NoEpAnns FieldLabelString -> LHsExpr GhcRn -> HsExpr GhcRn
-mkSetField set_field a (L _ (FieldLabelString field)) b =
- genHsApp (genHsApp (genHsVar set_field `genAppType` genHsTyLit field) b) a
-
-mkGet :: Name -> NonEmpty (LHsExpr GhcRn) -> LocatedAn NoEpAnns FieldLabelString -> NonEmpty (LHsExpr GhcRn)
-mkGet get_field l@(r :| _) (L _ (FieldLabelString field)) =
- wrapGenSpan (genHsApp (genHsVar get_field `genAppType` genHsTyLit field) r) NE.<| l
-
-mkSet :: Name -> LHsExpr GhcRn -> (LocatedAn NoEpAnns FieldLabelString, LHsExpr GhcRn) -> LHsExpr GhcRn
-mkSet set_field acc (field, g) = wrapGenSpan (mkSetField set_field g field acc)
-
--- mkProjection fields calculates a projection.
--- e.g. .x = mkProjection [x] = getField @"x"
--- .x.y = mkProjection [.x, .y] = (.y) . (.x) = getField @"y" . getField @"x"
-mkProjection :: Name -> Name -> NonEmpty FieldLabelString -> HsExpr GhcRn
-mkProjection getFieldName circName (field :| fields) = foldl' f (proj field) fields
- where
- f :: HsExpr GhcRn -> FieldLabelString -> HsExpr GhcRn
- f acc field = genHsApps circName $ map wrapGenSpan [proj field, acc]
-
- proj :: FieldLabelString -> HsExpr GhcRn
- proj (FieldLabelString f) = genHsVar getFieldName `genAppType` genHsTyLit f
-
--- mkProjUpdateSetField calculates functions representing dot notation record updates.
--- e.g. Suppose an update like foo.bar = 1.
--- We calculate the function \a -> setField @"foo" a (setField @"bar" (getField @"foo" a) 1).
-mkProjUpdateSetField :: Name -> Name -> LHsRecProj GhcRn (LHsExpr GhcRn) -> (LHsExpr GhcRn -> LHsExpr GhcRn)
-mkProjUpdateSetField get_field set_field (L _ (HsFieldBind { hfbLHS = (L _ (FieldLabelStrings flds')), hfbRHS = arg } ))
- = let {
- ; flds = NE.map (fmap (unLoc . dfoLabel)) flds'
- ; final = last flds -- quux
- ; fields = init flds -- [foo, bar, baz]
- ; getters = \a -> foldl' (mkGet get_field) (a :| []) fields -- Ordered from deep to shallow.
- -- [getField@"baz"(getField@"bar"(getField@"foo" a), getField@"bar"(getField@"foo" a), getField@"foo" a, a]
- ; zips = \a -> (final, head (getters a)) : zip (reverse fields) (tail (getters a)) -- Ordered from deep to shallow.
- -- [("quux", getField@"baz"(getField@"bar"(getField@"foo" a)), ("baz", getField@"bar"(getField@"foo" a)), ("bar", getField@"foo" a), ("foo", a)]
- }
- in (\a -> foldl' (mkSet set_field) arg (zips a))
- -- setField@"foo" (a) (setField@"bar" (getField @"foo" (a))(setField@"baz" (getField @"bar" (getField @"foo" (a)))(setField@"quux" (getField @"baz" (getField @"bar" (getField @"foo" (a))))(quux))))
-
-mkRecordDotUpd :: Name -> Name -> LHsExpr GhcRn -> [LHsRecUpdProj GhcRn] -> HsExpr GhcRn
-mkRecordDotUpd get_field set_field exp updates = foldl' fieldUpdate (unLoc exp) updates
- where
- fieldUpdate :: HsExpr GhcRn -> LHsRecUpdProj GhcRn -> HsExpr GhcRn
- fieldUpdate acc lpu = unLoc $ (mkProjUpdateSetField get_field set_field lpu) (wrapGenSpan acc)
rnHsUpdProjs :: [LHsRecUpdProj GhcPs] -> RnM ([LHsRecUpdProj GhcRn], FreeNames)
rnHsUpdProjs us = do
=====================================
compiler/GHC/Rename/Splice.hs
=====================================
@@ -141,9 +141,8 @@ rnTypedBracket e br_body
; recordThUse
; traceRn "Renaming typed TH bracket" empty
- ; (body', fvs_e) <- setThLevel (Brack cur_level RnPendingTyped) $ rnLExpr br_body
- ; return (HsTypedBracket noExtField body', fvs_e)
-
+ ; (body, fvs_e) <- setThLevel (Brack cur_level RnPendingTyped) $ rnLExpr br_body
+ ; return (HsTypedBracket noExtField body, fvs_e)
}
rnUntypedBracket :: HsExpr GhcPs -> HsQuote GhcPs -> RnM (HsExpr GhcRn, FreeNames)
@@ -176,6 +175,7 @@ rnUntypedBracket e br_body
setThLevel (UntypedBrack cur_level ps_var) $
rn_utbracket br_body
; pendings <- readMutVar ps_var
+
; return (HsUntypedBracket pendings body', fvs_e)
}
@@ -613,6 +613,13 @@ problems, but keeps it on while processing typed TH quotes.
This note and approach originated in #18102.
+The MR!15868 (#27156) moved all the expansion/rebindable syntax (RS) mechanism into its own pass,
+done after renaming and right before typechecking.
+Before this patch, only some constructs (if then else, overloaded labels) were
+expanded in the renamer, but some (Do statements and record updates) were done after
+the renamer. This meant that the treatment of rebindable syntax and typed template haskell was
+not uniform across constructs. The MR!15868 makes the treatement of RS uniform for all constructs.
+
-}
{- Note [Delaying modFinalizers in untyped splices]
=====================================
compiler/GHC/Tc/Gen/Do.hs
=====================================
@@ -238,9 +238,6 @@ See Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr
To disabmiguate desugaring (`HsExpr GhcTc -> Core.Expr`) we use the phrase expansion
(`HsExpr GhcRn -> HsExpr GhcRn`)
-This expansion is done after renaming and before typechecking
-See Part 2. of Note [Doing XXExprGhcRn in the Renamer vs Typechecker] in `GHC.Rename.Expr`
-
Historical note START
---------------------
In previous versions of GHC, the `do`-notation wasn't expanded before typechecking,
=====================================
compiler/GHC/Tc/Gen/Expand.hs
=====================================
@@ -7,17 +7,34 @@
module GHC.Tc.Gen.Expand( tcExpand ) where
-import GHC.Prelude
-
-import {-# SOURCE #-} GHC.Tc.Gen.Splice( getUntypedSpliceBody )
+import GHC.Prelude hiding (last, init, tail)
+import GHC.Data.FastString
import GHC.Hs
import GHC.Tc.Utils.Monad
import GHC.Tc.Types.ErrCtxt
+import GHC.Tc.Gen.Do
+import {-# SOURCE #-} GHC.Tc.Gen.Splice( getUntypedSpliceBody )
+
+import GHC.Types.Name
+import GHC.Types.Name.Reader
+import GHC.Types.Id.Make
+import GHC.Types.SrcLoc
+import GHC.Types.SourceText ( SourceText(..) )
+
+import GHC.Builtin.Names
import GHC.Rename.Utils
+import GHC.Utils.Panic
+import GHC.Utils.Outputable
+
+import qualified Data.List.NonEmpty as NE ( map, head, (<|) )
+import Data.List.NonEmpty ( NonEmpty(..), init, last, tail )
+
+import qualified GHC.LanguageExtensions as LangExt
+
{- Note [Typechecking by expansion: overview]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For many constructs, rather than typechecking the user-written code
@@ -32,12 +49,11 @@ Example: Typechecking the do expression. The typechecker looks (somewhat) like t
The `expandDoStmts` replaces the HsDo { x <- e1; return x }
with something like
- HSE { hse_ctxt = ExprCtxt e
+ HSE { hse_ctxt = ExprCtxt (HsDo { x <- e1; return x })
, hse_exp = e1 >>= \ x -> x }
and we then typecheck the expression `e1 >>= \ x -> x`
See also Note [Handling overloaded and rebindable constructs]
- and Note [Doing XXExprGhcRn in the Renamer vs Typechecker]
and Note [Rebindable syntax and XXExprGhcRn]
The Big Question is how to ensure that error messages mention
@@ -101,8 +117,39 @@ Wrinkle (TBE1)
-}
----------------
+-- See Note [Typechecking by expansion: overview]
tcExpand :: HsExpr GhcRn -> TcM (Maybe (HsExpansion GhcRn))
+
+------------------------------------------
+-- Overloaded labels
+tcExpand e@(HsOverLabel (_, Rebindable rs_table) v)
+ | Just fromLabelName <- lookup (nameOccName fromLabelClassOpName) rs_table
+ , let hs_ty_arg = mkEmptyWildCardBndrs $ wrapGenSpan $
+ HsTyLit noExtField (HsString NoSourceText v)
+ = return $ Just $
+ HSE { hse_ctxt = ExprCtxt e
+ , hse_exp = wrapGenSpan $ HsAppType noExtField (genLHsVar fromLabelName) hs_ty_arg
+ }
+
+ | 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)
= return $ Just $
HSE { hse_ctxt = ExprCtxt e
@@ -110,14 +157,327 @@ tcExpand e@(OpApp _ arg1 op arg2)
where
ap f a = wrapGenSpan (HsApp noExtField f a)
-tcExpand (XExpr (ExpandedThingRn hse))
- = return (Just hse)
+------------------------------------------
+-- If
+
+-- NoRebindable <=> rebindable is turned off
+-- so we typecheck the HsIf in tcExprNoExpand
+tcExpand (HsIf NoRebindable _ _ _ )
+ = return Nothing
+tcExpand e@(HsIf (Rebindable rs_table) p b1 b2)
+ | Just ifThenElseName <- lookup (rdrNameOcc $ mkVarUnqual (fsLit "ifThenElse")) rs_table
+ = return $ Just $
+ HSE { hse_ctxt = ExprCtxt e
+ , hse_exp = wrapGenSpan $ genHsApps ifThenElseName [p, b1, b2]
+ }
+ | otherwise
+ = pprPanic "tcExpand" (vcat [ text "Should Never Happen: could not find ifThenElse in rs_table"
+ , ppr e ])
+
+------------------------------------------
+-- Record dot syntax
+
+tcExpand e@(HsGetField (Rebindable rs_table) expr f)
+ | Just getField <- lookup (nameOccName getFieldName) rs_table
+ = return $ Just $
+ HSE { hse_ctxt = ExprCtxt e
+ , hse_exp = wrapGenSpan $ (mkGetField getField expr (fmap (unLoc . dfoLabel) f)) }
+ | otherwise
+ = pprPanic "tcExpand" (vcat [ text "Should Never Happen: could not find getField in rs_table"
+ , ppr e ])
+
+tcExpand e@(HsProjection (Rebindable rs_table) fs)
+ | Just getField <- lookup (nameOccName getFieldName) rs_table
+ , Just circ <- lookup (rdrNameOcc compose_RDR) rs_table
+ = return $ Just $
+ HSE { hse_ctxt = ExprCtxt e
+ , hse_exp = wrapGenSpan $ (mkProjection getField circ $ NE.map (unLoc . dfoLabel) fs) }
+ | otherwise
+ = pprPanic "tcExpand" (vcat [ text "Should Never Happen: could not find getField or circ in rs_table"
+ , ppr e])
+
+
+tcExpand (RecordUpd NoRebindable _ _ ) = return Nothing -- until #27160 is fixed
+
+tcExpand e@(RecordUpd (Rebindable rs_table) (L l expr) (OverloadedRecUpdFields { olRecUpdFields = us}))
+ | Just getField <- lookup (nameOccName getFieldName) rs_table
+ , Just setField <- lookup (nameOccName setFieldName) rs_table
+ = return $ Just $
+ HSE { hse_ctxt = ExprCtxt e
+ , hse_exp = wrapGenSpan $ mkRecordDotUpd getField setField (L l expr) us }
+ | otherwise
+ = pprPanic "tcExpand" (vcat [ text "Should Never Happen: could not find getField or setfield in rs_table"
+ , ppr e ])
+
+------------------------------------------
+-- Left and Right Sections
+
+tcExpand e@(SectionR _ op expr)
+ -- See Note [Left and right sections]
+ = return $ Just $
+ HSE { hse_ctxt = ExprCtxt e
+ , hse_exp = wrapGenSpan $ genHsApps rightSectionName [op, expr] }
+
+tcExpand e@(SectionL _ expr op)
+ -- Note [Left and right sections]
+ = do { postfix_ops <- xoptM LangExt.PostfixOperators
+ ; 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 } }
+
+------------------------------------------
+-- Explicit Lists
+
+tcExpand (ExplicitList NoRebindable _ )
+ = return Nothing -- rebindable syntax is off
+tcExpand e@(ExplicitList (Rebindable rs_table) exps)
+ | Just from_list_n_name <- lookup (nameOccName fromListNName) rs_table
+ = do { loc <- getSrcSpanM -- See Note [Source locations for implicit function calls]
+ ; let lit_n = mkIntegralLit (length exps)
+ hs_lit = genHsIntegralLit lit_n
+ exp_list = genHsApps' (wrapGenSpan' loc from_list_n_name)
+ [hs_lit, wrapGenSpan (ExplicitList NoRebindable exps)]
+ -- important to make it NoRebindable
+ -- Or we will go into an infinite loop
+ ; return $ Just $
+ HSE { hse_ctxt = ExprCtxt e
+ , hse_exp = wrapGenSpan $ exp_list }
+ }
+ | otherwise
+ = pprPanic "tcExpand" (vcat [text "Should Never Happen: could not find fromListN in rs_table"
+ , ppr e] )
+
+
+------------------------------------------
+-- Do statements
+
+tcExpand (HsDo _ do_or_lc stmts)
+ | DoExpr{} <- do_or_lc
+ -- ApplicativeDo are typechecked using tcDoStmts
+ = do isApplicativeDo <- xoptM LangExt.ApplicativeDo
+ if isApplicativeDo
+ 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
+ ; return (Just hse) }
+ | MDoExpr{} <- do_or_lc
+ = do hse <- expandDoStmts do_or_lc stmts
+ return (Just hse)
+ | otherwise
+ -- ListComp and MonadComp are handled by legacy tcDoStmts for now,
+ -- The ultimate goal is to handle them via expandDoStmts.
+ -- GHCiStmts are handled completely separate
+ = return Nothing
+
+------------------------------------------
+-- Template Haskell Splices
tcExpand e@(HsUntypedSplice splice_res _)
-- See Note [Looking through Template Haskell splices in splitHsApps]
= do { fun <- getUntypedSpliceBody splice_res
; return $ Just $
- HSE { hse_ctxt = ExprCtxt e
- , hse_exp = wrapGenSpan fun } }
+ HSE { hse_ctxt = ExprCtxt e
+ , hse_exp = wrapGenSpan fun }
+ }
+
+------------------------
+-- XExpr
+-- Expansions are idempotent, XExprs do not expand again
+tcExpand (XExpr (ExpandedThingRn hse))
+ = return $ Just hse
+
+tcExpand _ = return $ Nothing
+
-tcExpand _ = return Nothing
+
+{- Note [Left and right sections]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Dealing with left sections (x *) and right sections (* x) is
+surprisingly fiddly. We expand like this
+ (`op` e) ==> rightSection op e
+ (e `op`) ==> leftSection (op e)
+
+Using an auxiliary function in this way avoids the awkwardness of
+generating a lambda, esp if `e` is a redex, so we *don't* want
+to generate `(\x -> op x e)`. See Historical
+Note [Desugaring operator sections]
+
+Here are their definitions:
+ leftSection :: forall r1 r2 n (a::TYPE r1) (b::TYPE r2).
+ (a %n-> b) -> a %n-> b
+ leftSection f x = f x
+
+ rightSection :: forall r1 r2 r3 n1 n2 (a::TYPE r1) (b::TYPE r2) (c::TYPE r3).
+ (a %n1 -> b %n2-> c) -> b %n2-> a %n1-> c
+ rightSection f y x = f x y
+
+Note the wrinkles:
+
+* We do /not/ use lookupSyntaxName, which would make left and right
+ section fall under RebindableSyntax. Reason: it would be a user-
+ facing change, and there are some tricky design choices (#19354).
+ Plus, infix operator applications would be trickier to make
+ rebindable, so it'd be inconsistent to do so for sections.
+
+ TL;DR: we still use the renamer-expansion mechanism for operator
+ sections, but only to eliminate special-purpose code paths in the
+ renamer and desugarer.
+
+* leftSection and rightSection must be representation-polymorphic, to allow
+ (+# 4#) and (4# +#) to work. See
+ Note [Wired-in Ids for rebindable syntax] in GHC.Types.Id.Make.
+
+* leftSection and rightSection must be multiplicity-polymorphic.
+ (Test linear/should_compile/OldList showed this up.)
+
+* Because they are representation-polymorphic, we have to define them
+ as wired-in Ids, with compulsory inlining. See
+ GHC.Types.Id.Make.leftSectionId, rightSectionId.
+
+* leftSection is just ($) really; but unlike ($) it is
+ representation-polymorphic in the result type, so we can write
+ `(x +#)`, say.
+
+* The type of leftSection must have an arrow in its first argument,
+ because (x `ord`) should be rejected, because ord does not take two
+ arguments
+
+* It's important that we define leftSection in an eta-expanded way,
+ (i.e. not leftSection f = f), so that
+ (True `undefined`) `seq` ()
+ = (leftSection (undefined True) `seq` ())
+ evaluates to () and not undefined
+
+* If PostfixOperators is ON, then we expand a left section like this:
+ (e `op`) ==> op e
+ with no auxiliary function at all. Simple!
+
+* leftSection and rightSection switch on ImpredicativeTypes locally,
+ during Quick Look; see GHC.Tc.Gen.App.wantQuickLook. Consider
+ test DeepSubsumption08:
+ type Setter st t a b = forall f. Identical f => blah
+ (.~) :: Setter s t a b -> b -> s -> t
+ clear :: Setter a a' b (Maybe b') -> a -> a'
+ clear = (.~ Nothing)
+ The expansion look like (rightSection (.~) Nothing). So we must
+ instantiate `rightSection` first type argument to a polytype!
+ Hence the special magic in App.wantQuickLook.
+
+Historical Note [Desugaring operator sections]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+This Note explains some historical trickiness in desugaring left and
+right sections. That trickiness has completely disappeared now that
+we desugar to calls to 'leftSection` and `rightSection`, but I'm
+leaving it here to remind us how nice the new story is.
+
+Desugaring left sections with -XPostfixOperators is straightforward: convert
+(expr `op`) to (op expr).
+
+Without -XPostfixOperators it's a bit more tricky. At first it looks as if we
+can convert
+
+ (expr `op`)
+
+naively to
+
+ \x -> op expr x
+
+But no! expr might be a redex, and we can lose laziness badly this
+way. Consider
+
+ map (expr `op`) xs
+
+for example. If expr were a redex then eta-expanding naively would
+result in multiple evaluations where the user might only have expected one.
+
+So we convert instead to
+
+ let y = expr in \x -> op y x
+
+Also, note that we must do this for both right and (perhaps surprisingly) left
+sections. Why are left sections necessary? Consider the program (found in #18151),
+
+ seq (True `undefined`) ()
+
+according to the Haskell Report this should reduce to () (as it specifies
+desugaring via eta expansion). However, if we fail to eta expand we will rather
+bottom. Consequently, we must eta expand even in the case of a left section.
+
+If `expr` is actually just a variable, say, then the simplifier
+will inline `y`, eliminating the redundant `let`.
+
+Note that this works even in the case that `expr` is unlifted. In this case
+bindNonRec will automatically do the right thing, giving us:
+
+ case expr of y -> (\x -> op y x)
+
+See #18151.
+-}
+
+
+
+
+
+-----------------------------------------
+-- Bits and pieces for RecordDotSyntax.
+--
+-- See Note [Overview of record dot syntax] in GHC.Hs.Expr.
+
+-- mkGetField arg field calculates a get_field @field arg expression.
+-- e.g. z.x = mkGetField z x = get_field @x z
+mkGetField :: Name -> LHsExpr GhcRn -> LocatedAn NoEpAnns FieldLabelString -> HsExpr GhcRn
+mkGetField get_field arg field = unLoc (NE.head $ mkGet get_field (arg :| []) field)
+
+-- mkSetField a field b calculates a set_field @field expression.
+-- e.g mkSetSetField a field b = set_field @"field" a b (read as "set field 'field' to a on b").
+-- NB: the order of aruments is specified by GHC Proposal 583: HasField redesign.
+mkSetField :: Name -> LHsExpr GhcRn -> LocatedAn NoEpAnns FieldLabelString -> LHsExpr GhcRn -> HsExpr GhcRn
+mkSetField set_field a (L _ (FieldLabelString field)) b =
+ genHsApp (genHsApp (genHsVar set_field `genAppType` genHsTyLit field) b) a
+
+mkGet :: Name -> NonEmpty (LHsExpr GhcRn) -> LocatedAn NoEpAnns FieldLabelString -> NonEmpty (LHsExpr GhcRn)
+mkGet get_field l@(r :| _) (L _ (FieldLabelString field)) =
+ wrapGenSpan (genHsApp (genHsVar get_field `genAppType` genHsTyLit field) r) NE.<| l
+
+mkSet :: Name -> LHsExpr GhcRn -> (LocatedAn NoEpAnns FieldLabelString, LHsExpr GhcRn) -> LHsExpr GhcRn
+mkSet set_field acc (field, g) = wrapGenSpan (mkSetField set_field g field acc)
+
+-- mkProjection fields calculates a projection.
+-- e.g. .x = mkProjection [x] = getField @"x"
+-- .x.y = mkProjection [.x, .y] = (.y) . (.x) = getField @"y" . getField @"x"
+mkProjection :: Name -> Name -> NonEmpty FieldLabelString -> HsExpr GhcRn
+mkProjection getFieldName circName (field :| fields) = foldl' f (proj field) fields
+ where
+ f :: HsExpr GhcRn -> FieldLabelString -> HsExpr GhcRn
+ f acc field = genHsApps circName $ map wrapGenSpan [proj field, acc]
+
+ proj :: FieldLabelString -> HsExpr GhcRn
+ proj (FieldLabelString f) = genHsVar getFieldName `genAppType` genHsTyLit f
+
+-- mkProjUpdateSetField calculates functions representing dot notation record updates.
+-- e.g. Suppose an update like foo.bar = 1.
+-- We calculate the function \a -> setField @"foo" a (setField @"bar" (getField @"foo" a) 1).
+mkProjUpdateSetField :: Name -> Name -> LHsRecProj GhcRn (LHsExpr GhcRn) -> (LHsExpr GhcRn -> LHsExpr GhcRn)
+mkProjUpdateSetField get_field set_field (L _ (HsFieldBind { hfbLHS = (L _ (FieldLabelStrings flds')), hfbRHS = arg } ))
+ = let {
+ ; flds = NE.map (fmap (unLoc . dfoLabel)) flds'
+ ; final = last flds -- quux
+ ; fields = init flds -- [foo, bar, baz]
+ ; getters = \a -> foldl' (mkGet get_field) (a :| []) fields -- Ordered from deep to shallow.
+ -- [getField@"baz"(getField@"bar"(getField@"foo" a), getField@"bar"(getField@"foo" a), getField@"foo" a, a]
+ ; zips = \a -> (final, NE.head (getters a)) : zip (reverse fields) (tail (getters a)) -- Ordered from deep to shallow.
+ -- [("quux", getField@"baz"(getField@"bar"(getField@"foo" a)), ("baz", getField@"bar"(getField@"foo" a)), ("bar", getField@"foo" a), ("foo", a)]
+ }
+ in (\a -> foldl' (mkSet set_field) arg (zips a))
+ -- setField@"foo" (a) (setField@"bar" (getField @"foo" (a))(setField@"baz" (getField @"bar" (getField @"foo" (a)))(setField@"quux" (getField @"baz" (getField @"bar" (getField @"foo" (a))))(quux))))
+
+mkRecordDotUpd :: Name -> Name -> LHsExpr GhcRn -> [LHsRecUpdProj GhcRn] -> HsExpr GhcRn
+mkRecordDotUpd get_field set_field exp updates = foldl' fieldUpdate (unLoc exp) updates
+ where
+ fieldUpdate :: HsExpr GhcRn -> LHsRecUpdProj GhcRn -> HsExpr GhcRn
+ fieldUpdate acc lpu = unLoc $ (mkProjUpdateSetField get_field set_field lpu) (wrapGenSpan acc)
=====================================
compiler/GHC/Tc/Gen/Expr.hs
=====================================
@@ -36,7 +36,6 @@ import GHC.Rename.Env ( addUsedGRE, getUpdFieldLbls )
import GHC.Tc.Gen.Expand( tcExpand )
import GHC.Tc.Gen.App
import GHC.Tc.Gen.Head
-import GHC.Tc.Gen.Do
import GHC.Tc.Gen.Bind ( tcLocalBinds )
import GHC.Tc.Gen.HsType
import GHC.Tc.Gen.Arrow
@@ -94,8 +93,6 @@ import GHC.Data.FastString (fastStringToShortText)
import Control.Monad
import qualified Data.List.NonEmpty as NE
-import qualified GHC.LanguageExtensions as LangExt
-
{-
************************************************************************
* *
@@ -299,11 +296,19 @@ tcCollectApp the_app res_ty
; tcApp the_app fun args res_ty }
---------------
-tcExpr :: HsExpr GhcRn
+tcExpr, tcExprNoExpand :: HsExpr GhcRn
-> ExpRhoType -- DeepSubsumption <=> when checking, this type
-- is deeply skolemised
-> TcM (HsExpr GhcTc)
+tcExpr e res_ty
+-- See Note [Typechecking by expansion: overview]
+ = do { mb_hse <- tcExpand e
+ ; case mb_hse of
+ Just hse -> tcHsExpansion hse res_ty
+ Nothing -> tcExprNoExpand e res_ty }
+
+
-- Use tcApp to typecheck applications, which are treated specially
-- by Quick Look. Specifically:
-- - HsVar lone variables, to ensure that they can get an
@@ -324,46 +329,46 @@ tcExpr :: HsExpr GhcRn
-- expression and try to break them up further
-- and then call tcApp on the maximal application chain.
-- See Note [Application chains and heads] in GHC.Tc.Gen.App
-tcExpr e@(HsVar {}) res_ty = tcApp e e [] res_ty
-tcExpr e@(ExprWithTySig {}) res_ty = tcApp e e [] res_ty
-tcExpr e@(XExpr (HsRecSelRn{})) res_ty = tcApp e e [] res_ty
-tcExpr e@(HsAppType {}) res_ty = tcCollectApp e res_ty
-tcExpr e@(HsApp {}) res_ty = tcCollectApp e res_ty
+tcExprNoExpand e@(HsVar {}) res_ty = tcApp e e [] res_ty
+tcExprNoExpand e@(ExprWithTySig {}) res_ty = tcApp e e [] res_ty
+tcExprNoExpand e@(XExpr (HsRecSelRn{})) res_ty = tcApp e e [] res_ty
+tcExprNoExpand e@(HsAppType {}) res_ty = tcCollectApp e res_ty
+tcExprNoExpand e@(HsApp {}) res_ty = tcCollectApp e res_ty
-- Typecheck an occurrence of an unbound Id
--
-- Some of these started life as a true expression hole "_".
-- Others might simply be variables that accidentally have no binding site.
-tcExpr (HsHole (HoleVar locc@(L _ occ))) res_ty
+tcExprNoExpand (HsHole (HoleVar locc@(L _ occ))) res_ty
= do { ty <- expTypeToType res_ty -- Allow Int# etc (#12531)
; her <- emitNewExprHole occ ty
; tcEmitBindingUsage bottomUE -- Holes fit any usage environment
-- (#18491)
; return (HsHole (HoleVar locc, her))
}
-tcExpr (HsHole HoleError) _ =
+tcExprNoExpand (HsHole HoleError) _ =
panic "GHC.Tc.Gen.Expr: tcExpr: HoleError: Not implemented"
-tcExpr e@(HsLit x lit) res_ty
+tcExprNoExpand e@(HsLit x lit) res_ty
= do { let lit_ty = hsLitType lit
; tcWrapResult e (HsLit x (convertLit lit)) lit_ty res_ty }
-tcExpr (HsPar x expr) res_ty
+tcExprNoExpand (HsPar x expr) res_ty
= do { expr' <- tcMonoLExprNC expr res_ty
; return (HsPar x expr') }
-tcExpr (HsPragE x prag expr) res_ty
+tcExprNoExpand (HsPragE x prag expr) res_ty
= do { expr' <- tcMonoLExpr expr res_ty
; return (HsPragE x (tcExprPrag prag) expr') }
-tcExpr (NegApp x expr neg_expr) res_ty
+tcExprNoExpand (NegApp x expr neg_expr) res_ty
= do { (expr', neg_expr')
<- tcSyntaxOp NegateOrigin neg_expr [SynAny] res_ty $
\[arg_ty] [arg_mult] ->
tcScalingUsage arg_mult $ tcCheckMonoExpr expr arg_ty
; return (NegApp x expr' neg_expr') }
-tcExpr e@(HsIPVar _ x) res_ty
+tcExprNoExpand e@(HsIPVar _ x) res_ty
= do { ip_ty <- newFlexiTyVarTy liftedTypeKind
-- Create a unification type variable of kind 'Type'.
-- (The type of an implicit parameter must have kind 'Type'.)
@@ -378,7 +383,7 @@ tcExpr e@(HsIPVar _ x) res_ty
(mkHsWrap wrap (mkHsVar (noLocA ip_op)))
ip_ty res_ty }
-tcExpr e@(HsLam x lam_variant matches) res_ty
+tcExprNoExpand e@(HsLam x lam_variant matches) res_ty
= do { (wrap, matches') <- tcLambdaMatches e lam_variant matches [] res_ty
; return (mkHsWrap wrap $ HsLam x lam_variant matches') }
@@ -390,7 +395,7 @@ tcExpr e@(HsLam x lam_variant matches) res_ty
************************************************************************
-}
-tcExpr e@(HsOverLit _ lit) res_ty
+tcExprNoExpand e@(HsOverLit _ lit) res_ty
= -- See Note [Typechecking overloaded literals]
do { mb_res <- tcShortCutLit lit res_ty
-- See Note [Short cut for overloaded literals] in GHC.Tc.Utils.TcMType
@@ -426,7 +431,7 @@ tricky:
We can only take this short-cut if rebindable syntax is off; see `tcShortCutLit`.
-}
-tcExpr e@HsQualLit{} _ = pprPanic "tcExpr: HsQualLit" (ppr e)
+tcExprNoExpand e@HsQualLit{} _ = pprPanic "tcExpr: HsQualLit" (ppr e)
{-
************************************************************************
@@ -436,18 +441,19 @@ tcExpr e@HsQualLit{} _ = pprPanic "tcExpr: HsQualLit" (ppr e)
************************************************************************
-}
--- Explicit lists [e1,e2,e3] have been expanded already in the renamer
+-- Explicit lists [e1,e2,e3] have been expanded already in tcExpand
-- The expansion includes an ExplicitList, but it is always the built-in
-- list type, so that's all we need concern ourselves with here. See
-- GHC.Rename.Expr. Note [Handling overloaded and rebindable constructs]
-tcExpr (ExplicitList _ exprs) res_ty
- = do { res_ty <- expTypeToType res_ty
+tcExprNoExpand (ExplicitList x exprs) res_ty
+ = assert (isNoRebindable x) $
+ do { res_ty <- expTypeToType res_ty
; (coi, elt_ty) <- matchExpectedListTy res_ty
; let tc_elt expr = tcCheckPolyExpr expr elt_ty
; exprs' <- mapM tc_elt exprs
; return $ mkHsWrapCo coi $ ExplicitList elt_ty exprs' }
-tcExpr expr@(ExplicitTuple x tup_args boxity) res_ty
+tcExprNoExpand expr@(ExplicitTuple x tup_args boxity) res_ty
| all tupArgPresent tup_args
= do { let arity = length tup_args
tup_tc = tupleTyCon boxity arity
@@ -478,7 +484,7 @@ tcExpr expr@(ExplicitTuple x tup_args boxity) res_ty
; tcWrapResultMono expr expr' act_res_ty res_ty }
-tcExpr (ExplicitSum _ alt arity expr) res_ty
+tcExprNoExpand (ExplicitSum _ alt arity expr) res_ty
= do { let sum_tc = sumTyCon arity
; res_ty <- expTypeToType res_ty
; (coi, arg_tys) <- matchExpectedTyConApp sum_tc res_ty
@@ -505,12 +511,12 @@ tcExpr (ExplicitSum _ alt arity expr) res_ty
************************************************************************
-}
-tcExpr (HsLet x binds expr) res_ty
+tcExprNoExpand (HsLet x binds expr) res_ty
= do { (binds', expr') <- tcLocalBinds binds $
tcMonoLExpr expr res_ty
; return (HsLet x binds' expr') }
-tcExpr (HsCase ctxt scrut matches) res_ty
+tcExprNoExpand (HsCase ctxt scrut matches) res_ty
= do { -- We used to typecheck the case alternatives first.
-- The case patterns tend to give good type info to use
-- when typechecking the scrutinee. For example
@@ -532,13 +538,16 @@ tcExpr (HsCase ctxt scrut matches) res_ty
; matches' <- tcCaseMatches ctxt tcBody (Scaled mult scrut_ty) matches res_ty
; return (HsCase ctxt scrut' matches') }
-tcExpr (HsIf x pred b1 b2) res_ty
- = do { pred' <- tcCheckMonoExpr pred boolTy
+tcExprNoExpand (HsIf x pred b1 b2) res_ty
+ -- HsIf in rebindable case would be expanded out so we would not
+ -- have a Just RebindableSyntaxTable here, only Nothing
+ = assert (isNoRebindable x) $
+ do { pred' <- tcCheckMonoExpr pred boolTy
; let res_ty' = adjustExpTypeForCaseBranches res_ty [b1,b2]
; (u1,b1') <- tcCollectingUsage $ tcMonoLExpr b1 res_ty'
; (u2,b2') <- tcCollectingUsage $ tcMonoLExpr b2 res_ty'
; tcEmitBindingUsage (supUE u1 u2)
- ; return (HsIf x pred' b1' b2') }
+ ; return (HsIf noExtField pred' b1' b2') }
{-
Note [MultiWayIf linearity checking]
@@ -564,32 +573,16 @@ If we add linear guards, this code will have to be revisited.
Not using 'sup' caused #23814.
-}
-tcExpr (HsMultiIf _ alts) res_ty
+tcExprNoExpand (HsMultiIf _ alts) res_ty
= do { alts' <- tcGRHSNE IfAlt tcBody alts res_ty
-- See Note [MultiWayIf linearity checking]
; res_ty <- readExpType res_ty
; return (HsMultiIf res_ty alts') }
-tcExpr (HsDo _ do_or_lc stmts) res_ty
- | DoExpr{} <- do_or_lc
- -- ApplicativeDo are typechecked using tcDoStmts
- = do isApplicativeDo <- xoptM LangExt.ApplicativeDo
- if isApplicativeDo
- then tcDoStmts do_or_lc stmts res_ty
- -- Expand expression on the fly otherwise
- -- See Note [Typechecking by expansion: overview]
- else do { hse <- expandDoStmts do_or_lc stmts
- ; tcHsExpansion hse res_ty }
- | MDoExpr{} <- do_or_lc
- = do hse <- expandDoStmts do_or_lc stmts
- tcHsExpansion hse res_ty
- | otherwise
- -- ListComp and MonadComp are handled by legacy tcDoStmts for now,
- -- The ultimate goal is to handle them via expandDoStmts.
- -- GHCiStmts are handled completely separate
+tcExprNoExpand (HsDo _ do_or_lc stmts) res_ty
= tcDoStmts do_or_lc stmts res_ty
-tcExpr (HsProc x pat cmd) res_ty
+tcExprNoExpand (HsProc x pat cmd) res_ty
= do { (pat', cmd', coi) <- tcProc pat cmd res_ty
; return $ mkHsWrapCo coi (HsProc x pat' cmd') }
@@ -601,7 +594,7 @@ tcExpr (HsProc x pat cmd) res_ty
-- and wrap (static e) in a call to
-- fromStaticPtr :: IsStatic p => StaticPtr a -> p a
-tcExpr (HsStatic _ expr) res_ty
+tcExprNoExpand (HsStatic _ expr) res_ty
= do { res_ty <- expTypeToType res_ty
; (co, (p_ty, expr_ty)) <- matchExpectedAppTy res_ty
; (expr', lie) <- captureConstraints $
@@ -636,11 +629,11 @@ tcExpr (HsStatic _ expr) res_ty
expr''
}
-tcExpr (HsEmbTy _ _) _ = failWith (TcRnIllegalTypeExpr TypeKeywordSyntax)
-tcExpr (HsQual _ _ _) _ = failWith (TcRnIllegalTypeExpr ContextArrowSyntax)
-tcExpr (HsForAll _ _ _) _ = failWith (TcRnIllegalTypeExpr ForallTelescopeSyntax)
-tcExpr (HsFunArr _ _ _ _) _ = failWith (TcRnIllegalTypeExpr FunctionArrowSyntax)
-tcExpr (HsStar _) _ = failWith (TcRnIllegalTypeExpr StarKindSyntax)
+tcExprNoExpand (HsEmbTy _ _) _ = failWith (TcRnIllegalTypeExpr TypeKeywordSyntax)
+tcExprNoExpand (HsQual _ _ _) _ = failWith (TcRnIllegalTypeExpr ContextArrowSyntax)
+tcExprNoExpand (HsForAll _ _ _) _ = failWith (TcRnIllegalTypeExpr ForallTelescopeSyntax)
+tcExprNoExpand (HsFunArr _ _ _ _) _ = failWith (TcRnIllegalTypeExpr FunctionArrowSyntax)
+tcExprNoExpand (HsStar _) _ = failWith (TcRnIllegalTypeExpr StarKindSyntax)
{-
************************************************************************
@@ -650,7 +643,7 @@ tcExpr (HsStar _) _ = failWith (TcRnIllegalTypeExpr StarKindSyntax)
************************************************************************
-}
-tcExpr expr@(RecordCon { rcon_con = L loc qcon@(WithUserRdr _ con_name)
+tcExprNoExpand expr@(RecordCon { rcon_con = L loc qcon@(WithUserRdr _ con_name)
, rcon_flds = rbinds }) res_ty
= do { con_like <- tcLookupConLike qcon
@@ -688,11 +681,11 @@ tcExpr expr@(RecordCon { rcon_con = L loc qcon@(WithUserRdr _ con_name)
orig = OccurrenceOf con_name
-- Record updates via dot syntax are replaced by expanded expressions
--- in the renamer. See Note [Overview of record dot syntax] in
+-- in GHC.Tc.Expand. See Note [Overview of record dot syntax] in
-- GHC.Hs.Expr. This is why we match on 'rupd_flds = Left rbnds' here
-- and panic otherwise.
--- WIP: To be fixed soon expandRecordUpd needs to return HsExpansion and not a separate ds_res_ty
-tcExpr expr@(RecordUpd { rupd_expr = record_expr
+-- WIP: To be fixed soon (#27160) expandRecordUpd needs to return HsExpansion and not a separate ds_res_ty
+tcExprNoExpand expr@(RecordUpd { rupd_expr = record_expr
, rupd_flds =
RegularRecUpdFields
{ xRecUpdFields = possible_parents
@@ -719,7 +712,7 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr
}
}
-tcExpr e@(RecordUpd { rupd_flds = OverloadedRecUpdFields {}}) _
+tcExprNoExpand e@(RecordUpd { rupd_flds = OverloadedRecUpdFields {}}) _
= pprPanic "tcExpr: unexpected overloaded-dot RecordUpd" $ ppr e
{-
@@ -732,7 +725,7 @@ tcExpr e@(RecordUpd { rupd_flds = OverloadedRecUpdFields {}}) _
************************************************************************
-}
-tcExpr (ArithSeq _ witness seq) res_ty
+tcExprNoExpand (ArithSeq _ witness seq) res_ty
= tcArithSeq witness seq res_ty
{-
@@ -745,24 +738,20 @@ tcExpr (ArithSeq _ witness seq) res_ty
-- Here we get rid of it and add the finalizers to the global environment.
-- See Note [Delaying modFinalizers in untyped splices] in GHC.Rename.Splice.
-tcExpr (HsTypedSplice ext splice) res_ty = tcTypedSplice ext splice res_ty
-tcExpr e@(HsTypedBracket _ext body) res_ty = tcTypedBracket e body res_ty
-tcExpr e@(HsUntypedBracket ps body) res_ty = tcUntypedBracket e body ps res_ty
+tcExprNoExpand (HsTypedSplice ext splice) res_ty = tcTypedSplice ext splice res_ty
+tcExprNoExpand e@(HsTypedBracket _ext body) res_ty = tcTypedBracket e body res_ty
+tcExprNoExpand e@(HsUntypedBracket ps body) res_ty = tcUntypedBracket e body ps res_ty
{-
************************************************************************
* *
- Catch-all
+ Catch all Case
* *
************************************************************************
-}
--- See Note [Typechecking by expansion: overview]
-tcExpr e res_ty
- = do { mb_hse <- tcExpand e
- ; case mb_hse of
- Just hse -> tcHsExpansion hse res_ty
- Nothing -> pprPanic "tcExpr: unhandled case:" (ppr e) }
+-- We ought to have expanded out or handeled them above
+tcExprNoExpand e _ = pprPanic "tcExpr : unhandled case" $ ppr e
{-
************************************************************************
@@ -1656,7 +1645,7 @@ disambiguateRecordBinds record_expr record_rho possible_parents rbnds res_ty
RegularRecUpdFields
{ xRecUpdFields = parents
, recUpdFields = rbnds }
- , rupd_ext = noExtField }
+ , rupd_ext = NoRebindable }
loc = getLocA (head rbnds)
{-
=====================================
compiler/GHC/Tc/TyCl/PatSyn.hs
=====================================
@@ -1087,7 +1087,7 @@ tcPatToExpr args pat = go pat
go1 (ParPat _ pat) = fmap (HsPar noExtField) (go pat)
go1 (ListPat _ pats)
= do { exprs <- mapM go pats
- ; return $ ExplicitList noExtField exprs }
+ ; return $ ExplicitList NoRebindable exprs }
go1 (TuplePat _ pats box) = do { exprs <- mapM go pats
; return $ ExplicitTuple noExtField
(map (Present noExtField) exprs) box }
=====================================
compiler/GHC/Tc/Types/Origin.hs
=====================================
@@ -641,6 +641,7 @@ exprCtOrigin (XExpr (ExpandedThingRn (HSE o _))) = hsCtxtCtOrigin o
exprCtOrigin (XExpr (HsRecSelRn f)) = OccurrenceOfRecSel $ L (getLoc $ foLabel f) (foExt f)
hsCtxtCtOrigin :: HsCtxt -> CtOrigin
+hsCtxtCtOrigin (ExprCtxt (ExprWithTySig _ (L _ e) _)) = exprCtOrigin e
hsCtxtCtOrigin (ExprCtxt e) = exprCtOrigin e
hsCtxtCtOrigin (FunAppCtxt (FunAppCtxtExpr _ e) _) = exprCtOrigin e
hsCtxtCtOrigin (StmtErrCtxt{}) = DoStmtOrigin
=====================================
compiler/GHC/ThToHs.hs
=====================================
@@ -1227,6 +1227,8 @@ cvtl e = wrapLA (cvt e)
; let tele = setTelescopeBndrsNameSpace varName $
mkHsForAllVisTele noAnn tvs'
; return $ HsForAll noExtField tele body' }
+ cvt (ReSynBindsE m e) = do { e' <- cvt e
+ ; return $ XExpr (ReSynBinds (mk_mod m) e') }
{- | #16895 Ensure an infix expression's operator is a variable/constructor.
Consider this example:
=====================================
libraries/ghc-boot-th/GHC/Boot/TH/Ppr.hs
=====================================
@@ -1,4 +1,3 @@
-{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -Wno-x-partial #-}
-- | contains a prettyprinter for the
@@ -56,6 +55,9 @@ instance Ppr a => Ppr [a] where
instance Ppr Name where
ppr v = pprName v
+instance Ppr ModName where
+ ppr (ModName s) = text s
+
------------------------------
instance Ppr Info where
ppr (TyConI d) = ppr d
@@ -250,6 +252,7 @@ pprExp i (ForallE tvars body) =
parensIf (i >= funPrec) $ sep [pprForall tvars [], pprExp qualPrec body]
pprExp i (ConstrainedE ctx body) =
parensIf (i >= funPrec) $ sep [pprCtxWith pprExp ctx, pprExp qualPrec body]
+pprExp i (ReSynBindsE m e) = text "{{" <+> ppr m <+> text "}}" <+> pprExp i e
pprFields :: [(Name,Exp)] -> Doc
pprFields = sep . punctuate comma . map (\(s,e) -> pprName' Applied s <+> equals <+> ppr e)
=====================================
libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
=====================================
@@ -902,6 +902,8 @@ data Exp
| ForallE [TyVarBndr Specificity] Exp -- ^ @forall \<vars\>. \<expr\>@
| ForallVisE [TyVarBndr ()] Exp -- ^ @forall \<vars\> -> \<expr\>@
| ConstrainedE [Exp] Exp -- ^ @\<ctxt\> => \<expr\>@
+ | ReSynBindsE ModName Exp -- Remember to use bindings from the specified modname
+ -- while typechecking a typed splice for rebindable syntax
deriving( Show, Eq, Ord, Generic )
-- | A (field name, expression) pair. See 'RecConE' and 'RecUpdE'.
=====================================
testsuite/tests/ghc-api/T25121_status.stdout
=====================================
@@ -46,7 +46,9 @@ X(ExprWithTySig) mismatch
X(UntypedSplice) mismatch
>>> HsUntypedSpliceResult (HsExpr (GhcPass 'Renamed))
<<< HsUntypedSpliceResult (GenLocated (EpAnn [TrailingAnn]) (HsType (GhcPass 'Renamed)))
-X(ExplicitList) match = NoExtField
+X(ExplicitList) mismatch
+ >>> RebindableSyntaxTable
+ <<< NoExtField
X(ExplicitTuple) match = NoExtField
X(Hole) match = HoleKind
=====================================
testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
=====================================
@@ -2,11 +2,11 @@ RecordDotSyntaxFail8.hs:47:17: error: [GHC-39999]
• No instance for ‘HasField "quux1" Quux Quux’
arising from selecting the field ‘quux1’
NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class.
- • In the second argument of ‘($)’, namely ‘....bar.baz.quux1’
- In a stmt of a 'do' block: print @Quux $ ....baz.quux1
+ • In the second argument of ‘($)’, namely ‘a.foo.bar.baz.quux1’
+ In a stmt of a 'do' block: print @Quux $ a.foo.bar.baz.quux1
In the expression:
do let a = Foo {foo = ...}
- print @Quux $ ....quux1
+ print @Quux $ ....bar.baz.quux1
let b = myQuux
print @Quux $ b.quux2
let c = Foo {foo = ...}
@@ -20,7 +20,7 @@ RecordDotSyntaxFail8.hs:50:17: error: [GHC-39999]
In a stmt of a 'do' block: print @Quux $ b.quux2
In the expression:
do let a = Foo {foo = ...}
- print @Quux $ ....quux1
+ print @Quux $ ....bar.baz.quux1
let b = myQuux
print @Quux $ b.quux2
let c = Foo {foo = ...}
@@ -30,11 +30,11 @@ RecordDotSyntaxFail8.hs:53:17: error: [GHC-39999]
• No instance for ‘HasField "quux3" Quux r0’
arising from selecting the field ‘quux3’
NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class.
- • In the second argument of ‘($)’, namely ‘....baz.quux3.wob’
- In a stmt of a 'do' block: print @Bool $ ....quux3.wob
+ • In the second argument of ‘($)’, namely ‘a.foo.bar.baz.quux3.wob’
+ In a stmt of a 'do' block: print @Bool $ a.foo.bar.baz.quux3.wob
In the expression:
do let a = Foo {foo = ...}
- print @Quux $ ....quux1
+ print @Quux $ ....bar.baz.quux1
let b = myQuux
print @Quux $ b.quux2
let c = Foo {foo = ...}
=====================================
testsuite/tests/parser/should_fail/RecordDotSyntaxFail9.stderr
=====================================
@@ -1,7 +1,7 @@
RecordDotSyntaxFail9.hs:7:11: error: [GHC-18872]
• Couldn't match type ‘Int’ with ‘[Char]’
arising from selecting the field ‘foo’
- • In the expression: a.foo
+ • In the expression: a.foo :: String
In a pattern binding: _ = a.foo :: String
In a stmt of a 'do' block: let _ = a.foo :: String
=====================================
testsuite/tests/rebindable/T19918.stdout
=====================================
@@ -13,4 +13,4 @@
[("negate",SrcLoc {srcLocPackage = "main", srcLocModule = "Main", srcLocFile = "T19918.hs", srcLocStartLine = 63, srcLocStartCol = 11, srcLocEndLine = 63, srcLocEndCol = 17})]
[("a use of syntactic negation",SrcLoc {srcLocPackage = "main", srcLocModule = "Main", srcLocFile = "T19918.hs", srcLocStartLine = 64, srcLocStartCol = 11, srcLocEndLine = 64, srcLocEndCol = 14})]
[(">>",SrcLoc {srcLocPackage = "main", srcLocModule = "Main", srcLocFile = "T19918.hs", srcLocStartLine = 65, srcLocStartCol = 14, srcLocEndLine = 65, srcLocEndCol = 16})]
-[("a do statement",SrcLoc {srcLocPackage = "main", srcLocModule = "Main", srcLocFile = "T19918.hs", srcLocStartLine = 66, srcLocStartCol = 16, srcLocEndLine = 66, srcLocEndCol = 18})]
+[("a do statement",SrcLoc {srcLocPackage = "main", srcLocModule = "Main", srcLocFile = "T19918.hs", srcLocStartLine = 66, srcLocStartCol = 11, srcLocEndLine = 66, srcLocEndCol = 24})]
=====================================
testsuite/tests/th/T18102b.stdout
=====================================
@@ -1 +1 @@
-25
\ No newline at end of file
+10
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bb7d52fd6397872f27a99b8dd7414d…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bb7d52fd6397872f27a99b8dd7414d…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc] Pushed new branch wip/az/epa-tidy-locatedxxx-29
by Alan Zimmerman (@alanz) 23 Oct '26
by Alan Zimmerman (@alanz) 23 Oct '26
23 Oct '26
Alan Zimmerman pushed new branch wip/az/epa-tidy-locatedxxx-29 at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-tidy-locatedxxx-29
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/romes/multi-threaded-debugger] 33 commits: interp: spawn fillPipe thread, writePipe now safely interruptible
by Rodrigo Mesquita (@alt-romes) 23 Oct '26
by Rodrigo Mesquita (@alt-romes) 23 Oct '26
23 Oct '26
Rodrigo Mesquita pushed to branch wip/romes/multi-threaded-debugger at Glasgow Haskell Compiler / GHC
Commits:
256dcae4 by Andrea Vezzosi at 2026-10-22T17:48:37+02:00
interp: spawn fillPipe thread, writePipe now safely interruptible
Previously an async exception during a call to `writePipe` could have caused a
partial write, making any further write impossible to parse from the other end.
Now `writePipe` merely pushes the message onto a queue, and the actual write
happens in a separate `fillPipe` thread. As a result of this and previous
changes, `interpCmd` no longer needs `interruptibleMask` to preserve the state
of the protocol.
`writePipe` waits for the actual write to complete, and rethrows exceptions
raised in the write attempt, if any.
- - - - -
77a50ed6 by Andrea Vezzosi at 2026-10-23T14:41:26+02:00
Follow `Note [Exceptions in TH]` in `qReport` implementation
`qReport b msg` should use `seqList msg` to trigger any exceptions in the
`String`, as explained in the note.
Through refactors the `seqList msg` call followed the bulk of the implementation
in `GHC.Tc.Gen.Splice.report`, but the call should be in `qReport` itself, so
that, even with -fexternal-interpreter, `msg` gets forced right away and any
exceptions get reported as a compilation error.
Follow up to 'interp: spawn fillPipe thread, writePipe now safely
interruptible'.
- - - - -
9253eeb4 by Andrea Vezzosi at 2026-10-23T18:22:14+01:00
interp: cancel requests if async exceptions while waiting for reply.
- - - - -
d477a12c by Rodrigo Mesquita at 2026-10-23T18:22:14+01:00
Global break action which uses shared thread map
the status Var must actually be global across all threads, otherwise all of them will block trying to write some Status Var no one is looking at at all
have to fix these toggle untoggle things
very satisfying solution with mutable state
Matthew-certified big brain
WIP
HMmm almost there I think
pretty great progressssssssss
ExecOptions isolateThreadBreaks
ThreadBreaksIsolationMode
move to GHCi.Run.Breakpoints
- - - - -
287b3ed1 by Rodrigo Mesquita at 2026-10-23T18:22:14+01:00
Refactor: we have the interactive Ids directly... clean up significantly
Removes things like
names <- map idName ids
map (\i -> let id = find (\x -> i==idName x) names) idso
and is more straightforward because there's less state going around (no
more updating HscEnv as an output)
It also kills `printTypeOfNames` completely, since now we just have the
Ids. No longer `lookupName` names to get back the ids...
```
printTypeOfName :: GHC.GhcMonad m => Name -> m ()
printTypeOfName n
= do maybe_tything <- GHC.lookupName n
case maybe_tything of
Nothing -> return ()
Just thing -> printTyThing thing
```
now is just `printTyThing . AnId`
Also:
```diff
- tythings <- catMaybes `liftM` mapM GHC.lookupName namesSorted
- docs <- mapM pprTypeAndContents [i | AnId i <- tythings]
+ docs <- mapM pprTypeAndContents idsSorted
```
(and yes, in ExecBreaks there are only Ids, no TyThings, bc they are
only constructed by the interpreter execution which can only bind ids.
for TyThings use runDecls which doesn't return execBreaks.)
I have a plan for the `resumes`, I'm getting there.
fixes
grrr
UNDO the removing-hsc-env-globality part of the clean up and keep just the good parts
fixes
- - - - -
43c77c0b by Rodrigo Mesquita at 2026-10-23T18:22:14+01:00
Make the ExecBreak contain a Resume
Put the resume in ExecBreak
- - - - -
a59403a4 by Rodrigo Mesquita at 2026-10-23T18:22:14+01:00
Make resumeExec receive a Resume as an argument
- - - - -
c2553eec by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
Build EvalOpts once per exec rather than per breakpoint stop
in interpreter_steplocal the allocations increased because now we're
updating `eval_opts` after constructing them in `handleRunStatus` (which
is run many times since in step-local most often we don't stop, just
check).
So drop the update to the eval_opts, and, in fact, pull their
construction out. the loop always uses the same eval_opts, so no point
in constructing them inside from scratch every time.
-3.6% from this branch which had the regressions in
interpreter_steplocal
- - - - -
b6cfcb15 by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
Look up a thread's ResumeContext without taking a lock
modifyMVar is unnecessarily expensive and blocking when most often we
just care about reading without modifying. optimize for default case
(thread context already exists). It is called every single time a
breakpoint is hit (regardless of whether we stop there, e.g. in
interpreter_steplocal we do not stop there often)
-3.3% improvement over original regression
- - - - -
2b983445 by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
Every thread resume-context keeps a var for its EvalStatus
Kill the global mapping from thread id to EvalStatus
Instead, keep the EvalStatus in the ResumeContext associated to a thread
in the threadContextVar (where entries are created on breakpoints being
hit and when writing an EvalComplete result)
Before, every breakpoint hit meant reading the global map TVar and
deleting a map entry which did a lot of allocations. Now, we have a
Nothing variable which we overwrite to "take" rather than deleting from
a Map and allocating the GlobalDbgMap too. Note that for every
breakpoint hit we'd have to insert the ThreadId entry in the map again
(because we deleted it last time we resumed), again allocating
unnecessarily. Now it's only a look up on the map and an update on the
variable directly.
And a LOT of breakpoints were hit on interpreter_steplocal, stress
testing the cost of hitting a breakpoint
The isolated threads move to their own top-level TVar Set.
-4.4% improvement over the regression
- - - - -
f835dded by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
Move whether a thread is isolated to the same global map
Stops us from reconstructing the set every time this changed instead to
being a per thread variable just toggled on/off, by default non-isolated
like before (before it was Set.empty, Set.insert for True, Set.delete
for FALSE). This is more straightforward -- there's always an isolation
mode per thread and we can toggle it directly
reduces slightly allocations, but the main advantage is killing a second
global map and making it more uniform with just one thread map and no
membership check for toggledness.
- - - - -
fd268122 by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
Prefer foldl' in readAnyThreadEvalBreak txn
retry 'orElse' next is just next, so we might as well use a strict fold
- - - - -
2680f93f by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
Add inline TODO about improving efficiency of readyAnyThreadBreak
It is currently O(N) in number of threads that have hit breakpoints
It should be number of *live* threads that have hit breaks, bc we still need to find a way to evacuate threads from the map
- - - - -
1e8f83fe by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
Set global breakpoint action in sandboxIO rather than withBreakAction
- - - - -
13bbe29f by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
TODO comment on breakOnException being global rather than per-thread
- - - - -
01a67ce1 by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
fixmeup
- - - - -
cbf5facf by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
WIP: Asynchronous eval/resume
- - - - -
99ca41dd by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
Fix commentary
- - - - -
8052229e by Rodrigo Mesquita at 2026-10-23T18:22:15+01:00
fix
- - - - -
a18c9e96 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
more fixes
- - - - -
86226274 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
fixes api use, kill uninterruptible mask
- - - - -
06c5f856 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
Kill redundant custom handler in GHCi.Server
- - - - -
c279d33f by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
Revert "Kill redundant custom handler in GHCi.Server"
This reverts commit a64e1dbdc9f7a5d46a33c3bbafa69ffa49aee1ec.
- - - - -
ad486183 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
clean up some comments in GHCi.Signals
- - - - -
a597aee2 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
TSO_STOP_ON_EXCEPTION -- per-thread break-on-exception
- - - - -
7bdedd65 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
Add redirectInterrupts again
- - - - -
6d65302e by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
unmask runIt only
- - - - -
5f5a090b by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
Revert "Add redirectInterrupts again"
This reverts commit 564c64781849dd3e681b68ae6b167779403118a6.
- - - - -
be3a1461 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
Move cmmtn
- - - - -
060dfd09 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
internal interp: redirect interrupts on waits to the thread we're waiting for
- - - - -
d30808d8 by Rodrigo Mesquita at 2026-10-23T18:22:16+01:00
Do redirectInterrupts to ext interp too
- - - - -
3730032d by Rodrigo Mesquita at 2026-10-23T18:22:17+01:00
test: make T3171 not fragile and add version for ext interp too
- actually test the sleep of the user-given expression gets interrupted
- the ext interp version tests two things:
- Requests can be cancelled without terminating the ext interp (#18852)
- The stmt being evaluated gets interrupted in the ext interp (that
is, ^C gets sent to the thread running the user-given expression
and doesn't affect the ext interp main thread)
- testing ext interp requires sending ^C to whole process group
Fixes #15383
- - - - -
4be7bc82 by Rodrigo Mesquita at 2026-10-23T18:22:17+01:00
TEMP: remove handleInterpProcessFailure
- - - - -
40 changed files:
- compiler/GHC.hs
- compiler/GHC/Driver/Config.hs
- compiler/GHC/Runtime/Debugger.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/Runtime/Eval/Types.hs
- compiler/GHC/Runtime/Heap/Inspect.hs
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/Runtime/Interpreter/Process.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Splice.hs
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Monad.hs
- libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc
- libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc
- libraries/ghc-heap/tests/parse_tso_flags.hs
- libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs
- libraries/ghci/GHCi/Debugger.hs
- libraries/ghci/GHCi/Message.hs
- libraries/ghci/GHCi/Message/Async.hs
- libraries/ghci/GHCi/Run.hs
- + libraries/ghci/GHCi/Run/Breakpoints.hs
- libraries/ghci/GHCi/Server.hs
- libraries/ghci/GHCi/Server/Threads.hs
- libraries/ghci/GHCi/Signals.hs
- libraries/ghci/ghci.cabal.in
- libraries/template-haskell/Language/Haskell/TH/Syntax.hs
- rts/Exception.cmm
- rts/Interpreter.c
- rts/RtsSymbols.c
- rts/include/rts/Constants.h
- testsuite/tests/ghc-api/T8628.hs
- testsuite/tests/ghc-api/T8639_api.hs
- testsuite/tests/ghc-api/apirecomp001/myghc.hs
- testsuite/tests/ghci/should_run/Makefile
- testsuite/tests/ghci/should_run/T3171.stdout
- + testsuite/tests/ghci/should_run/T3171ext.stdout
- testsuite/tests/ghci/should_run/all.T
- + testsuite/tests/th/T8987b.hs
- + testsuite/tests/th/T8987b.stderr
- testsuite/tests/th/all.T
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/15b5c741ba3bbca8db53d0db9c3df7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/15b5c741ba3bbca8db53d0db9c3df7…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
Magnus pushed new branch wip/mangoiv/bp-16719 at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mangoiv/bp-16719
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/case-bndr-unf] More wibbles, mainly comments
by Simon Peyton Jones (@simonpj) 23 Oct '26
by Simon Peyton Jones (@simonpj) 23 Oct '26
23 Oct '26
Simon Peyton Jones pushed to branch wip/case-bndr-unf at Glasgow Haskell Compiler / GHC
Commits:
360bcb51 by Simon Peyton Jones at 2026-10-23T17:42:01+01:00
More wibbles, mainly comments
- - - - -
10 changed files:
- compiler/GHC/Core.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Types/Id.hs
Changes:
=====================================
compiler/GHC/Core.hs
=====================================
@@ -1393,6 +1393,151 @@ same way as above, otherwise the analysis would not be conservative wrt. the
lenient semantics (which includes the strict one). It is also much harder to
explain and maintain, as it turned out.
+Note [Core binder IdInfo invariants]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+We allow the following IdInfo on different sorts of Core binders.
+See the fields in GHC.Types.Id.Info.IdInfo:
+
+We classify binders into
+ * let-binders let x=rhs in body
+ * lambda binders (\x. e)
+ * case binders case e of x { ... }
+ * case-alternative binders case e of _ { K x y -> ... }
+
+ Let Lambda Case/case-alt
+ ---------------------------------------------
+ Occurrence Yes Yes Yes
+
+ InlinePrag Yes No No
+ Strictness (DmdSig) Yes No No
+ CPR info (CprSig) Yes No No
+ CAF Yes No No
+ Arity Yes No No
+ Call-arity Yes No No
+ Rules (RuleInfo) Yes No No
+ Unfolding Yes No(CBI1) evaldUnfolding only (CBI2)
+ Demand info Yes Yes Yes
+ One-shot No Yes No
+ ------------------------------------------------
+
+The predicate `GHC.Types.Id.lamBndrInfoOK` checks the Lambda and Case columns
+of this table (except one-shot info), and Core Lint applies it to every
+non-let binder (`lintIdBndr`).
+
+Generally, lambda binders have only IdInfo that describes their /use/
+(e.g. occ-info, demand info) not their /definition/. See esp (CBI1).
+
+Case and case-alternative binders are similar because again they lack a definition,
+and because they can /become/ a lambda binder when `mkDupableAlt` abstracts over them.
+
+Places that must take care to maintain these invariants (#27965):
+
+* The desugarer, when desugaring a strict binding let !x = rhs in body,
+ generates case x of x { DEFAULT -> body }; the case binder must not inherit
+ x's IdInfo. See `GHC.HsToCore.Utils.seqVar`.
+
+* `GHC.Core.Utils.bindNonRec` (used by `mkCoreLet`, and hence by the
+ Simplifier's `wrapFloats`), which turns let x = rhs in body into
+ case rhs of x { DEFAULT -> body } when `rhs` is unlifted and not
+ ok-for-speculation. Here `x` may well have a let-unfolding, e.g. one made
+ by `makeTrivial`.
+
+* `GHC.Core.Opt.SpecConstr.mkSeqs`, which builds case arg of arg' { DEFAULT -> rhs }
+ where `arg` may be an imported Id with an unfolding.
+
+All three use `GHC.Types.Id.mkCaseBndrFromLetBndr`.
+
+* The Simplifier's `simplNonRecE` does not use a StrictBind continuation for a
+ strict let-binding let x = rhs in body if `x` has RULES, a stable unfolding,
+ or a non-default inline pragma; for if it did, `mkDupableContWithDmds` might
+ turn `x` into the lambda binder of a join point. See `use_strict_bind`.
+
+(CBI1) Based on #17530 and #21496 we never attach unfoldings of any kind to lambda
+ binders, not even `evaldUnfolding`.
+
+ It's just too easy for the call site to change and invalidate the unfolding.
+ E.g. the caller of the lambda drops a seq (e.g. because the lambda is strict
+ in its binder) which in turn makes the OtherCon[] unfolding a lie. So
+ unfoldings on lambda binders can never really be trusted when on lambda
+ binders if there is the chance of the call site to change. So it's easiest to
+ just never attach any to lambda binders to begin with, as well as stripping
+ them off if we e.g. float out an expression while abstracting over some
+ arguments.
+
+(CBI2) See Note [Evaluated-ness on case binders]
+
+(CBI3) Note that /occurrences/ may have IdInfo that is not present on the binder.
+ Notably, consider case e of r { Just x -> ..r...; Nothing -> ...r... }
+ The occurrence of `r` in the (Just x) branch will have an unfolding `Just x`,
+ and similarly in the `Nothing` branch. But the /binder/ of `r` has only
+ `evaldUnfolding` See Note [Evaluated-ness on case binders]
+
+Note [Evaluated-ness on case binders]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The binding site of an Id in case expression (case-binder or case alternative) may
+carry an `OtherCon []` (aka `evaldUnfolding`). meaning "this variable is certainly
+evaluated". Specifically:
+
+* Case binders are always evaluated. `GHC.Core.Opt.Simplify.Iteration.simplAlts` and
+ CorePrep add `evaldUnfolding` to every case binder.
+
+* Case-alternative binders for strict constructor fields
+ binders)
+ data T = MkT !Int Int
+ case x of MkT y z -> ...
+ `y` gets an evaldUnfolding.
+
+ This is done by `GHC.Core.Utils.dataConRepFSInstPat` (used by the interface-file loader,
+ among others), `GHC.Core.SimpleOpt`, the Simplifier (`adjustFieldsIdInfo`), and
+ worker/wrapper (for the argument and CPR result binders it makes;
+ see Note [Record evaluated-ness in worker/wrapper] in GHC.Core.Opt.WorkWrap.Utils).
+
+Why is this information on the /binder/? Within the Simplifier it is not
+needed there: in each case alternative the Simplifier adds a more precise
+unfolding for the case binder (and evaluated-ness for strict-field binders) to
+its in-scope set, and refreshes every occurrence from that. But many other
+passes rebuild variable occurrences /from the binder/: substitution-based
+passes (SimpleOpt, Specialise, SpecConstr, CSE), SetLevels/FloatOut, the binder
+swap in the occurrence analyser, CoreTidy, and CorePrep. After such a pass,
+an occurrence knows that the variable is evaluated only if the binder does.
+
+That knowledge is used, mainly via `exprIsHNF`/`varIsHNF` (not by
+`exprOkForSpeculation`; see Note [exprOkForSpeculation and evaluated variables]
+in GHC.Core.Utils), by:
+
+* CorePrep: deciding whether a let-binding is a value (allocate directly) or
+ a thunk, e.g. `let x = Box y` where `y` is a strict field.
+ See Note [Pin evaluatedness on floats] in GHC.CoreToStg.Prep. CorePrep runs
+ just after CoreTidy, which propagates binder IdInfo to occurrences.
+
+* SetLevels/FloatOut: floating single-alternative cases out of loops, when the
+ scrutinee is evaluated; see Note [Floating single-alternative cases] in
+ GHC.Core.Opt.SetLevels. Also the call-by-value marks given to abstracted
+ variables (`GHC.Types.Id.transferPolyIdInfo`).
+
+* Worker/wrapper: `move_transit_vars` avoids an unboxed 1-tuple for a single
+ evaluated transit variable (test T18109); and the CPR result binders of the
+ wrapper remain evaluated (tests T13077a, #13027). The latter matters because
+ unboxed-tuple alternatives take a fast path in the Simplifier's
+ `adjustFieldsIdInfo`, and so get evaluated-ness only from the binder.
+
+* SimpleOpt: eliminating a case on an evaluated variable, and `mkFieldSeqFloats`.
+
+* Minor heuristic uses: FloatIn (the late FloatIn runs after FloatOut and CSE
+ with no Simplifier in between) and occurrences created by CSE or the binder
+ swap, until the next Simplifier run.
+
+Core Lint does /not/ depend on this information. Nor does anything in STG or
+tag inference.
+
+Removing the information from the binders would require these passes to track
+evaluated-ness in an environment instead (as SpecConstr already does with its
+ValueEnv), which they currently don't. So we allow an OtherCon unfolding (and
+only that) on case binders and case-alternative binders:
+see the table in Note [Core binder IdInfo invariants]
+
+
+
************************************************************************
* *
In/Out type synonyms
@@ -1742,128 +1887,6 @@ floatBinders (FloatTick {}) = []
The @Unfolding@ type is declared here to avoid numerous loops
-Note [Never put `OtherCon` unfoldings on lambda binders]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Based on #21496 we never attach unfoldings of any kind to lambda binders.
-It's just too easy for the call site to change and invalidate the unfolding.
-E.g. the caller of the lambda drops a seq (e.g. because the lambda is strict in it's binder)
-which in turn makes the OtherCon[] unfolding a lie.
-So unfoldings on lambda binders can never really be trusted when on lambda binders if there
-is the chance of the call site to change. So it's easiest to just never attach any
-to lambda binders to begin with, as well as stripping them off if we e.g. float out
-and expression while abstracting over some arguments.
-
-See also Note [Lambda and case binders have vanilla IdInfo].
-
-Note [Lambda and case binders have vanilla IdInfo]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Invariant: the following binders
- * lambda binders (\x. e)
- * case binders case e of x { ... }
- * case-alternative binders case e of _ { K x y -> ... }
-have none of
- (a) RULES
- (b) a (non-default) inline pragma, such as INLINE or NOINLINE
- (c) an unfolding, except that case binders and case-alternative binders may
- have an evaluated-ness unfolding (OtherCon);
- see Note [Evaluated-ness on case binders]
-The predicate `GHC.Types.Id.lamBndrInfoOK` checks (a-c), and Core Lint checks
-it (in `lintIdBndr`). Moreover lambda binders have no unfolding at all, not
-even an OtherCon one: see Note [Never put `OtherCon` unfoldings on lambda binders].
-
-Why? RULES, pragmas, and stable unfoldings describe a /let-bound/ Id, whose
-definition is right there in the binding. It is far from clear what they would
-mean for a lambda binder, whose value is supplied by the caller; and we can't
-easily work out the consequences of allowing them. It is much simpler just to
-rule them out. For example, `preInlineBetaUnconditionally` assumes the
-invariant, and so does not check the binder's activation or stable unfolding.
-This is very much in the spirit of #17530, when we stopped adding unfoldings to
-lambda binders.
-
-Why case binders and case-alternative binders? Because they can become lambda
-binders, when `mkDupableAlt` abstracts a join point over them.
-
-Places that must take care to maintain the invariant (#27965):
-
-* The desugarer, when desugaring a strict binding let !x = rhs in body,
- generates case x of x { DEFAULT -> body }; the case binder must not inherit
- x's IdInfo. See `GHC.HsToCore.Utils.seqVar`.
-
-* `GHC.Core.Utils.bindNonRec` (used by `mkCoreLet`, and hence by the
- Simplifier's `wrapFloats`), which turns let x = rhs in body into
- case rhs of x { DEFAULT -> body } when `rhs` is unlifted and not
- ok-for-speculation. Here `x` may well have a let-unfolding, e.g. one made
- by `makeTrivial`.
-
-Both use `GHC.Types.Id.mkCaseBndrFromLetBndr`.
-
-* The Simplifier, when duplicating a StrictBind continuation let x = <> in b,
- makes a join point whose lambda binder must not inherit x's IdInfo.
- See (DSB1) in Note [Duplicating StrictBind] in GHC.Core.Opt.Simplify.Iteration.
-
-Note [Evaluated-ness on case binders]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The binding site of an Id in case expression (case-binder or case alternative)
-has only vanillaIdInfo, /except/ that it may carry an `OtherCon []` (aka `evaldUnfolding`).
-meaning "this variable is certainly evaluated". Specifically:
-
-* Case binders are always evaluated. `GHC.Core.Opt.Simplify.Iteration.simplAlts` and
- CorePrep add `evaldUnfolding` to every case binder.
-
-* Case-alternative binders for strict constructor fields
- binders)
- data T = MkT !Int Int
- case x of MkT y z -> ...
- `y` gets an evaldUnfolding.
-
- This is done by `GHC.Core.Utils.dataConRepFSInstPat` (used by the interface-file loader,
- among others), `GHC.Core.SimpleOpt`, the Simplifier (`adjustFieldsIdInfo`), and
- worker/wrapper (for the argument and CPR result binders it makes;
- see Note [Record evaluated-ness in worker/wrapper] in GHC.Core.Opt.WorkWrap.Utils).
-
-Why is this information on the /binder/? Within the Simplifier it is not
-needed there: in each case alternative the Simplifier adds a more precise
-unfolding for the case binder (and evaluated-ness for strict-field binders) to
-its in-scope set, and refreshes every occurrence from that. But many other
-passes rebuild variable occurrences /from the binder/: substitution-based
-passes (SimpleOpt, Specialise, SpecConstr, CSE), SetLevels/FloatOut, the binder
-swap in the occurrence analyser, CoreTidy, and CorePrep. After such a pass,
-an occurrence knows that the variable is evaluated only if the binder does.
-
-That knowledge is used, mainly via `exprIsHNF`/`varIsHNF` (not by
-`exprOkForSpeculation`; see Note [exprOkForSpeculation and evaluated variables]
-in GHC.Core.Utils), by:
-
-* CorePrep: deciding whether a let-binding is a value (allocate directly) or
- a thunk, e.g. `let x = Box y` where `y` is a strict field.
- See Note [Pin evaluatedness on floats] in GHC.CoreToStg.Prep. CorePrep runs
- just after CoreTidy, which propagates binder IdInfo to occurrences.
-
-* SetLevels/FloatOut: floating single-alternative cases out of loops, when the
- scrutinee is evaluated; see Note [Floating single-alternative cases] in
- GHC.Core.Opt.SetLevels. Also the call-by-value marks given to abstracted
- variables (`GHC.Types.Id.transferPolyIdInfo`).
-
-* Worker/wrapper: `move_transit_vars` avoids an unboxed 1-tuple for a single
- evaluated transit variable (test T18109); and the CPR result binders of the
- wrapper remain evaluated (tests T13077a, #13027). The latter matters because
- unboxed-tuple alternatives take a fast path in the Simplifier's
- `adjustFieldsIdInfo`, and so get evaluated-ness only from the binder.
-
-* SimpleOpt: eliminating a case on an evaluated variable, and `mkFieldSeqFloats`.
-
-* Minor heuristic uses: FloatIn (the late FloatIn runs after FloatOut and CSE
- with no Simplifier in between) and occurrences created by CSE or the binder
- swap, until the next Simplifier run.
-
-Core Lint does /not/ depend on this information. Nor does anything in STG or
-tag inference.
-
-Removing the information from the binders would require these passes to track
-evaluated-ness in an environment instead (as SpecConstr already does with its
-ValueEnv), which they currently don't. So we allow an OtherCon unfolding (and
-only that) on case binders and case-alternative binders: see (c) in
-Note [Lambda and case binders have vanilla IdInfo].
-}
-- | Records the /unfolding/ of an identifier, which is approximately the form the
=====================================
compiler/GHC/Core/Lint.hs
=====================================
@@ -1859,15 +1859,13 @@ lintIdBndr top_lvl bind_site id thing_inside
2 (ppr unf)
-- Check that lambda, case, and case-alternative binders have
- -- no RULES, no inline pragma, and no unfolding other than OtherCon
- -- See Note [Lambda and case binders have vanilla IdInfo] in GHC.Core
+ -- only the IdInfo permitted by the table in
+ -- Note [Core binder IdInfo invariants] in GHC.Core
; checkL (is_let_bind || lamBndrInfoOK id) $
hang (text "Non-let binder" <+> quotes (ppr id)
- <+> text "has RULES, an inline pragma, or a non-OtherCon unfolding")
+ <+> text "has IdInfo that only a let-binder may have")
2 (vcat [ text "Binding site:" <+> text (show_site bind_site)
- , text "Inline pragma:" <+> ppr (idInlinePragma id)
- , text "Rules:" <+> ppr (idCoreRules id)
- , text "Unfolding:" <+> ppr (realIdUnfolding id) ])
+ , text "IdInfo:" <+> ppr (idInfo id) ])
; addLoc (IdTy id) (lintValueType id_ty)
=====================================
compiler/GHC/Core/Opt/Simplify/Env.hs
=====================================
@@ -1372,15 +1372,7 @@ getTCvSubst (SimplEnv { seInScope = in_scope, seTvSubst = tv_env, seCvSubst = cv
getFullSubst :: InScopeSet -> SimplEnv -> Subst
getFullSubst in_scope (SimplEnv { seIdSubst = id_env, seTvSubst = tv_env, seCvSubst = cv_env })
- = mkSubst in_scope (mapVarEnv to_expr id_env) tv_env cv_env
- where
- to_expr :: SimplClo -> CoreExpr
- -- A tiresome impedence-matcher
- to_expr (DoneEx e _) = e
- to_expr (DoneId v) = Var v
- to_expr (ContEx env e mco) = mkCastMCo e' mco
- where
- e' = GHC.Core.Subst.substExprSC (getFullSubst in_scope env) e
+ = mkSubst in_scope (mapVarEnv (simplCloExpr in_scope) id_env) tv_env cv_env
simplCloExpr :: InScopeSet -> SimplClo -> OutExpr
-- Turn a SimplClo into an OutExpr, by applying the substitution
=====================================
compiler/GHC/Core/Opt/Simplify/Iteration.hs
=====================================
@@ -1643,7 +1643,7 @@ completeBindX env from_what bndr rhs body cont
| FromBeta arg_levity <- from_what
, needsCaseBindingL arg_levity rhs -- Enforcing the let-can-float-invariant
= do { (env1, bndr1) <- simplNonRecBndr env bndr -- Lambda binders don't have rules
- -- See Note [Lambda and case binders have vanilla IdInfo] in GHC.Core
+ -- See Note [Core binder IdInfo invariants] in GHC.Core
; (floats, expr') <- simplNonRecBody env1 from_what body cont
-- Do not float floats past the Case binder below
; let expr'' = wrapFloats floats expr'
@@ -1795,7 +1795,7 @@ simplLamBndr :: SimplEnv -> InBndr -> SimplM (SimplEnv, OutBndr)
-- could have a stable unfolding;
-- see Historical Note [Case binders and join points]
-- But now it is much simpler! We now only remove unfoldings.
--- See Note [Never put `OtherCon` unfoldings on lambda binders]
+-- See (CBI1) in Note [Core binder IdInfo invariants]
simplLamBndr env bndr = simplBinder env (zapIdUnfolding bndr)
simplLamBndrs :: SimplEnv -> [InBndr] -> SimplM (SimplEnv, [OutBndr])
@@ -1829,7 +1829,7 @@ simplNonRecE :: HasDebugCallStack
simplNonRecE env from_what bndr (rhs, rhs_se) body cont
| assert (isId bndr && not (isJoinId bndr) ) $
- is_strict_bind
+ use_strict_bind
= -- Evaluate RHS strictly
simplExprF (rhs_se `setInScopeFromE` env) rhs
(StrictBind { sc_bndr = bndr, sc_body = body, sc_from = from_what
@@ -1844,14 +1844,38 @@ simplNonRecE env from_what bndr (rhs, rhs_se) body cont
; return (floats1 `addFloats` floats2, expr') }
where
- is_strict_bind = case from_what of
- FromBeta Unlifted -> True
+ info = idInfo bndr
+
+ use_strict_bind
-- If we are coming from a beta-reduction (FromBeta) we must
- -- establish the let-can-float invariant, so go via StrictBind
+ -- establish the let-can-float invariant, so we must go via StrictBind
-- If not, the invariant holds already, and it's optional.
-
- -- (FromBeta Lifted) or FromLet: look at the demand info
- _ -> seCaseCase env && isStrUsedDmd (idDemandInfo bndr)
+ | FromBeta Unlifted <- from_what
+ = True
+
+ -- Not if the demand is non-strict
+ | not (isStrUsedDmd (demandInfo info))
+ = False
+
+ -- Not if case-of-case is off
+ | not (seCaseCase env)
+ = False
+
+ -- Not for things with RULES or INLINE or NOINLINE
+ -- because won't survive if we duplicate the join point. e.g.
+ -- let {-# NOINLINE x #-}
+ -- x* = case y of { ... }
+ -- in blah
+ -- If we make a join point j x = blah, we have nowhere convenient
+ -- to put that NOINLINE. Ditto INLINE or RULES. It's very unusual,
+ -- so no harm in simply not using StrictBind.
+ | FromLet <- from_what
+ , isStableUnfolding (unfoldingInfo info)
+ || not (isEmptyRuleInfo (ruleInfo info))
+ || not (isAlwaysActive (inlinePragmaActivation (inlinePragInfo info)))
+ = False
+
+ | otherwise = True
------------------
@@ -3998,15 +4022,10 @@ mkDupableContWithDmds env _
; let join_body = wrapFloats floats1 join_inner
res_ty = contResultType cont
- -- If bndr' has IdInfo that a lambda binder must not have,
- -- use a fresh lambda binder; see (DSB1) in Note [Duplicating StrictBind]
- ; (arg_bndr, join_body')
- <- if lamBndrInfoOK bndr'
- then return (bndr', join_body)
- else do { arg_bndr <- newId (fsLit "x") (idMult bndr') (idType bndr')
- ; return (arg_bndr, Let (NonRec bndr' (Var arg_bndr)) join_body) }
-
- ; mkDupableStrictBind env arg_bndr join_body' res_ty }
+ -- bndr' is about to become a lambda binder, so it must have suitable
+ -- IdInfo; simplNonRecE ensures this. See Note [Core binder IdInfo invariants]
+ ; assertPpr (lamBndrInfoOK bndr') (ppr bndr') $
+ mkDupableStrictBind env bndr' join_body res_ty }
mkDupableContWithDmds env _
(StrictArg { sc_fun = fun, sc_cont = cont
@@ -4200,7 +4219,7 @@ mkDupableAlt _env case_bndr jfloats (Alt con alt_bndrs alt_rhs_in)
-- No lambda binder has an unfolding, but (currently) case binders can,
-- so we must zap them here. But case binders never have a pragma,
-- stable unfolding or RULES, so there is no need to zap those.
- -- See Note [Lambda and case binders have vanilla IdInfo] in GHC.Core
+ -- See Note [Core binder IdInfo invariants] in GHC.Core
join_rhs = mkLams (map zapIdUnfolding final_bndrs) rhs_with_seqs
; join_bndr <- newJoinId filtered_binders rhs_ty'
@@ -4607,20 +4626,6 @@ So we potentially make a join-point for the body, thus:
Just like StrictArg in fact -- and indeed they share code.
-(DSB1) Lambda binders must not have a (non-default) inline pragma, a stable
- unfolding, or RULES; see Note [Lambda and case binders have vanilla IdInfo]
- in GHC.Core, and #27965. But the let-binder `x` may well
- have them; e.g. in GHC.Internal.Control.Monad.ST.Lazy.Imp we have
- {-# NOINLINE res1 #-}
- !res1 = unST fm s
- So if `x` has such IdInfo, we use a fresh binder `x'` for the join point,
- and keep `x` as a let-binder, retaining all its IdInfo:
- let x = <> in b ==> join j x' = let x = x' in b
- in j <>
- The hole is evaluated before the jump, so `x'` is a value, and `let x = x'`
- is just an alias. We do this only when necessary, to avoid leaving an
- alias in the common case.
-
Note [Join point abstraction] Historical note
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NB: This note is now historical, describing how (in the past) we used
=====================================
compiler/GHC/Core/Opt/Simplify/Utils.hs
=====================================
@@ -1922,6 +1922,9 @@ preInlineBetaUnconditionally
-- Like preInlineLetUnconditionally, but for a beta-redex (\bndr. body) arg
-- The argument may or may not be already simplified (DoneEx or ContEx)
--
+-- The binder is a lambda binder and so lacks most IdInfo;
+-- see Note [Core binder IdInfo invariants]
+--
-- Compared to preInlineLetUnconditionally we omit some checks:
-- * The binder is never top-level, so no need for the
-- Note [Top-level bottoming Ids] check, nor for `early_phase`
@@ -1930,12 +1933,16 @@ preInlineBetaUnconditionally
-- * A lambda binder never has an inline pragma, a stable unfolding, or RULES
-- (see `lamBndrInfoOK`), so no need to check activation, nor for
-- Note [Stable unfoldings and preInlineUnconditionally]
+--
+-- And we add one extra one
+-- * Check the let-can-float invariant, and don't inline if not
+
preInlineBetaUnconditionally env levity bndr arg
| assertPpr (lamBndrInfoOK bndr) (ppr bndr) $
not pre_inline_unconditionally = Nothing
| isCoVar bndr = Nothing -- Note [Do not inline CoVars unconditionally]
| not (one_occ (idOccInfo bndr)) = Nothing
- | needs_case_binding = Nothing
+ | needs_case_binding = Nothing -- Enforce the let-can-float invariant
| otherwise = Just $! extendIdSubst env bndr arg
-- If the arg is not yet simplified, it is a ContEx, which captures the
-- lexical environment for us to restore in `simplInId`.
@@ -1946,24 +1953,24 @@ preInlineBetaUnconditionally env levity bndr arg
where
pre_inline_unconditionally = sePreInline env
+ needs_case_binding = needsCaseBindingL levity rhs
+ -- Ok to test an InExpr or OutExpr in needsCaseBindingL because
+ -- exprOkForSpeculation is stable under simplification
+
+ rhs :: CoreExpr -- Can be InExpr or OutExpr, but here it does not matter
+ rhs = case arg of
+ ContEx _ e _ -> e -- InExpr
+ DoneEx e _ -> e -- OutExpr
+ DoneId v -> Var v -- OutExpr
+
one_occ IAmDead = True -- Happens in ((\x.1) v)
one_occ OneOcc{ occ_n_br = 1
, occ_in_lam = NotInsideLam } = True
one_occ OneOcc{ occ_n_br = 1
, occ_in_lam = IsInsideLam
- , occ_int_cxt = IsInteresting } = case arg of
- ContEx _ e _ -> canInlineInLam e
- DoneEx e _ -> canInlineInLam e
- DoneId v -> canInlineInLam (Var v)
+ , occ_int_cxt = IsInteresting } = canInlineInLam rhs
one_occ _ = False
- -- Enforce the let-can-float invariant
- -- Ok to test an InExpr in needsCaseBinding because
- -- exprOkForSpeculation is stable under simplification
- needs_case_binding = case arg of
- ContEx _ e _ -> needsCaseBindingL levity e
- DoneEx e _ -> needsCaseBindingL levity e
- DoneId v -> needsCaseBindingL levity (Var v)
canInlineInLam :: CoreExpr -> Bool
-- Be very careful before inlining inside a lambda, because (a) we must not
=====================================
compiler/GHC/Core/Opt/SpecConstr.hs
=====================================
@@ -2072,7 +2072,7 @@ mkSeqs seqees res_ty rhs =
-- localiseId: see (SCF1) in Note [SpecConstr and strict fields]
-- mkCaseBndrFromLetBndr: arg_id may have IdInfo (e.g. an unfolding,
-- if it is a global) that a case binder must not have; see
- -- Note [Lambda and case binders have vanilla IdInfo] in GHC.Core
+ -- Note [Core binder IdInfo invariants] in GHC.Core
res_ty
([Alt DEFAULT [] rhs])
=====================================
compiler/GHC/Core/Opt/WorkWrap/Utils.hs
=====================================
@@ -1041,7 +1041,7 @@ unbox_one_arg opts arg_var
-- Apply str info to new args. Also remove OtherCon unfoldings so they
-- don't end up in lambda binders of the worker.
- -- See Note [Never put `OtherCon` unfoldings on lambda binders]
+ -- See (CBI1) in Note [Core binder IdInfo invariants]
arg_ids' = map zapIdUnfolding $
zipWithEqual setIdDemandInfo arg_ids ds
=====================================
compiler/GHC/Core/Utils.hs
=====================================
@@ -758,7 +758,7 @@ bindNonRec bndr rhs body
where
case_bind = mkDefaultCase rhs (mkCaseBndrFromLetBndr bndr) body
-- mkCaseBndrFromLetBndr: bndr may have IdInfo suitable for a
- -- let-binder; see Note [Lambda and case binders have vanilla IdInfo]
+ -- let-binder; see Note [Core binder IdInfo invariants]
-- in GHC.Core
let_bind = Let (NonRec bndr rhs) body
=====================================
compiler/GHC/HsToCore/Utils.hs
=====================================
@@ -267,7 +267,7 @@ bindMatchId new mid body
--
-- The case binder has the same Name (and hence Unique), type and multiplicity
-- as `var`, but not its IdInfo: `var` may have, say, a NOINLINE pragma, but a
--- case binder must not; see Note [Lambda and case binders have vanilla IdInfo]
+-- case binder must not; see Note [Core binder IdInfo invariants]
-- in GHC.Core, and #27965. E.g. `res1` in GHC.Internal.Control.Monad.ST.Lazy.Imp
-- has a NOINLINE pragma.
seqVar :: Var -> CoreExpr -> CoreExpr
=====================================
compiler/GHC/Types/Id.hs
=====================================
@@ -893,7 +893,7 @@ setCaseBndrEvald str id
-- that a case binder must not have, so we keep its Name, type, multiplicity
-- and IdDetails, but reset its IdInfo, except that we record that it is
-- evaluated.
--- See Note [Lambda and case binders have vanilla IdInfo] in GHC.Core
+-- See Note [Core binder IdInfo invariants] in GHC.Core
mkCaseBndrFromLetBndr :: Id -> Id
mkCaseBndrFromLetBndr id = id `setIdInfo` (vanillaIdInfo `setUnfoldingInfo` evaldUnfolding)
@@ -917,20 +917,31 @@ idCoreRules id = ruleInfoRules (idSpecialisation id)
idHasRules :: Id -> Bool
idHasRules id = not (isEmptyRuleInfo (idSpecialisation id))
--- | True <=> the Id has no (non-default) inline pragma, no RULES, and no
--- unfolding except perhaps an evaluated-ness one (OtherCon). Lambda binders,
--- case binders, and case-alternative binders must all satisfy this.
--- See Note [Lambda and case binders have vanilla IdInfo] in GHC.Core
+-- | True <=> the Id has only the IdInfo permitted on a lambda, case, or
+-- case-alternative binder. See the table in Note [Core binder IdInfo invariants]
+-- in GHC.Core; Core Lint checks this invariant.
+--
+-- We allow occurrence info, demand info, and one-shot info (which the table
+-- permits only on lambda binders, but a case binder may be about to become one).
+-- We also allow an `OtherCon []` unfolding; lambda binders must have no unfolding
+-- at all, but Lint checks that separately.
lamBndrInfoOK :: Id -> Bool
lamBndrInfoOK id
- = isDefaultInlinePragma (idInlinePragma id)
- && unf_ok (realIdUnfolding id)
- && not (idHasRules id)
+ = isDefaultInlinePragma (inlinePragInfo info)
+ && isNopSig (dmdSigInfo info)
+ && isTopCprSig (cprSigInfo info)
+ && mayHaveCafRefs (cafInfo info)
+ && arityInfo info == unknownArity
+ && callArityInfo info == unknownArity
+ && isEmptyRuleInfo (ruleInfo info)
+ && unf_ok (realUnfoldingInfo info)
where
+ info = idInfo id
+
-- See Note [Evaluated-ness on case binders] in GHC.Core
- unf_ok NoUnfolding = True
- unf_ok (OtherCon _) = True
- unf_ok _ = False
+ unf_ok NoUnfolding = True
+ unf_ok (OtherCon []) = True
+ unf_ok _ = False
setIdSpecialisation :: Id -> RuleInfo -> Id
setIdSpecialisation id spec_info = modifyIdInfo (`setRuleInfo` spec_info) id
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/360bcb51e9ef7eafcae105be6f3ee18…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/360bcb51e9ef7eafcae105be6f3ee18…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/romes/async-rpc] 2 commits: test: make T3171 not fragile and add version for ext interp too
by Andrea Vezzosi (@trac-Saizan) 23 Oct '26
by Andrea Vezzosi (@trac-Saizan) 23 Oct '26
23 Oct '26
Andrea Vezzosi pushed to branch wip/romes/async-rpc at Glasgow Haskell Compiler / GHC
Commits:
422ec8e5 by Rodrigo Mesquita at 2026-10-23T14:41:27+02:00
test: make T3171 not fragile and add version for ext interp too
- actually test the sleep of the user-given expression gets interrupted
- the ext interp version tests two things:
- Requests can be cancelled without terminating the ext interp (#18852)
- The stmt being evaluated gets interrupted in the ext interp (that
is, ^C gets sent to the thread running the user-given expression
and doesn't affect the ext interp main thread)
- testing ext interp requires sending ^C to whole process group
Fixes #15383
- - - - -
5cc052e8 by Andrea Vezzosi at 2026-10-23T17:49:10+02:00
interp: cancel requests if async exceptions while waiting for reply.
- - - - -
9 changed files:
- compiler/GHC/Runtime/Interpreter/Process.hs
- libraries/ghci/GHCi/Message.hs
- libraries/ghci/GHCi/Message/Async.hs
- libraries/ghci/GHCi/Server.hs
- libraries/ghci/GHCi/Server/Threads.hs
- testsuite/tests/ghci/should_run/Makefile
- testsuite/tests/ghci/should_run/T3171.stdout
- + testsuite/tests/ghci/should_run/T3171ext.stdout
- testsuite/tests/ghci/should_run/all.T
Changes:
=====================================
compiler/GHC/Runtime/Interpreter/Process.hs
=====================================
@@ -64,7 +64,7 @@ sendTHComputation i msg reqHandler = mask $ \restore -> do
where
proc = instProcess i
handleOne mbox doneRef = do
- handleRemoteTHCall (interpPipe proc) mbox $ \req -> do
+ handleRemoteTHCall (interpPipe proc) mbox $ \_setCancel req -> do
(stop, res) <- reqHandler req
writeIORef doneRef stop
return res
=====================================
libraries/ghci/GHCi/Message.hs
=====================================
@@ -75,6 +75,7 @@ import GHC.Stack.CCS
import qualified GHC.Boot.TH.Syntax as TH
import qualified GHC.Boot.TH.Monad as TH
import GHCi.Message.Async
+import Control.Monad.STM
-- -----------------------------------------------------------------------------
-- The RPC protocol between GHC and the interactive server
@@ -666,12 +667,12 @@ remoteCall pipe msg = either throwIO (pure . runGet get)
-- | Handle a single 'Message' request on the interpreter and reply to the host
handleRemoteCall :: Pipe
-> (Msg -> IO Msg) {-^ Msg hook -}
- -> (forall a. (Show a, Binary a) => WriteReply a %1 -> Message a -> IO r)
+ -> (forall a. (Show a, Binary a) => WriteReply a %1 -> (IO () -> IO ()) -> Message a -> IO r)
-> IO r
handleRemoteCall pipe hook k =
- handleAsyncReq pipe getMessage Nothing \(WriteReply writer) msg0 -> IO \s0 ->
+ handleAsyncReq pipe getMessage Nothing \(WriteReply writer) sa msg0 -> IO \s0 ->
case hook msg0 |#> s0 of -- unIO for linearity checking
- (# s1, Msg msg #) -> k (WriteReply \x -> writer (fmap put x)) msg |#> s1
+ (# s1, Msg msg #) -> k (WriteReply \x -> writer (fmap put x)) sa msg |#> s1
-- | Send a 'THMessage' request to the host and wait for a reply from the host
-- to the interpreter.
@@ -687,9 +688,9 @@ remoteTHCall pipe ii msg = either throwIO (pure . runGet get)
-- Symmterically to 'remoteTHCall', we always want to specify the 'InboxId' for
-- RunTH "reverse requests"
handleRemoteTHCall
- :: Pipe -> InboxId -> (forall a. (Show a, Binary a) => THMessage a -> IO a) -> IO ()
+ :: Pipe -> InboxId -> (forall a. (Show a, Binary a) => (IO () -> IO ()) -> THMessage a -> IO a) -> IO ()
handleRemoteTHCall pipe ii k =
- handleAsyncReq pipe getTHMessage (Just ii) \writer (THMsg msg) -> IO \s0 ->
- case k msg |#> s0 of -- unIO for linearity checking
+ handleAsyncReq pipe getTHMessage (Just ii) \writer sa (THMsg msg) -> IO \s0 ->
+ case k sa msg |#> s0 of -- unIO for linearity checking
(# s1, a #) -> writeReply writer (put a) |#> s1
=====================================
libraries/ghci/GHCi/Message/Async.hs
=====================================
@@ -160,14 +160,19 @@ instance Exception PipeWriteClosedException
-- and identify whether they are requests or replies.
writePipe :: Pipe -> IddMsg -> IO ()
-writePipe Pipe{..} msg = do
- var <- newEmptyTMVarIO
- atomically $ do
+writePipe p msg = do
+ var <- atomically $ writePipeAsync p msg
+ either throwIO pure =<< atomically (takeTMVar var)
+
+writePipeAsync :: Pipe -> IddMsg -> STM (TMVar (Either SomeException ()))
+writePipeAsync Pipe{..} msg = do
+ var <- newEmptyTMVar
readTVar pipeWriteClosed >>= \case
True -> throwSTM PipeWriteClosedException
False -> pure ()
writeTQueue (writeQueue pipeAsyncMngr) (msg, var)
- either throwIO pure =<< atomically (takeTMVar var)
+ pure var
+
-- | Only the 'drainPipe' thread should read from the pipe directly. Other
-- functions should wait for the matching reply to be delivered asynchronously.
@@ -239,14 +244,18 @@ remoteAsyncReq pipe msg ii = do
-- Write request
writePipe pipe (Request uq ii (runPut msg))
`onException`
- -- the req wasn't done, or no one will be reading the reply:
- -- in either case, drop it from the pending map.
- atomically (modifyTVar pendingReplies (IntMap.delete uq))
+ -- the req wasn't done, or no one will be reading the reply:
+ -- in either case, drop it from the pending map.
+ atomically (modifyTVar pendingReplies (IntMap.delete uq))
-- Block waiting for reply
atomically (takeTMVar wv)
`onException`
- atomically (modifyTVar pendingReplies (IntMap.delete uq))
+ atomically (do
+ modifyTVar pendingReplies (IntMap.delete uq)
+ -- we don't wait for Cancel to be written on the pipe,
+ -- and won't get a reply: nowhere to report it anyway.
+ writePipeAsync pipe (Cancel uq))
-- | Receive a single asynchronous request and send a matching reply
-- asynchronously (the handler may fork a computation that eventually replies
@@ -258,7 +267,7 @@ remoteAsyncReq pipe msg ii = do
-- branch, and if the handler otherwise throws, it is handled by 'handleAsyncReq'.
--
-- See Note [Exceptions during serialization] about exceptions the 'Put' argument might raise.
-handleAsyncReq :: Pipe -> Get a -> (Maybe InboxId) -> (WriteReply Put %1 -> a -> IO r) -> IO r
+handleAsyncReq :: Pipe -> Get a -> (Maybe InboxId) -> (WriteReply Put %1 -> (IO () -> IO ()) -> a -> IO r) -> IO r
handleAsyncReq pipe getit mii k = mask $ \restore -> do
let am = pipeAsyncMngr pipe
ack <- newEmptyMVar
@@ -274,7 +283,7 @@ handleAsyncReq pipe getit mii k = mask $ \restore -> do
Nothing -> tryReadTQueue $ requestsQueue am
Just ii -> tryReadTQueue =<< getMailbox am ii
case taken of
- Just req -> pure (Just req)
+ Just req@(uq,_) -> fetchedRequest am uq >> pure (Just req)
Nothing | isClosed -> pure Nothing -- empty and closed
| otherwise -> retry -- wait for msg
@@ -282,9 +291,9 @@ handleAsyncReq pipe getit mii k = mask $ \restore -> do
Nothing -> throwIO PipeReadClosedException -- can't expect reqs
Just (uq, bs) -> do
let reply p = do
- writePipe pipe (Reply uq (bimap toSerializableException runPut p))
- putMVar ack ()
-
+ b <- atomically $ doneHandling am uq
+ when b $ writePipe pipe (Reply uq (bimap toSerializableException runPut p))
+ putMVar ack () -- TODO: superfluous?
-- Run the continuation which must reply exactly once with 'writeReply'
case runGetOrFail getit bs of
Left (_, _, err) -> do
@@ -292,7 +301,7 @@ handleAsyncReq pipe getit mii k = mask $ \restore -> do
reply (Left (toException exc))
throwIO exc
Right (_, _, it) ->
- restore (k (WriteReply reply) it)
+ restore (k (WriteReply reply) (setActive am uq) it)
-- If there's an exception before the reply is sent, reply with an error instead.
`catch` \(e :: SomeException) -> do
@@ -306,6 +315,7 @@ handleAsyncReq pipe getit mii k = mask $ \restore -> do
reply (Left e)
throwIO e
+
-- | 'handleSyncReq' failed to decode an incoming request payload using the given @'Get' a@
newtype DecodeAsyncReqException = DecodeAsyncReqException String deriving Show
instance Exception DecodeAsyncReqException
@@ -347,6 +357,15 @@ getMailbox am (InboxId ii) = do
-- ** Async matching "internals" -----------------------------------------------
+-- | Requests go
+-- requestsQueue -> Fetched -> Active cancel -> gone
+-- .. -> Canceling -> gone
+-- Canceling is needed to avoid race condition in gap between Fetched and Active.
+data RequestStatus
+ = Fetched
+ | Active (IO ()) -- ^ must not be blocking.
+ | Canceling
+
data AsyncManager = AsyncManager
{ pendingReply :: !(TVar (IntMap (TMVar (Either SomeException LB.ByteString))))
-- ^ When a request is sent, keep track that we're expecting a reply. The
@@ -357,6 +376,9 @@ data AsyncManager = AsyncManager
-- /without/ a specific 'InboxId', queue it here. A request handler will
-- pop the next request from it. (Nothing except the 'drainPipe' thread
-- should read from the pipe). Read with @'handleAsyncReq' p get Nothing@.
+ , cancelStatus :: !(TVar (IntMap RequestStatus))
+ -- ^ When a `Cancel uq` is received, we lookup `uq` in this map and call the
+ -- callback if present.
, mailboxQueues :: !(TVar (IntMap (TQueue (CorrelationId, LB.ByteString))))
-- ^ Requests for a specific 'InboxId' that can be read using
-- @'handleAsyncReq' p get (Just <mailboxid>)@.
@@ -389,15 +411,21 @@ type CorrelationId = Int
-- exclusively.
data IddMsg = Request !CorrelationId !(Maybe InboxId) LB.ByteString
| Reply !CorrelationId (Either SerializableException LB.ByteString)
+ | Cancel !CorrelationId -- !(Maybe InboxId) --? ^ Technically a
+ -- Request, but no Reply is expected, the CorrelationId is the
+ -- one of the Request being canceled.
instance Binary IddMsg where
put (Request i ii bs) = putWord8 0 >> put i >> put ii >> put bs
put (Reply i bs) = putWord8 1 >> put i >> put bs
+ put (Cancel i) = putWord8 2 >> put i
+
get = do
b <- getWord8
case b of
0 -> Request <$> get <*> get <*> get
1 -> Reply <$> get <*> get
+ 2 -> Cancel <$> get
_ -> fail $ "impossible: Binary IddMsg - " ++ show b
newAsyncManager :: Pipe -> IO AsyncManager
@@ -405,6 +433,7 @@ newAsyncManager pipe = do
asyncFreshId <- newIORef 0
pendingReply <- newTVarIO IntMap.empty
requestsQueue <- newTQueueIO
+ cancelStatus <- newTVarIO IntMap.empty
mailboxQueues <- newTVarIO IntMap.empty
writeQueue <- newTQueueIO
@@ -455,6 +484,7 @@ drainPipe p unmask = catch (unmask $ loop `finally` pipeCloseRead p) replyToPend
q <- getMailbox am ii
writeTQueue q (uq,bs)
loop
+ Just (Cancel uq) -> cancelRequest am uq
-- EOF on read handle
Nothing -> do
-- clean up pipe then exit loop
@@ -465,6 +495,46 @@ drainPipe p unmask = catch (unmask $ loop `finally` pipeCloseRead p) replyToPend
am = pipeAsyncMngr p
+cancelRequest :: AsyncManager -> CorrelationId -> IO ()
+cancelRequest am uq = join . atomically $ do
+ cs <- readTVar (cancelStatus am)
+ case IntMap.lookup uq cs of
+ Nothing -> pure (pure ())
+ Just Fetched -> writeTVar (cancelStatus am) (IntMap.insert uq Canceling cs) >> pure (pure ())
+ Just (Active cancel) -> writeTVar (cancelStatus am) (IntMap.delete uq cs) >> pure cancel
+ Just Canceling -> pure (pure ())
+
+doneHandling :: AsyncManager -> CorrelationId -> STM Bool
+doneHandling am uq = do
+ cs <- readTVar (cancelStatus am)
+ case IntMap.lookup uq cs of
+ Nothing -> pure False
+ Just s -> do
+ writeTVar (cancelStatus am) $ IntMap.delete uq cs
+ case s of
+ Canceling -> pure False
+ _ -> pure True
+
+setActive :: AsyncManager -> CorrelationId -> IO () -> IO ()
+setActive am uq cancel = join . atomically $ do
+ cs <- readTVar (cancelStatus am)
+ case IntMap.lookup uq cs of
+ Nothing -> pure (pure ()) -- reply already received.
+ Just Fetched -> writeTVar (cancelStatus am) (IntMap.insert uq (Active cancel) cs) >> pure (pure ())
+ Just (Active _) -> writeTVar (cancelStatus am) (IntMap.insert uq (Active cancel) cs) >> pure (pure ())
+ Just Canceling -> pure cancel
+
+fetchedRequest :: AsyncManager -> CorrelationId -> STM ()
+fetchedRequest am uq = do
+ cs <- readTVar (cancelStatus am)
+ case IntMap.lookup uq cs of
+ Nothing -> writeTVar (cancelStatus am) (IntMap.insert uq Fetched cs)
+ Just Fetched -> error "impossible"
+ Just (Active _) -> error "impossible"
+ Just Canceling -> error "impossible"
+
+
+
{-
Note [Exceptions during serialization]
-----------------------------------------------------------------------------
@@ -553,7 +623,7 @@ runWriteReply (WriteReply r) = r
(|#>) (IO fs) s = fs s
(%>>=) :: (IO a) -> (a -> IO b) %1 -> IO b
-(%>>=) = \ m f -> IO (\s0 ->
+(%>>=) = \ m -> \ f -> IO (\s0 ->
case m |#> s0 of -- unIO for linearity checking
(# s1, x #) -> f x |#> s1)
infixl 1 %>>=
=====================================
libraries/ghci/GHCi/Server.hs
=====================================
@@ -39,6 +39,7 @@ import System.Exit
import System.IO
import Control.Concurrent
+import Control.Monad.STM
import GHCi.Message.Async (runWriteReply, (%>>=))
import GHCi.Server.Threads
@@ -66,13 +67,13 @@ servWithCustom
-> IO ()
servWithCustom verbose hook pipe restore customHandler = do
ref <- newIORef False
- withThreadManager $ \mngr ->
+ withThreadManager $ \mngr -> do
loop ref mngr `finally` closePipe pipe
where
loop doneRef mngr = do
when verbose $ trace "reading pipe..."
- handleRemoteCall pipe hook $ \wr (msg :: Message a) ->
+ handleRemoteCall pipe hook $ \wr setCancel (msg :: Message a) ->
discardCtrlC %>>= \_ ->
when verbose (trace ("msg: " ++ (show msg))) %>>= \_ ->
@@ -83,8 +84,10 @@ servWithCustom verbose hook pipe restore customHandler = do
reply () %>>= writeReply wr
RunTH ii st q ty loc -> spawnFinally mngr (runWriteReply wr)
(wrapRunTH ii (runTH pipe ii st q ty loc))
+ (setCancel . void . forkIO . killThread)
RunModFinalizers ii st qs -> spawnFinally mngr (runWriteReply wr)
(wrapRunTH ii (runModFinalizerRefs pipe ii st qs))
+ (setCancel . void . forkIO . killThread)
_other -> run msg >>= reply %>>= writeReply wr
isDone <- readIORef doneRef
=====================================
libraries/ghci/GHCi/Server/Threads.hs
=====================================
@@ -41,8 +41,8 @@ withThreadManager k = do
-- | Linear and resource-safe because 'ThreadManager' is guaranteed to wait or
-- cancel all threads.
-spawnFinally :: ThreadManager -> (Either SomeException a -> IO ()) %1 -> IO a -> IO ()
-spawnFinally ThreadManager{..} = unsafe_linear \fin -> \action -> void $
+spawnFinally :: ThreadManager -> (Either SomeException a -> IO ()) %1 -> IO a -> (ThreadId -> IO b) -> IO b
+spawnFinally ThreadManager{..} = unsafe_linear \fin -> \action -> \k ->
forkFinally
( mask $ \unmask -> do
tid <- myThreadId
@@ -57,6 +57,7 @@ spawnFinally ThreadManager{..} = unsafe_linear \fin -> \action -> void $
else throwIO ThreadKilled
)
( \ea -> fin ea )
+ >>= k
unsafe_linear :: (a -> b) %1 -> (a %1 -> b)
unsafe_linear = Unsafe.unsafeCoerce (Unsafe.unsafeCoerce :: (a -> b) -> (a %1 -> b))
=====================================
testsuite/tests/ghci/should_run/Makefile
=====================================
@@ -3,10 +3,20 @@ include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
# Test that threadDelay can be interrupted by ^C.
-T3171:
- echo "do Control.Concurrent.threadDelay 3000000; putStrLn \"threadDelay was not interrupted\"" | \
- "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) & \
- sleep 2; kill -INT $$!; wait
+# Wait for the statement to start before interrupting (#15383), and signal
+# the external interpreter too (the `pgrep -P $!`), as ^C in a terminal would.
+#
+# The ext interp tests both:
+# - interrupting a remote request doesn't terminate the ext interpreter (#18852)
+# - a ^C gets propagated to the thread evaluating the user request on the ext
+# interpreter so that it gets interrupted
+T3171ext: T3171_OPTS = -fexternal-interpreter
+T3171 T3171ext:
+ rm -f $@.started
+ echo 'do { writeFile "$@.started" ""; (Control.Concurrent.threadDelay 100000000 >> putStrLn "threadDelay was not interrupted.") `Control.Exception.catch` \(e :: Control.Exception.SomeException) -> System.IO.hPutStrLn System.IO.stderr ("threadDelay was interrupted: " ++ show e) >> Control.Exception.throwIO e }' | \
+ "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) $(T3171_OPTS) & \
+ while [ ! -e $@.started ] && kill -0 $$! 2>/dev/null; do sleep 0.1; done; \
+ kill -INT $$! $$(pgrep -P $$!); wait
TopEnvIface:
"$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) TopEnvIface -v1 -fno-hide-source-paths -e "a" -e ":q" -fwrite-if-simplified-core -fwrite-interface
=====================================
testsuite/tests/ghci/should_run/T3171.stdout
=====================================
@@ -1 +1,2 @@
+threadDelay was interrupted: user interrupt
Interrupted.
=====================================
testsuite/tests/ghci/should_run/T3171ext.stdout
=====================================
@@ -0,0 +1,2 @@
+threadDelay was interrupted: user interrupt
+Interrupted.
=====================================
testsuite/tests/ghci/should_run/all.T
=====================================
@@ -12,11 +12,17 @@ test('T27287', [just_ghci, combined_output], makefile_test, [])
test('T3171',
[when(opsys('mingw32'),skip),
- fragile(15383),
req_interp,
combined_output],
makefile_test, [])
+test('T3171ext',
+ [when(opsys('mingw32'),skip),
+ req_interp,
+ unless(config.have_ext_interp, skip),
+ combined_output],
+ makefile_test, [])
+
test('ghcirun004', just_ghci, compile_and_run, [''])
test('T8377', just_ghci, compile_and_run, [''])
test('T9914', just_ghci, ghci_script, ['T9914.script'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77a50ed696da001af080b319a8a86f…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77a50ed696da001af080b319a8a86f…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/27323] 9 commits: Fix a few tag inference bugs.
by Sasha Bogicevic (@Bogicevic) 23 Oct '26
by Sasha Bogicevic (@Bogicevic) 23 Oct '26
23 Oct '26
Sasha Bogicevic pushed to branch wip/27323 at Glasgow Haskell Compiler / GHC
Commits:
6bbca569 by Andreas Klebinger at 2026-10-21T10:01:10+00:00
Fix a few tag inference bugs.
* Treat bottoming functions and nullary join points as functions.
* When generating bytecode don't rely on imported tag sigs.
Fixes #27831, #27841 and #27842.
- - - - -
71808e29 by Sylvain Henry at 2026-10-22T04:50:24-04:00
Add GHC.Internal.Unboxed.Do: do-notation for unboxed values (#27944)
QualifiedDo operators can be representation-polymorphic: a do-block is
expanded into ordinary applications before typechecking, and the only
check on a bound variable is the deferred fixed-runtime-rep check. A
representation-polymorphic (>>=) cannot be defined directly, though,
because its body would bind a variable of unknown representation.
The new module provides such operators for State#-passing code as
methods of a class indexed by RuntimeRep, with one instance per
representation. With optimisation the dictionaries disappear and a
block compiles to the usual nested case expressions:
Ubx.do { x <- readWordArray# mba 0# -- x :: Word#
; writeWordArray# mba 1# x -- unit actions are statements
; Ubx.pure x }
Also add users guide documentation and tests.
Co-Authored-By: Claude Fable 5.1 <noreply(a)anthropic.com>
- - - - -
33247780 by Sylvain Henry at 2026-10-22T04:50:24-04:00
Bignum: use Ubx.do for State#-passing code (#27944)
Rewrite the State#-passing code of the GHC.Internal.Bignum modules
(Primitives, WordArray, BigNat, Natural, Integer, Backend.Native,
Backend.GMP) with the qualified do-notation of GHC.Internal.Unboxed.Do.
Nested case chains such as
case newWordArray# sz s of { (# s, mwa #) ->
case act mwa s of { s ->
unsafeFreezeByteArray# mwa s }}
become
Ubx.do
mwa <- newWordArray# sz
act mwa
unsafeFreezeByteArray# mwa
The optimised Core is unchanged (compared per top-level binding).
BigNat now enables MonoLocalBinds: local loops written with Ubx.do
must stay monomorphic in the state type, otherwise GHC does not turn
them into join points.
Co-Authored-By: Claude Fable 5.1 <noreply(a)anthropic.com>
- - - - -
593f5f5b by Sylvain Henry at 2026-10-22T04:51:16-04:00
JS: remove archive padding after wasm objects (#25665)
On Darwin hosts, emar (llvm-ar) writes archives in the Darwin format when
the first member is not a known object file, which is the case for the
archives of the JS backend. This format pads each member to 8 bytes with
'\n' and includes the padding in the member size. Wasm objects do not
accept trailing bytes: wasm-ld failed with "section too large".
The JS linker now removes this padding when it extracts a wasm object from
an archive. In addition, Hadrian passes --format=gnu to emar for the JS
target. See Note [Wasm objects in Darwin archives].
Also document the format of Cc (wasm) objects in Note [Cc object format].
Co-Authored-By: Claude Opus 5.5 <noreply(a)anthropic.com>
- - - - -
13dff5d0 by L0neGamer at 2026-10-22T21:37:31-04:00
add options for resizing bytearrays (#27244)
add five mutable bytearray resizing operations
for various kinds of pinnedness and aligning.
- prefer unpinned when allocating new array (``resizeMutableByteArrayPreferUnpinned#``; the ``resizeMutableByteArray#`` default)
- prefer pinned when allocating new array (``resizeMutableByteArrayPreferPinned#``)
- prefer aligned and pinned when allocating new array (``resizeMutableByteArrayPreferAlignedPinned#``)
- prefer same as input bytearray when allocating new array (``resizeMutableByteArrayKeepPinnedness#``)
- ensure the output array is aligned and pinned after operation (``resizeMutableByteArrayMakeAlignedPinned#``)
- - - - -
0c17201c by Sylvain Henry at 2026-10-22T21:38:23-04:00
JS: implement performMinorGC and performBlockingMajorGC (#28012)
GHC.Internal.System.Mem imports three C entry points: performMajorGC,
performGC (for performMinorGC) and performBlockingMajorGC. The JS RTS
only defined h$performMajorGC, so calling performMinorGC or
performBlockingMajorGC threw "ReferenceError: h$performGC is not
defined" at runtime.
The JS RTS has a single non-generational collector, so both missing
entry points are now aliases of h$performMajorGC.
Add a test that calls every GC entry point of System.Mem.
Co-Authored-By: Claude Fable 5.1 <noreply(a)anthropic.com>
- - - - -
7a631ff2 by L0neGamer at 2026-10-23T09:11:39-04:00
Mon(a|oi)d of No (Return|Mappend) progress (!15795)
Make non-canonical definitions of return and mappend
non-suppressible errors, and make canonical definitions
of those methods warnings.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/328
- - - - -
14656fd4 by Simon Jakobi at 2026-10-23T09:12:27-04:00
Cmm: keep the CBE substitution idempotent
When blocks are merged over multiple rounds during common block
elimination, a block that won a merge in an earlier round can still
lose a merge in a later round. The substitution map (Subst) used to
record this as a chain: the earlier loser mapped to a block that was
itself eliminated. In PLT terminology, the substitution became
*non-idempotent*. Applying such a substitution with a single lookup
left edges to unreachable blocks in the Cmm graph, eventually leading
to a setInfoTableStackMap panic (#27368).
With this patch, each round's fresh substitutions are applied to the old
ones as they are added (extendSubst), so every eliminated block maps
directly to its final replacement and the substitution stays idempotent.
Fixes #27368.
Assisted-by: Claude Fable 5.1
- - - - -
f2bfd333 by Sasha Bogicevic at 2026-10-23T17:22:30+02:00
Don't report -XStrict-generated bangs under -Wredundant-bang-patterns
-Wredundant-bang-patterns could warn about bangs inserted by -XStrict,
including those on unlifted function arguments and local tuple
bindings, even though there is no user-written bang to remove.
Mark bangs inserted by decideBangHood with generatedSrcSpan and track
generated code in DsLclEnv through putSrcSpanDs. The pattern-match
checker emits these bangs without SrcInfo, suppressing redundant-bang
warnings while retaining divergence checks and inaccessible-RHS
warnings.
Update tidy1 and tidy_bang_pat to use the monadic context instead of
threading a Boolean. Push sub-pattern locations when descending, and
consult inGeneratedCodeDs when checking literal overflow.
Preserve located patterns through matchSinglePatVar, pmcPatBind and
desugarPatBind, using desugarLPat so pattern bindings retain their
generated-code information.
Add regression tests T27323 and T27323b and a changelog entry.
- - - - -
190 changed files:
- + changelog.d/25665
- + changelog.d/27368
- + changelog.d/28012
- + changelog.d/T27323
- + changelog.d/T27831-bottoming-strict-field
- + changelog.d/T27842-bytecode-imported-tags
- + changelog.d/monad-of-no-return-canonical
- + changelog.d/resizeMutableByteArray-pinnedness
- + changelog.d/unboxed-do
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/Cmm/CommonBlockElim.hs
- compiler/GHC/CmmToAsm/CFG/Dominators.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Data/OrdList.hs
- compiler/GHC/Data/Pair.hs
- compiler/GHC/Data/Word64Map/Internal.hs
- compiler/GHC/Data/Word64Set/Internal.hs
- compiler/GHC/Driver/CmdLine.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Pmc/Types.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/JS/Opt/Simple.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Stg/EnforceEpt.hs
- compiler/GHC/Stg/EnforceEpt/Rewrite.hs
- compiler/GHC/Stg/EnforceEpt/TagSig.hs
- compiler/GHC/Stg/EnforceEpt/Types.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Linker/Linker.hs
- compiler/GHC/StgToJS/Object.hs
- compiler/GHC/StgToJS/Prim.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Unique/FM.hs
- compiler/GHC/Types/Unique/Map.hs
- compiler/GHC/Unit/External/ModuleOrigin.hs
- compiler/GHC/Unit/External/Visibility.hs
- compiler/GHC/Utils/Monad/Codensity.hs
- compiler/GHC/Utils/Ppr/Colour.hs
- compiler/ghc.cabal.in
- docs/users_guide/exts/qualified_do.rst
- docs/users_guide/using-warnings.rst
- ghc/ghc-bin.cabal.in
- hadrian/src/Settings/Builders/Ar.hs
- hadrian/src/Settings/Warnings.hs
- libraries/base/src/GHC/Base.hs
- libraries/base/src/GHC/Exts.hs
- libraries/ghc-internal/CHANGELOG.md
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/Base.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/Backend/GMP.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/Backend/Native.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/BigNat.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/Integer.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/Natural.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/Primitives.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/WordArray.hs
- libraries/ghc-internal/src/GHC/Internal/Event/Windows.hsc
- + libraries/ghc-internal/src/GHC/Internal/Unboxed/Do.hs
- rts/PrimOps.cmm
- rts/RtsSymbols.c
- rts/include/stg/MiscClosures.h
- rts/js/environment.js
- testsuite/tests/ado/ado-optimal.hs
- testsuite/tests/ado/ado001.hs
- + testsuite/tests/bytecode/T27842.hs
- + testsuite/tests/bytecode/T27842.stdout
- + testsuite/tests/bytecode/T27842A.hs
- + testsuite/tests/bytecode/T27842N.hs
- testsuite/tests/bytecode/all.T
- + testsuite/tests/codeGen/should_compile/T27368.hs
- testsuite/tests/codeGen/should_compile/all.T
- testsuite/tests/concurrent/T13615/Parallel.hs
- testsuite/tests/concurrent/should_run/T21651.hs
- testsuite/tests/concurrent/should_run/setnumcapabilities001.hs
- testsuite/tests/cpranal/should_run/T20598a.hs
- testsuite/tests/deriving/should_compile/T13758.hs
- testsuite/tests/deriving/should_run/all.T
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.hs
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.stderr
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.stdout
- testsuite/tests/determinism/determ017/A.hs
- testsuite/tests/dmdanal/should_compile/T9208.hs
- testsuite/tests/generics/T27245.hs
- testsuite/tests/generics/T27245.stdout
- testsuite/tests/haddock/perf/Fold.hs
- testsuite/tests/hiefile/should_compile/hie002.hs
- testsuite/tests/hpc/raytrace/Eval.hs
- testsuite/tests/indexed-types/should_compile/T3787.hs
- testsuite/tests/indexed-types/should_fail/T7729.hs
- testsuite/tests/indexed-types/should_fail/T7729a.hs
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/javascript/Makefile
- + testsuite/tests/javascript/T25665.hs
- + testsuite/tests/javascript/T25665.pkg
- + testsuite/tests/javascript/T25665.stdout
- + testsuite/tests/javascript/T25665Lib.hs
- + testsuite/tests/javascript/T25665_c.c
- + testsuite/tests/javascript/T25665_js.js
- testsuite/tests/javascript/all.T
- testsuite/tests/module/mod133.hs
- testsuite/tests/perf/compiler/T13253.hs
- testsuite/tests/perf/compiler/T14683.hs
- testsuite/tests/perf/compiler/T16473.hs
- testsuite/tests/perf/compiler/T18730_A.hs
- testsuite/tests/perf/compiler/T25723.hs
- testsuite/tests/pmcheck/should_compile/T11276.hs
- + testsuite/tests/pmcheck/should_compile/T27323.hs
- + testsuite/tests/pmcheck/should_compile/T27323b.hs
- testsuite/tests/pmcheck/should_compile/all.T
- + testsuite/tests/primops/should_run/ResizeByteArrayPinnedness.hs
- + testsuite/tests/primops/should_run/ResizeByteArrayPinnedness.stdout
- testsuite/tests/primops/should_run/all.T
- testsuite/tests/profiling/should_compile/T19894/StreamK.hs
- testsuite/tests/profiling/should_run/T3001-2.hs
- testsuite/tests/programs/galois_raytrace/Eval.hs
- testsuite/tests/qualifieddo/should_compile/all.T
- + testsuite/tests/qualifieddo/should_compile/qdocompile003.hs
- + testsuite/tests/qualifieddo/should_compile/qdocompile003.stderr
- testsuite/tests/qualifieddo/should_fail/all.T
- + testsuite/tests/qualifieddo/should_fail/qdofail006.hs
- + testsuite/tests/qualifieddo/should_fail/qdofail006.stderr
- testsuite/tests/qualifieddo/should_run/all.T
- + testsuite/tests/qualifieddo/should_run/qdorun008.hs
- + testsuite/tests/qualifieddo/should_run/qdorun008.stdout
- testsuite/tests/rebindable/rebindable2.hs
- + testsuite/tests/rename/should_fail/Noncanonical.hs
- + testsuite/tests/rename/should_fail/Noncanonical.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/rename/should_fail/rnfail026.hs
- + testsuite/tests/rts/T28012.hs
- + testsuite/tests/rts/T28012.stdout
- testsuite/tests/rts/all.T
- testsuite/tests/rts/ipe/IpeStats/Fold.hs
- testsuite/tests/simplCore/should_compile/T14908_Deps.hs
- testsuite/tests/simplCore/should_compile/simpl017.hs
- testsuite/tests/simplStg/should_compile/all.T
- + testsuite/tests/simplStg/should_compile/inferTags005.hs
- + testsuite/tests/simplStg/should_compile/inferTags005.stderr
- + testsuite/tests/simplStg/should_compile/inferTags006.hs
- + testsuite/tests/simplStg/should_compile/inferTags006.stderr
- + testsuite/tests/simplStg/should_run/InferTags007_A.hs
- + testsuite/tests/simplStg/should_run/T27831.hs
- + testsuite/tests/simplStg/should_run/T27831.stdout
- + testsuite/tests/simplStg/should_run/T27857.hs
- + testsuite/tests/simplStg/should_run/T27857.stdout
- testsuite/tests/simplStg/should_run/all.T
- + testsuite/tests/simplStg/should_run/inferTags007.hs
- + testsuite/tests/simplStg/should_run/inferTags007.stdout
- testsuite/tests/typecheck/should_compile/DeepSubsumption02.hs
- testsuite/tests/typecheck/should_compile/T4524.hs
- testsuite/tests/typecheck/should_compile/T4969.hs
- testsuite/tests/typecheck/should_fail/T22707.hs
- testsuite/tests/typecheck/should_fail/T7019.hs
- testsuite/tests/typecheck/should_fail/T8603.hs
- testsuite/tests/warnings/should_compile/Overflow.stderr-ws-64
- + testsuite/tests/warnings/should_compile/RedundantCanonicalMethods.hs
- + testsuite/tests/warnings/should_compile/RedundantCanonicalMethods.stderr
- testsuite/tests/warnings/should_compile/T13256.stderr-ws-64
- testsuite/tests/warnings/should_compile/WarnNoncanonical.hs
- testsuite/tests/warnings/should_compile/WarnNoncanonical.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/haddock/haddock-api/haddock-api.cabal
- utils/haddock/haddock-api/src/Haddock/Interface/ParseModuleHeader.hs
- utils/haddock/haddock-api/src/Haddock/Utils/Json.hs
- utils/haddock/haddock-library/haddock-library.cabal
- utils/haddock/haddock.cabal
- utils/runghc/Main.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f33efee8e138a79057fb6abe0dec5a…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f33efee8e138a79057fb6abe0dec5a…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/27323] Don't report -XStrict-generated bangs under -Wredundant-bang-patterns
by Sasha Bogicevic (@Bogicevic) 23 Oct '26
by Sasha Bogicevic (@Bogicevic) 23 Oct '26
23 Oct '26
Sasha Bogicevic pushed to branch wip/27323 at Glasgow Haskell Compiler / GHC
Commits:
f33efee8 by Sasha Bogicevic at 2026-10-23T17:21:54+02:00
Don't report -XStrict-generated bangs under -Wredundant-bang-patterns
-Wredundant-bang-patterns could warn about bangs inserted by -XStrict,
including those on unlifted function arguments and local tuple
bindings, even though there is no user-written bang to remove.
Mark bangs inserted by decideBangHood with generatedSrcSpan and track
generated code in DsLclEnv through putSrcSpanDs. The pattern-match
checker emits these bangs without SrcInfo, suppressing redundant-bang
warnings while retaining divergence checks and inaccessible-RHS
warnings.
Update tidy1 and tidy_bang_pat to use the monadic context instead of
threading a Boolean. Push sub-pattern locations when descending, and
consult inGeneratedCodeDs when checking literal overflow.
Preserve located patterns through matchSinglePatVar, pmcPatBind and
desugarPatBind, using desugarLPat so pattern bindings retain their
generated-code information.
Add regression tests T27323 and T27323b and a changelog entry.
- - - - -
13 changed files:
- + changelog.d/T27323
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/HsToCore/Utils.hs
- + testsuite/tests/pmcheck/should_compile/T27323.hs
- + testsuite/tests/pmcheck/should_compile/T27323b.hs
- testsuite/tests/pmcheck/should_compile/all.T
- testsuite/tests/warnings/should_compile/Overflow.stderr-ws-64
- testsuite/tests/warnings/should_compile/T13256.stderr-ws-64
Changes:
=====================================
changelog.d/T27323
=====================================
@@ -0,0 +1,7 @@
+section: compiler
+synopsis: Don't report ``-XStrict``-generated bang patterns under ``-Wredundant-bang-patterns``
+description:
+ Bangs introduced by ``-XStrict`` are no longer reported as redundant under
+ ``-Wredundant-bang-patterns``, as they are not user-written.
+issues: #27323
+mrs: !16395
=====================================
compiler/GHC/HsToCore/Match.hs
=====================================
@@ -383,12 +383,14 @@ tidyEqnInfo :: MatchId -> EquationInfo
tidyEqnInfo _ eqn@(EqnDone {}) = return (idDsWrapper, eqn)
-tidyEqnInfo v eqn@(EqnMatch { eqn_pat = (L loc pat) }) = do
- (wrap, pat') <- tidy1 v (not . isGoodSrcSpan . locA $ loc) pat
+tidyEqnInfo v eqn@(EqnMatch { eqn_pat = p@(L loc _) }) = do
+ (wrap, pat') <- tidyLPat v p
return (wrap, eqn{eqn_pat = L loc pat' })
+tidyLPat :: MatchId -> LPat GhcTc -> DsM (DsWrapper, Pat GhcTc)
+tidyLPat v (L loc pat) = putSrcSpanDsA loc (tidy1 v pat)
+
tidy1 :: MatchId -- The scrutinee
- -> Bool -- `True` if the pattern was generated, `False` if it was user-written
-> Pat GhcTc -- The pattern against which it is to be matched
-> DsM (DsWrapper, -- Extra bindings to do before the match
Pat GhcTc) -- Equivalent pattern
@@ -399,21 +401,22 @@ tidy1 :: MatchId -- The scrutinee
-- It eliminates many pattern forms (as-patterns, variable patterns,
-- list patterns, etc) and returns any created bindings in the wrapper.
-tidy1 v g (ParPat _ pat) = tidy1 v g (unLoc pat)
-tidy1 v g (SigPat _ pat _) = tidy1 v g (unLoc pat)
-tidy1 _ _ (WildPat ty) = return (idDsWrapper, WildPat ty)
-tidy1 v g (BangPat _ (L l p)) = tidy_bang_pat v g l p
-tidy1 v g (ModifiedPat _ _ pat) = tidy1 v g (unLoc pat)
+tidy1 v (ParPat _ pat) = tidyLPat v pat
+tidy1 v (SigPat _ pat _) = tidyLPat v pat
+tidy1 _ (WildPat ty) = return (idDsWrapper, WildPat ty)
+tidy1 v (BangPat _ (L l p)) = putSrcSpanDsA l $ tidy_bang_pat v l p
+tidy1 v (ModifiedPat _ _ pat) = tidyLPat v pat
-- case v of { x -> mr[] }
-- = case v of { _ -> let x=v in mr[] }
-tidy1 v _ (VarPat _ (L _ var))
+tidy1 v (VarPat _ (L _ var))
= return (bindMatchId var v, WildPat (idType var))
-- case v of { x@p -> mr[] }
-- = case v of { p -> let x=v in mr[] }
-tidy1 v g (AsPat _ (L _ var) pat)
- = do { (wrap, pat') <- tidy1 v g (unLoc pat)
+tidy1 v (AsPat _ (L _ var) pat)
+
+ = do { (wrap, pat') <- tidyLPat v pat
; return (bindMatchId var v . wrap, pat') }
{- now, here we handle lazy patterns:
@@ -427,7 +430,7 @@ tidy1 v g (AsPat _ (L _ var) pat)
The case expr for v_i is just: match [v] [(p, [], \ x -> Var v_i)] any_expr
-}
-tidy1 v _ (LazyPat _ pat)
+tidy1 v (LazyPat _ pat)
-- This is a convenient place to check for unlifted types under a lazy pattern.
-- Doing this check during type-checking is unsatisfactory because we may
-- not fully know the zonked types yet. We sure do here.
@@ -441,14 +444,14 @@ tidy1 v _ (LazyPat _ pat)
; let sel_binds = [NonRec b rhs | (b,rhs) <- sel_prs]
; return (mkCoreLets sel_binds, WildPat (matchIdType v)) }
-tidy1 _ _ (ListPat ty pats)
+tidy1 _ (ListPat ty pats)
= return (idDsWrapper, unLoc list_ConPat)
where
list_ConPat = foldr (\ x y -> mkPrefixConPat consDataCon [x, y] [ty])
(mkNilPat ty)
pats
-tidy1 _ _ (TuplePat tys pats boxity)
+tidy1 _ (TuplePat tys pats boxity)
= return (idDsWrapper, unLoc tuple_ConPat)
where
arity = length pats
@@ -458,34 +461,37 @@ tidy1 _ _ (TuplePat tys pats boxity)
Boxed -> tys
-- See Note [Unboxed tuple RuntimeRep vars] in TyCon
-tidy1 _ _ (SumPat tys pat alt arity)
+tidy1 _ (SumPat tys pat alt arity)
= return (idDsWrapper, unLoc sum_ConPat)
where
sum_ConPat = mkPrefixConPat (sumDataCon alt arity) [pat] (map getRuntimeRep tys ++ tys)
-- See Note [Unboxed tuple RuntimeRep vars] in TyCon
-- LitPats: we *might* be able to replace these w/ a simpler form
-tidy1 _ g (LitPat _ lit)
- = do { unless g $
+tidy1 _ (LitPat _ lit)
+ = do { in_gen <- inGeneratedCodeDs;
+ unless in_gen $
warnAboutOverflowedLit lit
; return (idDsWrapper, tidyLitPat lit) }
-- NPats: we *might* be able to replace these w/ a simpler form
-tidy1 _ g (NPat ty (L _ lit@OverLit { ol_val = v }) mb_neg eq)
- = do { unless g $
+tidy1 _ (NPat ty (L _ lit@OverLit { ol_val = v }) mb_neg eq)
+ = do { in_gen <- inGeneratedCodeDs;
+ unless in_gen $
let lit' | Just _ <- mb_neg = lit{ ol_val = negateOverLitVal v }
| otherwise = lit
in warnAboutOverflowedOverLit lit'
; return (idDsWrapper, tidyNPat lit mb_neg eq ty) }
-- NPlusKPat: we may want to warn about the literals
-tidy1 _ g n@(NPlusKPat _ _ (L _ lit1) lit2 _ _)
- = do { unless g $ do
+tidy1 _ n@(NPlusKPat _ _ (L _ lit1) lit2 _ _)
+ = do { in_gen <- inGeneratedCodeDs;
+ unless in_gen $ do
warnAboutOverflowedOverLit lit1
warnAboutOverflowedOverLit lit2
; return (idDsWrapper, n) }
-tidy1 _ _ (OrPat ty lpats)
+tidy1 _ (OrPat ty lpats)
-- See Note [Implementation of OrPatterns]. We desugar
-- (1; 2; 3)
-- to
@@ -514,44 +520,44 @@ tidy1 _ _ (OrPat ty lpats)
single_grhs e = GRHSs emptyComments [noLocA $ GRHS noAnn [] e] (EmptyLocalBinds noExtField)
-- Everything else goes through unchanged...
-tidy1 _ _ non_interesting_pat
+tidy1 _ non_interesting_pat
= return (idDsWrapper, non_interesting_pat)
--------------------
-tidy_bang_pat :: MatchId -> Bool -> SrcSpanAnnA -> Pat GhcTc
+tidy_bang_pat :: MatchId -> SrcSpanAnnA -> Pat GhcTc
-> DsM (DsWrapper, Pat GhcTc)
-- Discard par/sig under a bang
-tidy_bang_pat v g _ (ParPat _ (L l p)) = tidy_bang_pat v g l p
-tidy_bang_pat v g _ (SigPat _ (L l p) _) = tidy_bang_pat v g l p
+tidy_bang_pat v _ (ParPat _ (L l p)) = putSrcSpanDsA l $ tidy_bang_pat v l p
+tidy_bang_pat v _ (SigPat _ (L l p) _) = putSrcSpanDsA l $ tidy_bang_pat v l p
-- Push the bang-pattern inwards, in the hope that
-- it may disappear next time
-tidy_bang_pat v g l (AsPat x v' p)
- = tidy1 v g (AsPat x v' (L l (BangPat noExtField p)))
-tidy_bang_pat v g l (XPat (CoPat w p t))
- = tidy1 v g (XPat $ CoPat w (BangPat noExtField (L l p)) t)
-tidy_bang_pat v g l (OrPat x (p:|ps)) -- push bang into first pat alt
- = tidy1 v g (OrPat x (L l (BangPat noExtField p) :| ps))
+tidy_bang_pat v l (AsPat x v' p)
+ = tidy1 v (AsPat x v' (L l (BangPat noExtField p)))
+tidy_bang_pat v l (XPat (CoPat w p t))
+ = tidy1 v (XPat $ CoPat w (BangPat noExtField (L l p)) t)
+tidy_bang_pat v l (OrPat x (p:|ps)) -- push bang into first pat alt
+ = tidy1 v (OrPat x (L l (BangPat noExtField p) :| ps))
-- Discard bang around strict pattern
-tidy_bang_pat v g _ p@(LitPat {}) = tidy1 v g p
-tidy_bang_pat v g _ p@(ListPat {}) = tidy1 v g p
-tidy_bang_pat v g _ p@(TuplePat {}) = tidy1 v g p
-tidy_bang_pat v g _ p@(SumPat {}) = tidy1 v g p
+tidy_bang_pat v _ p@(LitPat {}) = tidy1 v p
+tidy_bang_pat v _ p@(ListPat {}) = tidy1 v p
+tidy_bang_pat v _ p@(TuplePat {}) = tidy1 v p
+tidy_bang_pat v _ p@(SumPat {}) = tidy1 v p
-- Data/newtype constructors
-tidy_bang_pat v g l p@(ConPat { pat_con = L _ (RealDataCon dc)
- , pat_args = args
- , pat_con_ext = ConPatTc
- { cpt_arg_tys = arg_tys
- }
- })
+tidy_bang_pat v l p@(ConPat { pat_con = L _ (RealDataCon dc)
+ , pat_args = args
+ , pat_con_ext = ConPatTc
+ { cpt_arg_tys = arg_tys
+ }
+ })
-- Newtypes: push bang inwards (#9844)
=
if isNewTyCon (dataConTyCon dc)
- then tidy1 v g (p { pat_args = push_bang_into_newtype_arg l (scaledThing ty) args })
- else tidy1 v g p -- Data types: discard the bang
+ then tidy1 v (p { pat_args = push_bang_into_newtype_arg l (scaledThing ty) args })
+ else tidy1 v p -- Data types: discard the bang
where
(ty:_) = dataConInstArgTys dc arg_tys
@@ -570,7 +576,7 @@ tidy_bang_pat v g l p@(ConPat { pat_con = L _ (RealDataCon dc)
--
-- NB: SigPatIn, ConPatIn should not happen
-tidy_bang_pat _ _ l p = return (idDsWrapper, BangPat noExtField (L l p))
+tidy_bang_pat _ l p = return (idDsWrapper, BangPat noExtField (L l p))
-------------------
push_bang_into_newtype_arg :: SrcSpanAnnA
@@ -954,7 +960,7 @@ matchSinglePatVar var mb_scrut ctx pat ty match_result
; ldi_nablas <-
if isMatchContextPmChecked_SinglePat dflags FromSource ctx pat
then addCoreScrutTmCs (maybeToList mb_scrut) [var] $
- pmcPatBind (DsMatchContext ctx locn) var (unLoc pat)
+ pmcPatBind (DsMatchContext ctx locn) var pat
else getLdiNablas
; let eqn_info = EqnMatch { eqn_pat = decideBangHood dflags pat
=====================================
compiler/GHC/HsToCore/Match/Literal.hs
=====================================
@@ -33,6 +33,7 @@ import GHC.HsToCore.Utils
import GHC.Hs
+import GHC.Rename.Utils (wrapGenSpan)
import GHC.Tc.Utils.TcMType ( shortCutLit )
import GHC.Tc.Utils.TcType
@@ -580,7 +581,8 @@ tidyNPat (OverLit (OverLitTc False _ ty) val) mb_neg _eq outer_ty
mk_con_pat :: DataCon -> HsLit GhcTc -> Pat GhcTc
mk_con_pat con lit
- = unLoc (mkPrefixConPat con [noLocA $ LitPat noExtField lit] [])
+ -- Mark the generated literal to avoid duplicate -Woverflowed-literals.
+ = unLoc (mkPrefixConPat con [wrapGenSpan $ LitPat noExtField lit] [])
mb_int_lit :: Maybe Integer
mb_int_lit = case (mb_neg, val) of
=====================================
compiler/GHC/HsToCore/Monad.hs
=====================================
@@ -15,7 +15,7 @@ module GHC.HsToCore.Monad (
duplicateLocalDs, newSysLocalDs, newSysLocalsDs,
newSysLocalMDs, newSysLocalsMDs, newFailLocalMDs,
newUniqueId, newPredVarDs, newStaticId,
- getSrcSpanDs, putSrcSpanDs, putSrcSpanDsA,
+ getSrcSpanDs, inGeneratedCodeDs, putSrcSpanDs, putSrcSpanDsA,
mkNamePprCtxDs,
newUnique,
UniqSupply, newUniqueSupply,
@@ -584,6 +584,7 @@ mkDsEnvs unit_env mod rdr_env type_env fam_inst_env tcm_plugins ptc msg_var
, dsl_loc = real_span
, dsl_nablas = Ldi initNablas
, dsl_unspecables = Just emptyVarSet
+ , dsl_in_generated_code = False
}
in (gbl_env, lcl_env)
@@ -676,13 +677,17 @@ getSrcSpanDs :: DsM SrcSpan
getSrcSpanDs = do { env <- getLclEnv
; return (RealSrcSpan (dsl_loc env) Strict.Nothing) }
+-- | See 'dsl_in_generated_code'
+inGeneratedCodeDs :: DsM Bool
+inGeneratedCodeDs = dsl_in_generated_code <$> getLclEnv
+
putSrcSpanDs :: SrcSpan -> DsM a -> DsM a
putSrcSpanDs (RealSrcSpan real_span _) thing_inside
- = updLclEnv (\ env -> env {dsl_loc = real_span}) thing_inside
+ = updLclEnv (\ env -> env {dsl_loc = real_span, dsl_in_generated_code = False}) thing_inside
putSrcSpanDs UnhelpfulSpan{} thing_inside
= thing_inside
putSrcSpanDs GeneratedSrcSpan{} thing_inside
- = thing_inside
+ = updLclEnv (\ env -> env {dsl_in_generated_code = True}) thing_inside
putSrcSpanDsA :: EpAnn ann -> DsM a -> DsM a
putSrcSpanDsA loc = putSrcSpanDs (locA loc)
=====================================
compiler/GHC/HsToCore/Pmc.hs
=====================================
@@ -104,7 +104,7 @@ whenDoingPmc no_pmc thing_inside
Ldi nablas -> thing_inside nablas }
-- | Check a pattern binding (let, where) for exhaustiveness.
-pmcPatBind :: DsMatchContext -> Id -> Pat GhcTc -> DsM LdiNablas
+pmcPatBind :: DsMatchContext -> Id -> LPat GhcTc -> DsM LdiNablas
pmcPatBind ctxt@(DsMatchContext match_ctxt loc) var p
= whenDoingPmc NoPmc $ \ !missing ->
mb_discard_warnings $ do
=====================================
compiler/GHC/HsToCore/Pmc/Desugar.hs
=====================================
@@ -155,11 +155,15 @@ desugarPat x pat = case pat of
VarPat _ y -> pure (mkPmLetVar (unLoc y) x)
ParPat _ p -> desugarLPat x p
LazyPat _ _ -> pure GdEnd -- like a wildcard
- BangPat _ p@(L l p') ->
+ BangPat _ p@(L l p') -> do
-- Add the bang in front of the list, because it will happen before any
-- nested stuff.
+ in_gen <- inGeneratedCodeDs
+ -- A bang inserted by -XStrict (decideBangHood) has no SrcInfo: it is
+ -- divergence-checked but never reported as redundant (#27323).
+ let pm_loc | in_gen = Nothing
+ | otherwise = Just (SrcInfo (L (locA l) (ppr p')))
consGrdDag (PmBang x pm_loc) <$> desugarLPat x p
- where pm_loc = Just (SrcInfo (L (locA l) (ppr p')))
-- (x@pat) ==> Desugar pat with x as match var and handle impedance
-- mismatch with incoming match var
@@ -311,11 +315,11 @@ desugarPatV pat = do
pure (x, grds)
desugarLPat :: Id -> LPat GhcTc -> DsM GrdDag
-desugarLPat x = desugarPat x . unLoc
+desugarLPat x (L loc pat) = putSrcSpanDsA loc (desugarPat x pat)
-- | 'desugarLPat', but also select and return a new match var.
desugarLPatV :: LPat GhcTc -> DsM (Id, GrdDag)
-desugarLPatV = desugarPatV . unLoc
+desugarLPatV (L loc pat) = putSrcSpanDsA loc (desugarPatV pat)
-- | @desugarListPat _ x [p1, ..., pn]@ is basically
-- @desugarConPatOut _ x $(mkListConPatOuts [p1, ..., pn]>@ without ever
@@ -374,11 +378,11 @@ desugarConPatOut x con univ_tys ex_tvs dicts = \case
-- tracePm "ConPatOut" (ppr x $$ ppr con $$ ppr arg_ids)
pure (con_grd `consGrdDag` arg_grds)
-desugarPatBind :: SrcSpan -> Id -> Pat GhcTc -> DsM (PmPatBind Pre)
+desugarPatBind :: SrcSpan -> Id -> LPat GhcTc -> DsM (PmPatBind Pre)
-- See 'GrdPatBind' for how this simply repurposes GrdGRHS.
-- See Note [Suppress warnings in PMC desugaring]
desugarPatBind loc var pat = discardWarningsDs $
- PmPatBind . flip PmGRHS (SrcInfo (L loc (ppr pat))) <$> desugarPat var pat
+ PmPatBind . flip PmGRHS (SrcInfo (L loc (ppr pat))) <$> desugarLPat var pat
desugarEmptyCase :: Id -> DsM PmEmptyCase
desugarEmptyCase var = pure PmEmptyCase { pe_var = var }
@@ -650,4 +654,19 @@ user *had* written a bang:
+ In an equation for ‘idV’: idV !v = ...
So we live with the duplication.
+
+Note that 'decideBangHood' places the bangs it inserts at a 'generatedSrcSpan'.
+When 'desugarLPat' enters such a span, 'putSrcSpanDs' (GHC.HsToCore.Monad)
+records in 'dsl_in_generated_code' that we are desugaring compiler-generated
+code. For a bang in generated code, 'desugarPat' emits a 'PmBang' with no
+'SrcInfo': the checker still performs the divergence check (so the
+inaccessible-RHS warning above survives), but -Wredundant-bang-patterns only
+ever reports bangs the user actually wrote (#27323). See
+Note [Dead bang patterns] in GHC.HsToCore.Pmc.Check.
+
+Eventually the bangs inserted by -XStrict should become expanded patterns,
+following Note [Handling overloaded and rebindable constructs] in
+GHC.Rename.Expr. That would let warnings always display the original
+user-written code, making the decideBangHood duplication described above
+unnecessary. This is tracked as #27677.
-}
=====================================
compiler/GHC/HsToCore/Types.hs
=====================================
@@ -11,7 +11,7 @@ module GHC.HsToCore.Types (
DsMetaEnv, DsMetaVal(..), CompleteMatches
) where
-import GHC.Prelude (Int)
+import GHC.Prelude (Bool, Int)
import Data.IORef
@@ -125,6 +125,7 @@ data DsLclEnv
-- ^ See Note [Desugaring non-canonical evidence]
-- This field collects all un-specialisable evidence variables in scope.
-- Nothing <=> don't collect this info (used for the LHS of Rules)
+ , dsl_in_generated_code :: Bool -- Desugaring compiler-generated or user-written code
}
-- Inside [| |] brackets, the desugarer looks
=====================================
compiler/GHC/HsToCore/Utils.hs
=====================================
@@ -72,6 +72,7 @@ import GHC.Unit.Module
import GHC.Builtin.KnownKeys
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Rename.Utils (wrapGenSpan')
import GHC.Types.SrcLoc
import GHC.Types.Tickish
import GHC.Utils.Misc
@@ -1025,6 +1026,9 @@ Specifically:
-- | Use -XStrict to add a ! or remove a ~
+-- The bang we insert is compiler-generated, so we put it at a generatedSrcSpan.
+-- The pattern-match checker uses this (via dsl_in_generated_code) to avoid reporting
+-- such bangs under -Wredundant-bang-patterns (#27323).
-- See Note [decideBangHood]
decideBangHood :: DynFlags
-> LPat GhcTc -- ^ Original pattern
@@ -1040,7 +1044,7 @@ decideBangHood dflags lpat
ParPat x p -> L l (ParPat x (go p))
LazyPat _ lp' -> lp'
BangPat _ _ -> lp
- _ -> L l (BangPat noExtField lp)
+ _ -> wrapGenSpan' (locA l) (BangPat noExtField lp)
isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr)
=====================================
testsuite/tests/pmcheck/should_compile/T27323.hs
=====================================
@@ -0,0 +1,9 @@
+{-# LANGUAGE MagicHash, Strict #-}
+{-# OPTIONS_GHC -Wredundant-bang-patterns #-}
+
+import GHC.Prim (Int#)
+
+idInt# :: Int# -> Int#
+idInt# x = x
+
+main = pure ()
=====================================
testsuite/tests/pmcheck/should_compile/T27323b.hs
=====================================
@@ -0,0 +1,6 @@
+{-# LANGUAGE Strict, MonoLocalBinds #-}
+{-# OPTIONS_GHC -Wredundant-bang-patterns #-}
+module T27323b where
+
+f :: Int -> Int
+f x = let (a, b) = (x, x) in a + b
=====================================
testsuite/tests/pmcheck/should_compile/all.T
=====================================
@@ -190,4 +190,6 @@ test('T24845', [], compile, [overlapping_incomplete])
test('T22652', [], compile, [overlapping_incomplete])
test('T22652a', [], compile, [overlapping_incomplete])
test('T24867', [], compile_fail, [overlapping_incomplete])
+test('T27323', normal, compile, ['-Wredundant-bang-patterns'])
+test('T27323b', normal, compile, ['-Wredundant-bang-patterns'])
test('T27360', normal, compile, [overlapping_incomplete + '-g3'])
=====================================
testsuite/tests/warnings/should_compile/Overflow.stderr-ws-64
=====================================
@@ -1,18 +1,18 @@
-
Overflow.hs:8:15: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
Literal 10000000000000000000000000000000 is out of the Int# range -9223372036854775808..9223372036854775807
-Overflow.hs:13:1: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
+Overflow.hs:13:3: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
Literal 100000000000000000000000000 is out of the Int# range -9223372036854775808..9223372036854775807
Overflow.hs:18:5: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
Literal 1000000000000000000000000000000 is out of the Int range -9223372036854775808..9223372036854775807
-Overflow.hs:22:1: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
+Overflow.hs:22:3: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
Literal 100000000000000000000000000000000 is out of the Int range -9223372036854775808..9223372036854775807
Overflow.hs:27:6: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
Literal -1 is out of the Word range 0..18446744073709551615
-Overflow.hs:31:1: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
+Overflow.hs:31:4: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
Literal -1 is out of the Word range 0..18446744073709551615
+
=====================================
testsuite/tests/warnings/should_compile/T13256.stderr-ws-64
=====================================
@@ -1,3 +1,3 @@
-
-T13256.hs:4:12: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
+T13256.hs:4:31: warning: [GHC-97441] [-Woverflowed-literals (in -Wdefault)]
Literal 100000000000000000000000000000000 is out of the Int range -9223372036854775808..9223372036854775807
+
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f33efee8e138a79057fb6abe0dec5a4…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f33efee8e138a79057fb6abe0dec5a4…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/T26599] 5 commits: add options for resizing bytearrays (#27244)
by Simon Peyton Jones (@simonpj) 23 Oct '26
by Simon Peyton Jones (@simonpj) 23 Oct '26
23 Oct '26
Simon Peyton Jones pushed to branch wip/T26599 at Glasgow Haskell Compiler / GHC
Commits:
13dff5d0 by L0neGamer at 2026-10-22T21:37:31-04:00
add options for resizing bytearrays (#27244)
add five mutable bytearray resizing operations
for various kinds of pinnedness and aligning.
- prefer unpinned when allocating new array (``resizeMutableByteArrayPreferUnpinned#``; the ``resizeMutableByteArray#`` default)
- prefer pinned when allocating new array (``resizeMutableByteArrayPreferPinned#``)
- prefer aligned and pinned when allocating new array (``resizeMutableByteArrayPreferAlignedPinned#``)
- prefer same as input bytearray when allocating new array (``resizeMutableByteArrayKeepPinnedness#``)
- ensure the output array is aligned and pinned after operation (``resizeMutableByteArrayMakeAlignedPinned#``)
- - - - -
0c17201c by Sylvain Henry at 2026-10-22T21:38:23-04:00
JS: implement performMinorGC and performBlockingMajorGC (#28012)
GHC.Internal.System.Mem imports three C entry points: performMajorGC,
performGC (for performMinorGC) and performBlockingMajorGC. The JS RTS
only defined h$performMajorGC, so calling performMinorGC or
performBlockingMajorGC threw "ReferenceError: h$performGC is not
defined" at runtime.
The JS RTS has a single non-generational collector, so both missing
entry points are now aliases of h$performMajorGC.
Add a test that calls every GC entry point of System.Mem.
Co-Authored-By: Claude Fable 5.1 <noreply(a)anthropic.com>
- - - - -
7a631ff2 by L0neGamer at 2026-10-23T09:11:39-04:00
Mon(a|oi)d of No (Return|Mappend) progress (!15795)
Make non-canonical definitions of return and mappend
non-suppressible errors, and make canonical definitions
of those methods warnings.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/328
- - - - -
14656fd4 by Simon Jakobi at 2026-10-23T09:12:27-04:00
Cmm: keep the CBE substitution idempotent
When blocks are merged over multiple rounds during common block
elimination, a block that won a merge in an earlier round can still
lose a merge in a later round. The substitution map (Subst) used to
record this as a chain: the earlier loser mapped to a block that was
itself eliminated. In PLT terminology, the substitution became
*non-idempotent*. Applying such a substitution with a single lookup
left edges to unreachable blocks in the Cmm graph, eventually leading
to a setInfoTableStackMap panic (#27368).
With this patch, each round's fresh substitutions are applied to the old
ones as they are added (extendSubst), so every eliminated block maps
directly to its final replacement and the substitution stays idempotent.
Fixes #27368.
Assisted-by: Claude Fable 5.1
- - - - -
381ae687 by Simon Peyton Jones at 2026-10-23T15:02:25+01:00
Refactor QuickLook a bit
This MR simply refactors QuickLook a bit. In particular, it
simplifies `tcApp`, and moves shared code into `finishApp`.
It also adds `Note [QuickLook: arguments before result]`
responding to #26599.
There should be no user-visible changes, except perhaps in error messages,
which improve marginally.
For some reason T24984 compiles 8% faster. I'll take the win!
Metric Decrease:
T24984
- - - - -
126 changed files:
- + changelog.d/27368
- + changelog.d/28012
- + changelog.d/monad-of-no-return-canonical
- + changelog.d/resizeMutableByteArray-pinnedness
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/Cmm/CommonBlockElim.hs
- compiler/GHC/CmmToAsm/CFG/Dominators.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Data/OrdList.hs
- compiler/GHC/Data/Pair.hs
- compiler/GHC/Data/Word64Map/Internal.hs
- compiler/GHC/Data/Word64Set/Internal.hs
- compiler/GHC/Driver/CmdLine.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/HsToCore/Pmc/Types.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/JS/Opt/Simple.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Prim.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Unique/FM.hs
- compiler/GHC/Types/Unique/Map.hs
- compiler/GHC/Unit/External/ModuleOrigin.hs
- compiler/GHC/Unit/External/Visibility.hs
- compiler/GHC/Utils/Monad/Codensity.hs
- compiler/GHC/Utils/Ppr/Colour.hs
- compiler/ghc.cabal.in
- docs/users_guide/using-warnings.rst
- ghc/ghc-bin.cabal.in
- hadrian/src/Settings/Warnings.hs
- libraries/base/src/GHC/Base.hs
- libraries/base/src/GHC/Exts.hs
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/Base.hs
- libraries/ghc-internal/src/GHC/Internal/Event/Windows.hsc
- rts/PrimOps.cmm
- rts/RtsSymbols.c
- rts/include/stg/MiscClosures.h
- rts/js/environment.js
- testsuite/tests/ado/ado-optimal.hs
- testsuite/tests/ado/ado001.hs
- + testsuite/tests/codeGen/should_compile/T27368.hs
- testsuite/tests/codeGen/should_compile/all.T
- testsuite/tests/concurrent/T13615/Parallel.hs
- testsuite/tests/concurrent/should_run/T21651.hs
- testsuite/tests/concurrent/should_run/setnumcapabilities001.hs
- testsuite/tests/cpranal/should_run/T20598a.hs
- testsuite/tests/deriving/should_compile/T13758.hs
- testsuite/tests/deriving/should_run/all.T
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.hs
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.stderr
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.stdout
- testsuite/tests/determinism/determ017/A.hs
- testsuite/tests/dmdanal/should_compile/T9208.hs
- testsuite/tests/generics/T27245.hs
- testsuite/tests/generics/T27245.stdout
- testsuite/tests/ghci.debugger/scripts/T14628.stderr
- testsuite/tests/haddock/perf/Fold.hs
- testsuite/tests/hiefile/should_compile/hie002.hs
- testsuite/tests/hpc/raytrace/Eval.hs
- testsuite/tests/indexed-types/should_compile/T3787.hs
- testsuite/tests/indexed-types/should_fail/T7729.hs
- testsuite/tests/indexed-types/should_fail/T7729a.hs
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/module/mod133.hs
- testsuite/tests/perf/compiler/T13253.hs
- testsuite/tests/perf/compiler/T14683.hs
- testsuite/tests/perf/compiler/T16473.hs
- testsuite/tests/perf/compiler/T18730_A.hs
- testsuite/tests/perf/compiler/T25723.hs
- testsuite/tests/pmcheck/should_compile/T11276.hs
- + testsuite/tests/primops/should_run/ResizeByteArrayPinnedness.hs
- + testsuite/tests/primops/should_run/ResizeByteArrayPinnedness.stdout
- testsuite/tests/primops/should_run/all.T
- testsuite/tests/profiling/should_compile/T19894/StreamK.hs
- testsuite/tests/profiling/should_run/T3001-2.hs
- testsuite/tests/programs/galois_raytrace/Eval.hs
- testsuite/tests/rebindable/rebindable2.hs
- + testsuite/tests/rename/should_fail/Noncanonical.hs
- + testsuite/tests/rename/should_fail/Noncanonical.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/rename/should_fail/rnfail026.hs
- + testsuite/tests/rts/T28012.hs
- + testsuite/tests/rts/T28012.stdout
- testsuite/tests/rts/all.T
- testsuite/tests/rts/ipe/IpeStats/Fold.hs
- testsuite/tests/simplCore/should_compile/T14908_Deps.hs
- testsuite/tests/simplCore/should_compile/simpl017.hs
- testsuite/tests/typecheck/should_compile/DeepSubsumption02.hs
- testsuite/tests/typecheck/should_compile/T4524.hs
- testsuite/tests/typecheck/should_compile/T4969.hs
- testsuite/tests/typecheck/should_fail/T22707.hs
- testsuite/tests/typecheck/should_fail/T22707.stderr
- testsuite/tests/typecheck/should_fail/T25950.stderr
- testsuite/tests/typecheck/should_fail/T7019.hs
- testsuite/tests/typecheck/should_fail/T8450.stderr
- testsuite/tests/typecheck/should_fail/T8603.hs
- + testsuite/tests/warnings/should_compile/RedundantCanonicalMethods.hs
- + testsuite/tests/warnings/should_compile/RedundantCanonicalMethods.stderr
- testsuite/tests/warnings/should_compile/WarnNoncanonical.hs
- testsuite/tests/warnings/should_compile/WarnNoncanonical.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/haddock/haddock-api/haddock-api.cabal
- utils/haddock/haddock-api/src/Haddock/Interface/ParseModuleHeader.hs
- utils/haddock/haddock-api/src/Haddock/Utils/Json.hs
- utils/haddock/haddock-library/haddock-library.cabal
- utils/haddock/haddock.cabal
- utils/runghc/Main.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1abedd1a26a4e6b50ad6b89c8fdd10…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1abedd1a26a4e6b50ad6b89c8fdd10…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0