[Git][ghc/ghc][wip/T27078] Kill off the substitution in Lint
by Simon Peyton Jones (ļ¼ simonpj) 06 Apr '26
by Simon Peyton Jones (ļ¼ simonpj) 06 Apr '26
06 Apr '26
Simon Peyton Jones pushed to branch wip/T27078 at Glasgow Haskell Compiler / GHC
Commits:
b97d30eb by Simon Peyton Jones at 2026-04-06T11:14:51+01:00
Kill off the substitution in Lint
Now that we have invariant (NoTypeShadowing) we no longer
need Lint to carry an ambient substitution. This makes it
simpler and faster. A really worthwhile refactor.
There are some knock-on effects
* Linting join points after worker/wrapper. See
Note [Join points and beta redexes]
* Running a type substitution after the desugarer.
See Note [Substituting type-lets] in
the new module GHC.Core.SubstTypeLets
Implements #27078
Most perf tests don't use Lint so we won't see a perf incresae.
But T1969 improves a bit for some reason.
Metric Decrease:
T1969
- - - - -
9 changed files:
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs
- compiler/GHC/Core/Subst.hs
- + compiler/GHC/Core/SubstTypeLets.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/ghc.cabal.in
- testsuite/tests/corelint/LintEtaExpand.stderr
- testsuite/tests/corelint/T21115b.stderr
Changes:
=====================================
compiler/GHC/Core/Lint.hs
=====================================
@@ -46,6 +46,7 @@ import GHC.Core.FVs
import GHC.Core.Utils
import GHC.Core.Stats ( coreBindsStats )
import GHC.Core.DataCon
+import GHC.Core.SubstTypeLets( substTypeLets )
import GHC.Core.Ppr
import GHC.Core.Coercion
import GHC.Core.Type as Type
@@ -178,65 +179,7 @@ Note [Linting function types]
All saturated applications of funTyCon are represented with the FunTy constructor.
See Note [Function type constructors and FunTy] in GHC.Builtin.Types.Prim
- We check this invariant in lintType.
-
-Note [Linting type lets]
-~~~~~~~~~~~~~~~~~~~~~~~~
-In the desugarer, it's very very convenient to be able to say (in effect)
- let a = Type Bool in
- let x::a = True in <body>
-That is, use a type let. See Note [Core type and coercion invariant] in "GHC.Core".
-One place it is used is in mkWwBodies; see Note [Join points and beta-redexes]
-in GHC.Core.Opt.WorkWrap.Utils. (Maybe there are other "clients" of this feature; I'm not sure).
-
-* Hence when linting <body> we need to remember that a=Int, else we
- might reject a correct program. So we carry a type substitution (in
- this example [a -> Bool]) and apply this substitution before
- comparing types. In effect, in Lint, type equality is always
- equality-modulo-le-subst. This is in the le_subst field of
- LintEnv. But nota bene:
-
- (SI1) The le_subst substitution is applied to types and coercions only
-
- (SI2) The result of that substitution is used only to check for type
- equality, to check well-typed-ness, /but is then discarded/.
- The result of substitution does not outlive the CoreLint pass.
-
- (SI3) The InScopeSet of le_subst includes only TyVar and CoVar binders.
-
-* The function
- lintInTy :: Type -> LintM (Type, Kind)
- returns a substituted type.
-
-* When we encounter a binder (like x::a) we must apply the substitution
- to the type of the binding variable. lintBinders does this.
-
-* Clearly we need to clone tyvar binders as we go.
-
-* But take care (#17590)! We must also clone CoVar binders:
- let a = TYPE (ty |> cv)
- in \cv -> blah
- blindly substituting for `a` might capture `cv`.
-
-* Alas, when cloning a coercion variable we might choose a unique
- that happens to clash with an inner Id, thus
- \cv_66 -> let wild_X7 = blah in blah
- We decide to clone `cv_66` because it's already in scope. Fine,
- choose a new unique. Aha, X7 looks good. So we check the lambda
- body with le_subst of [cv_66 :-> cv_X7]
-
- This is all fine, even though we use the same unique as wild_X7.
- As (SI2) says, we do /not/ return a new lambda
- (\cv_X7 -> let wild_X7 = blah in ...)
- We simply use the le_subst substitution in types/coercions only, when
- checking for equality.
-
-* We still need to check that Id occurrences are bound by some
- enclosing binding. We do /not/ use the InScopeSet for the le_subst
- for this purpose -- it contains only TyCoVars. Instead we have a separate
- le_ids for the in-scope Id binders.
-
-Sigh. We might want to explore getting rid of type-let!
+We check this invariant in lintType.
Note [Bad unsafe coercion]
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -311,6 +254,7 @@ path does not result in allocation in the hot path. This can be surprisingly
impactful. Changing `lint_app` reduced allocations for one test program I was
looking at by ~4%.
+
************************************************************************
* *
Beginning and ending passes
@@ -407,26 +351,37 @@ data LintPassResultConfig = LintPassResultConfig
, lpr_platform :: !Platform
, lpr_makeLintFlags :: !LintFlags
, lpr_passPpr :: !SDoc
+ , lpr_preSubst :: !Bool -- True <=> run substTypeLets before linting
+ -- See Note [Substituting type-lets]
, lpr_localsInScope :: ![Var]
}
lintPassResult :: Logger -> LintPassResultConfig
-> CoreProgram -> IO ()
lintPassResult logger cfg binds
- = do { let warns_and_errs = lintCoreBindings'
- (LintConfig
+ = do { let lint_config = LintConfig
{ l_diagOpts = lpr_diagOpts cfg
, l_platform = lpr_platform cfg
, l_flags = lpr_makeLintFlags cfg
, l_vars = lpr_localsInScope cfg
- })
- binds
+ }
+
+ -- Do the pre-substitution if necessary
+ -- See Note [Substituting type-lets] in GHC.Core.SubstTypeLets
+ -- especially wrinkle (STL2)
+ ; let binds1 | lpr_preSubst cfg = substTypeLets binds
+ | otherwise = binds
+
+ -- Do the main Lint pass itself
+ ; let warns_and_errs = lintCoreBindings' lint_config binds1
+
+ -- Report the results
; Err.showPass logger $
"Core Linted result of " ++
renderWithContext defaultSDocContext (lpr_passPpr cfg)
; displayLintResults logger
(lpr_passPpr cfg)
- (pprCoreBindings binds) warns_and_errs
+ (pprCoreBindings binds1) warns_and_errs
}
displayLintResults :: Logger
@@ -472,8 +427,7 @@ lintCoreBindings' cfg binds
; checkL (null ext_dups) (dupExtVars ext_dups)
-- Typecheck the bindings
- ; lintRecBindings TopLevel all_pairs $ \_ ->
- return () }
+ ; lintRecBindings TopLevel all_pairs $ return () }
where
all_pairs = flattenBinds binds
-- Put all the top-level binders in scope at the start
@@ -555,11 +509,11 @@ Check a core binding, returning the list of variables bound.
-- Let
lintRecBindings :: TopLevelFlag -> [(Id, CoreExpr)]
- -> ([OutId] -> LintM a) -> LintM (a, [UsageEnv])
+ -> LintM a -> LintM (a, [UsageEnv])
lintRecBindings top_lvl pairs thing_inside
- = lintIdBndrs top_lvl bndrs $ \ bndrs' ->
- do { ues <- zipWithM lint_pair bndrs' rhss
- ; a <- thing_inside bndrs'
+ = lintIdBndrs top_lvl bndrs $
+ do { ues <- zipWithM lint_pair bndrs rhss
+ ; a <- thing_inside
; return (a, ues) }
where
(bndrs, rhss) = unzip pairs
@@ -569,14 +523,14 @@ lintRecBindings top_lvl pairs thing_inside
; lintLetBind top_lvl Recursive bndr' rhs rhs_ty
; return ue }
-lintLetBody :: LintLocInfo -> [OutId] -> CoreExpr -> LintM (OutType, UsageEnv)
+lintLetBody :: LintLocInfo -> [Id] -> CoreExpr -> LintM (Type, UsageEnv)
lintLetBody loc bndrs body
= do { (body_ty, body_ue) <- addLoc loc (lintCoreExpr body)
; mapM_ (lintJoinBndrType body_ty) bndrs
; return (body_ty, body_ue) }
-lintLetBind :: TopLevelFlag -> RecFlag -> OutId
- -> CoreExpr -> OutType -> LintM ()
+lintLetBind :: TopLevelFlag -> RecFlag -> Id
+ -> CoreExpr -> Type -> LintM ()
-- Binder's type, and the RHS, have already been linted
-- This function checks other invariants
lintLetBind top_lvl rec_flag binder rhs rhs_ty
@@ -667,7 +621,7 @@ lintLetBind top_lvl rec_flag binder rhs rhs_ty
-- join point.
--
-- See Note [Checking StaticPtrs].
-lintRhs :: Id -> CoreExpr -> LintM (OutType, UsageEnv)
+lintRhs :: Id -> CoreExpr -> LintM (Type, UsageEnv)
-- NB: the Id can be Linted or not -- it's only used for
-- its OccInfo and join-pointer-hood
lintRhs bndr rhs
@@ -682,7 +636,7 @@ lintRhs _bndr rhs = fmap lf_check_static_ptrs getLintFlags >>= go
where
-- Allow occurrences of 'makeStatic' at the top-level but produce errors
-- otherwise.
- go :: StaticPtrCheck -> LintM (OutType, UsageEnv)
+ go :: StaticPtrCheck -> LintM (Type, UsageEnv)
go AllowAtTopLevel
| (binders0, rhs') <- collectTyBinders rhs
, Just (fun, t, info, e) <- collectMakeStaticArgs rhs'
@@ -699,7 +653,7 @@ lintRhs _bndr rhs = fmap lf_check_static_ptrs getLintFlags >>= go
-- | Lint the RHS of a join point with expected join arity of @n@ (see Note
-- [Join points] in "GHC.Core").
-lintJoinLams :: JoinArity -> Maybe Id -> CoreExpr -> LintM (OutType, UsageEnv)
+lintJoinLams :: JoinArity -> Maybe Id -> CoreExpr -> LintM (Type, UsageEnv)
lintJoinLams join_arity enforce rhs
= go join_arity rhs
where
@@ -887,13 +841,8 @@ suspicious and worth investigating if you have a seg-fault or bizarre behaviour.
************************************************************************
-}
-lintCoreExpr :: InExpr -> LintM (OutType, UsageEnv)
--- The returned type has the substitution from the monad
--- already applied to it:
--- lintCoreExpr e subst = exprType (subst e)
---
--- The returned "type" can be a kind, if the expression is (Type ty)
-
+lintCoreExpr :: CoreExpr -> LintM (Type, UsageEnv)
+-- The returned type is the type of the expression
-- If you edit this function, you may need to update the GHC formalism
-- See Note [GHC Formalism]
@@ -920,7 +869,7 @@ lintCoreExpr (Cast expr co)
; lintCoercion co
; lintRole co Representational (coercionRole co)
- ; Pair from_ty to_ty <- substCoKindM co
+ ; let Pair from_ty to_ty = coercionKind co
; checkValueType (typeKind to_ty) $
text "target of cast" <+> quotes (ppr co)
; ensureEqTys from_ty expr_ty (mkCastErr expr co from_ty expr_ty)
@@ -934,15 +883,10 @@ lintCoreExpr (Tick tickish expr)
lintCoreExpr (Let (NonRec tv (Type ty)) body)
| isTyVar tv
- = -- See Note [Linting type lets]
- do { ty' <- lintTypeAndSubst ty
- ; lintTyCoBndr tv $ \ tv' ->
- do { addLoc (RhsOf tv) $ lintTyKind tv' ty'
- -- Now extend the substitution so we
- -- take advantage of it in the body
- ; extendTvSubstL tv ty' $
- addLoc (BodyOfLet tv) $
- lintCoreExpr body } }
+ = do { lintType ty
+ ; lintTyCoBndr tv $
+ do { addLoc (RhsOf tv) $ lintTyKind tv ty
+ ; addLoc (BodyOfLet tv) $ lintCoreExpr body } }
lintCoreExpr (Let (NonRec bndr rhs) body)
| isId bndr
@@ -951,10 +895,10 @@ lintCoreExpr (Let (NonRec bndr rhs) body)
-- See Note [Multiplicity of let binders] in Var
-- Now lint the binder
- ; lintBinder LetBind bndr $ \bndr' ->
- do { lintLetBind NotTopLevel NonRecursive bndr' rhs rhs_ty
- ; addAliasUE bndr' let_ue $
- lintLetBody (BodyOfLet bndr') [bndr'] body } }
+ ; lintBinder LetBind bndr $
+ do { lintLetBind NotTopLevel NonRecursive bndr rhs rhs_ty
+ ; addAliasUE bndr let_ue $
+ lintLetBody (BodyOfLet bndr) [bndr] body } }
| otherwise
= failWithL (mkLetErr bndr rhs) -- Not quite accurate
@@ -973,8 +917,8 @@ lintCoreExpr e@(Let (Rec pairs) body)
-- See Note [Multiplicity of let binders] in Var
; ((body_type, body_ue), ues) <-
- lintRecBindings NotTopLevel pairs $ \ bndrs' ->
- lintLetBody (BodyOfLetRec bndrs') bndrs' body
+ lintRecBindings NotTopLevel pairs $
+ lintLetBody (BodyOfLetRec bndrs) bndrs body
; return (body_type, body_ue `addUE` scaleUE ManyTy (foldr1WithDefault zeroUE addUE ues)) }
where
bndrs = map fst pairs
@@ -986,7 +930,7 @@ lintCoreExpr e@(App _ _)
-- N.B. we may have an over-saturated application of the form:
-- runRW (\s -> \x -> ...) y
, ty_arg1 : ty_arg2 : cont_arg : rest <- args
- = do { let lint_rw_cont :: CoreArg -> Mult -> UsageEnv -> LintM (OutType, UsageEnv)
+ = do { let lint_rw_cont :: CoreArg -> Mult -> UsageEnv -> LintM (Type, UsageEnv)
lint_rw_cont expr@(Lam _ _) mult fun_ue
= do { (arg_ty, arg_ue) <- lintJoinLams 1 (Just fun) expr
; let app_ue = addUE fun_ue (scaleUE mult arg_ue)
@@ -1036,74 +980,73 @@ lintCoreExpr (Type ty)
lintCoreExpr (Coercion co)
-- See Note [Coercions in terms]
= do { addLoc (InCo co) $ lintCoercion co
- ; ty <- substTyM (coercionType co)
+ ; let ty = coercionType co
; return (ty, zeroUE) }
----------------------
-lintIdOcc :: InId -> Int -- Number of arguments (type or value) being passed
- -> LintM (OutType, UsageEnv) -- returns type of the *variable*
-lintIdOcc in_id nargs
- = addLoc (OccOf in_id) $
- do { checkL (isNonCoVarId in_id)
- (text "Non term variable" <+> ppr in_id)
+lintIdOcc :: Id -> Int -- Number of arguments (type or value) being passed
+ -> LintM (Type, UsageEnv) -- returns type of the *variable*
+lintIdOcc id nargs
+ = addLoc (OccOf id) $
+ do { checkL (isNonCoVarId id)
+ (text "Non term variable" <+> ppr id)
-- See GHC.Core Note [Variable occurrences in Core]
- -- Check that the type of the occurrence is the same
- -- as the type of the binding site. The inScopeIds are
- -- /un-substituted/, so this checks that the occurrence type
- -- is identical to the binder type.
- -- This makes things much easier for things like:
- -- /\a. \(x::Maybe a). /\a. ...(x::Maybe a)...
- -- The "::Maybe a" on the occurrence is referring to the /outer/ a.
- -- If we compared /substituted/ types we'd risk comparing
- -- (Maybe a) from the binding site with bogus (Maybe a1) from
- -- the occurrence site. Comparing un-substituted types finesses
- -- this altogether
- ; out_ty <- lintVarOcc in_id
+ ; lintVarOcc id
-- Check for a nested occurrence of the StaticPtr constructor.
-- See Note [Checking StaticPtrs].
; when (nargs /= 0) $
- checkL (idName in_id /= makeStaticName) $
+ checkL (idName id /= makeStaticName) $
text "Found makeStatic nested in an expression"
- ; checkDeadIdOcc in_id
+ ; checkDeadIdOcc id
- ; case isDataConId_maybe in_id of
+ ; case isDataConId_maybe id of
Nothing -> return ()
Just dc -> checkTypeDataConOcc "expression" dc
- ; checkJoinOcc in_id nargs
- ; usage <- varCallSiteUsage in_id
-
- ; return (out_ty, usage) }
+ ; checkJoinOcc id nargs
+ ; usage <- varCallSiteUsage id
+ ; return (idType id, usage) }
+------------------
lintCoreFun :: CoreExpr
- -> Int -- Number of arguments (type or val) being passed
- -> LintM (OutType, UsageEnv) -- Returns type of the *function*
+ -> Int -- Number of arguments (type or val) being passed
+ -> LintM (Type, UsageEnv) -- Returns type of the *function*
lintCoreFun (Var var) nargs
= lintIdOcc var nargs
lintCoreFun (Lam var body) nargs
- -- Act like lintCoreExpr of Lam, but *don't* call markAllJoinsBad;
- -- See Note [Beta redexes]
+ -- Act like lintCoreExpr of Lam, but *don't* necessarily call markAllJoinsBad;
+ -- See Note [Join points and beta-redexes]
| nargs /= 0
= lintLambda var $ lintCoreFun body (nargs - 1)
lintCoreFun expr nargs
- = markAllJoinsBadIf (nargs /= 0) $
- -- See Note [Join points are less general than the paper]
- lintCoreExpr expr
+ = do { mark_bad_joins
+ <- if nargs == 0
+ then -- Saturated lambda
+ -- See Note [Join points and beta-redexes]
+ do { flags <- getLintFlags
+ ; return (not (lf_allow_beta_joins flags)) }
+ else -- Something else
+ -- See Note [Join points are less general than the paper]
+ return True
+
+ ; markAllJoinsBadIf mark_bad_joins $
+ lintCoreExpr expr }
+
------------------
lintLambda :: Var -> LintM (Type, UsageEnv) -> LintM (Type, UsageEnv)
lintLambda var lintBody =
addLoc (LambdaBodyOf var) $
- lintBinder LambdaBind var $ \ var' ->
+ lintBinder LambdaBind var $
do { (body_ty, ue) <- lintBody
- ; ue' <- checkLinearity ue var'
- ; return (mkLamType var' body_ty, ue') }
+ ; ue' <- checkLinearity ue var
+ ; return (mkLamType var body_ty, ue') }
------------------
checkDeadIdOcc :: Id -> LintM ()
-- Occurrences of an Id should never be dead....
@@ -1117,8 +1060,8 @@ checkDeadIdOcc id
= return ()
------------------
-lintJoinBndrType :: OutType -- Type of the body
- -> OutId -- Possibly a join Id
+lintJoinBndrType :: Type -- Type of the body
+ -> Id -- Possibly a join Id
-> LintM ()
-- Checks that the return type of a join Id matches the body
-- E.g. join j x = rhs in body
@@ -1337,8 +1280,51 @@ checkLinearity body_ue lam_var =
return body_ue'
Nothing -> return body_ue -- A type variable
-{- Note [Linting join points with casts or ticks]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+{- Note [Join points and beta-redexes]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+In the worker/wrapper pass, the worker invokes the original function by calling
+it with arguments, thus producing a beta-redex for the simplifier to munch away:
+
+ \x y z -> e => (\x y z -> e) wx wy wz
+
+But we need to take care if `e` invokes a join point. For example:
+
+ join j1 x = ...
+ join j2 y = if y == 0 then 0 else j1 y
+=>
+ join j1 x = ...
+ join $wj2 y# = (\y -> if y == 0 then 0 else jump j1 y) (I# y#)
+ join j2 y = case y of I# y# -> jump $wj2 y#
+
+Now the jump to `j1` is inside a lambda and inside an application. That is ill-typed
+from Lint's point of view. And yet, after one round of simplification it'll all be
+fine.
+
+You might wonder if we could use a `let` instead of a lambda for the worker:
+
+ join $wj2 y# = let y = I# y#
+ in if y == 0 then 0 else jump j1 y
+
+That would solve the join-point problem, but it really doesn't work because the
+lets shadow each other. The lambda arguments should not "see" any of the
+lambda-bound variables.
+
+So our solution is this:
+
+* Use straightforward applicaion in the worker-wrapper pass, creating a eta-redex.
+ See the call to `mkApps` in GHC.Core.Opt.WorkWrap.Utils.mkWwBodies.
+
+* Tell Lint not to complain about a join-point invocation hidden under a
+ saturated beta-redex. The code is rather simple: see `lintCoreFun`.
+
+* We guard this with a Lint flag `lf_allow_beta_joins`.
+
+* Teach occurrence analysis that `j1` is still a join point, despite its
+ call being nested inside the beta-redex. See Note [occAnal for applications]
+ in GHC.Core.Opt.OccurAnal.
+
+Note [Linting join points with casts or ticks]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As per Note [Join points, casts, and ticks] in GHC.Core, we have to be careful
when a cast or tick occurs in between a join point binding and a corresponding
join point occurrence.
@@ -1409,33 +1395,6 @@ lose track of why an expression is bottom, so we shouldn't make too
much fuss when that happens.
-Note [Beta redexes]
-~~~~~~~~~~~~~~~~~~~
-Consider:
-
- join j @x y z = ... in
- (\@x y z -> jump j @x y z) @t e1 e2
-
-This is clearly ill-typed, since the jump is inside both an application and a
-lambda, either of which is enough to disqualify it as a tail call (see Note
-[Invariants on join points] in GHC.Core). However, strictly from a
-lambda-calculus perspective, the term doesn't go wrong---after the two beta
-reductions, the jump *is* a tail call and everything is fine.
-
-Why would we want to allow this when we have let? One reason is that a compound
-beta redex (that is, one with more than one argument) has different scoping
-rules: naively reducing the above example using lets will capture any free
-occurrence of y in e2. More fundamentally, type lets are tricky; many passes,
-such as Float Out, tacitly assume that the incoming program's type lets have
-all been dealt with by the simplifier. Thus we don't want to let-bind any types
-in, say, GHC.Core.Subst.simpleOptPgm, which in some circumstances can run immediately
-before Float Out.
-
-All that said, currently GHC.Core.Subst.simpleOptPgm is the only thing using this
-loophole, doing so to avoid re-traversing large functions (beta-reducing a type
-lambda without introducing a type let requires a substitution). TODO: Improve
-simpleOptPgm so that we can forget all this ever happened.
-
************************************************************************
* *
\subsection[lintCoreArgs]{lintCoreArgs}
@@ -1449,23 +1408,23 @@ subtype of the required type, as one would expect.
-- Takes the functions type and arguments as argument.
-- Returns the *result* of applying the function to arguments.
-- e.g. f :: Int -> Bool -> Int would return `Int` as result type.
-lintCoreArgs :: (OutType, UsageEnv) -> [InExpr] -> LintM (OutType, UsageEnv)
+lintCoreArgs :: (Type, UsageEnv) -> [CoreExpr] -> LintM (Type, UsageEnv)
lintCoreArgs (fun_ty, fun_ue) args
- = lintApp (text "expression")
- lintTyArg lintValArg fun_ty args fun_ue
+ = lintApp (text "expression") lintTyArg lintValArg fun_ty args fun_ue
-lintTyArg :: InExpr -> LintM OutType
+lintTyArg :: CoreExpr -> LintM Type
-- Type argument
lintTyArg (Type arg_ty)
= do { checkL (not (isCoercionTy arg_ty))
(text "Unnecessary coercion-to-type injection:"
<+> ppr arg_ty)
- ; lintTypeAndSubst arg_ty }
+ ; lintType arg_ty
+ ; return arg_ty }
lintTyArg arg
= failWithL (hang (text "Expected type argument but found") 2 (ppr arg))
-lintValArg :: InExpr -> Mult -> UsageEnv -> LintM (OutType, UsageEnv)
+lintValArg :: CoreExpr -> Mult -> UsageEnv -> LintM (Type, UsageEnv)
lintValArg arg mult fun_ue
= do { (arg_ty, arg_ue) <- markAllJoinsBad $ lintCoreExpr arg
-- See Note [Representation polymorphism invariants] in GHC.Core
@@ -1485,12 +1444,18 @@ lintValArg arg mult fun_ue
-----------------
lintAltBinders :: UsageEnv
-> Var -- Case binder
- -> OutType -- Scrutinee type
- -> OutType -- Constructor type
+ -> Type -- Scrutinee type
+ -> Type -- Constructor type
-> [(Mult, OutVar)] -- Binders
-> LintM UsageEnv
-- If you edit this function, you may need to update the GHC formalism
-- See Note [GHC Formalism]
+{-
+lintAltBinders rhs_ue _case_bndr scrut_ty con_ty bndrs
+ = do { (res_ty, rhs_ue') <- lintApp (text ".") lintTyBndr lintValBndr con_ty bndrs
+ ; ensureEqTys res_ty scrut_ty (mkBadPatMsg con_ty scrut_ty)
+ ; return rhs_ue }
+-}
lintAltBinders rhs_ue _case_bndr scrut_ty con_ty []
= do { ensureEqTys con_ty scrut_ty (mkBadPatMsg con_ty scrut_ty)
; return rhs_ue }
@@ -1505,6 +1470,7 @@ lintAltBinders rhs_ue case_bndr scrut_ty con_ty ((var_w, bndr):bndrs)
; rhs_ue' <- checkCaseLinearity rhs_ue case_bndr var_w bndr
; lintAltBinders rhs_ue' case_bndr scrut_ty con_ty' bndrs }
+
-- | Implements the case rules for linearity
checkCaseLinearity :: UsageEnv -> Var -> Mult -> Var -> LintM UsageEnv
checkCaseLinearity ue case_bndr var_w bndr = do
@@ -1529,7 +1495,7 @@ checkCaseLinearity ue case_bndr var_w bndr = do
-----------------
-lintTyApp :: OutType -> OutType -> LintM OutType
+lintTyApp :: Type -> Type -> LintM Type
lintTyApp fun_ty arg_ty
| Just (tv,body_ty) <- splitForAllTyVar_maybe fun_ty
= do { lintTyKind tv arg_ty
@@ -1547,8 +1513,8 @@ lintTyApp fun_ty arg_ty
-- | @lintValApp arg fun_ty arg_ty@ lints an application of @fun arg@
-- where @fun :: fun_ty@ and @arg :: arg_ty@, returning the type of the
-- application.
-lintValApp :: CoreExpr -> OutType -> OutType -> UsageEnv -> UsageEnv
- -> LintM (OutType, UsageEnv)
+lintValApp :: CoreExpr -> Type -> Type -> UsageEnv -> UsageEnv
+ -> LintM (Type, UsageEnv)
lintValApp arg fun_ty arg_ty fun_ue arg_ue
| Just (_, w, arg_ty', res_ty') <- splitFunTy_maybe fun_ty
= do { ensureEqTys arg_ty' arg_ty (mkAppMsg arg_ty' arg_ty arg)
@@ -1559,9 +1525,7 @@ lintValApp arg fun_ty arg_ty fun_ue arg_ue
where
err2 = mkNonFunAppMsg fun_ty arg_ty arg
-lintTyKind :: OutTyVar -> OutType -> LintM ()
--- Both args have had substitution applied
-
+lintTyKind :: OutTyVar -> Type -> LintM ()
-- If you edit this function, you may need to update the GHC formalism
-- See Note [GHC Formalism]
lintTyKind tyvar arg_ty
@@ -1579,36 +1543,36 @@ lintTyKind tyvar arg_ty
************************************************************************
-}
-lintCaseExpr :: CoreExpr -> InId -> InType -> [CoreAlt] -> LintM (OutType, UsageEnv)
+lintCaseExpr :: CoreExpr -> Id -> Type -> [CoreAlt] -> LintM (Type, UsageEnv)
lintCaseExpr scrut case_bndr alt_ty alts
= do { let e = Case scrut case_bndr alt_ty alts -- Just for error messages
-- Check the scrutinee
- ; (scrut_ty', scrut_ue) <- markAllJoinsBad $ lintCoreExpr scrut
+ ; (scrut_ty, scrut_ue) <- markAllJoinsBad $ lintCoreExpr scrut
-- See Note [Join points are less general than the paper]
-- in GHC.Core
- ; alt_ty' <- addLoc (CaseTy scrut) $ lintValueType alt_ty
+ ; addLoc (CaseTy scrut) $ lintValueType alt_ty
- ; checkCaseAlts e scrut scrut_ty' alts
+ ; checkCaseAlts e scrut scrut_ty alts
-- Lint the case-binder. Must do this after linting the scrutinee
-- because the case-binder isn't in scope in the scrutineex
- ; lintBinder CaseBind case_bndr $ \case_bndr' ->
+ ; lintBinder CaseBind case_bndr $
-- Don't use lintIdBndr on case_bndr, because unboxed tuple is legitimate
- do { let case_bndr_ty' = idType case_bndr'
- scrut_mult = idMult case_bndr'
+ do { let case_bndr_ty = idType case_bndr
+ scrut_mult = idMult case_bndr
- ; ensureEqTys case_bndr_ty' scrut_ty' (mkScrutMsg case_bndr case_bndr_ty' scrut_ty')
+ ; ensureEqTys case_bndr_ty scrut_ty (mkScrutMsg case_bndr case_bndr_ty scrut_ty)
-- See GHC.Core Note [Case expression invariants] item (7)
; -- Check the alternatives
- ; alt_ues <- mapM (lintCoreAlt case_bndr' scrut_ty' scrut_mult alt_ty') alts
+ ; alt_ues <- mapM (lintCoreAlt case_bndr scrut_ty scrut_mult alt_ty) alts
; let case_ue = (scaleUE scrut_mult scrut_ue) `addUE` supUEs alt_ues
- ; return (alt_ty', case_ue) } }
+ ; return (alt_ty, case_ue) } }
-checkCaseAlts :: InExpr -> InExpr -> OutType -> [CoreAlt] -> LintM ()
+checkCaseAlts :: CoreExpr -> CoreExpr -> Type -> [CoreAlt] -> LintM ()
-- a) Check that the alts are non-empty
-- b1) Check that the DEFAULT comes first, if it exists
-- b2) Check that the others are in increasing order
@@ -1683,17 +1647,17 @@ checkCaseAlts e scrut scrut_ty alts
is_lit_alt (Alt (LitAlt _) _ _) = True
is_lit_alt _ = False
-lintAltExpr :: CoreExpr -> OutType -> LintM UsageEnv
+lintAltExpr :: CoreExpr -> Type -> LintM UsageEnv
lintAltExpr expr ann_ty
= do { (actual_ty, ue) <- lintCoreExpr expr
; ensureEqTys actual_ty ann_ty (mkCaseAltMsg expr actual_ty ann_ty)
; return ue }
-- See GHC.Core Note [Case expression invariants] item (6)
-lintCoreAlt :: OutId -- Case binder
- -> OutType -- Type of scrutinee
+lintCoreAlt :: Id -- Case binder
+ -> Type -- Type of scrutinee
-> Mult -- Multiplicity of scrutinee
- -> OutType -- Type of the alternative
+ -> Type -- Type of the alternative
-> CoreAlt
-> LintM UsageEnv
-- If you edit this function, you may need to update the GHC formalism
@@ -1738,11 +1702,11 @@ lintCoreAlt case_bndr scrut_ty _scrut_mult alt_ty alt@(Alt (DataAlt con) args rh
; multiplicities = map binderMult $ fst $ splitPiTys con_payload_ty }
-- And now bring the new binders into scope
- ; lintBinders CasePatBind args $ \ args' -> do
+ ; lintBinders CasePatBind args $ do
{ rhs_ue <- lintAltExpr rhs alt_ty
; rhs_ue' <- addLoc (CasePat alt) $
lintAltBinders rhs_ue case_bndr scrut_ty con_payload_ty
- (zipEqual multiplicities args')
+ (zipEqual multiplicities args)
; return $ deleteUE rhs_ue' case_bndr
}
}
@@ -1784,54 +1748,52 @@ lintLinearBinder doc actual_usage described_usage
-}
-- When we lint binders, we (one at a time and in order):
--- 1. Lint var types or kinds (possibly substituting)
--- 2. Add the binder to the in scope set, and if its a coercion var,
--- we may extend the substitution to reflect its (possibly) new kind
-lintBinders :: HasDebugCallStack => BindingSite -> [InVar] -> ([OutVar] -> LintM a) -> LintM a
-lintBinders _ [] linterF = linterF []
-lintBinders site (var:vars) linterF = lintBinder site var $ \var' ->
- lintBinders site vars $ \ vars' ->
- linterF (var':vars')
+-- 1. Lint var types or kinds
+-- 2. Add the binder to the in scope set
+lintBinders :: HasDebugCallStack => BindingSite -> [Var] -> LintM a -> LintM a
+lintBinders _ [] linterF = linterF
+lintBinders site (var:vars) linterF = lintBinder site var $
+ lintBinders site vars $
+ linterF
-- If you edit this function, you may need to update the GHC formalism
-- See Note [GHC Formalism]
-lintBinder :: HasDebugCallStack => BindingSite -> InVar -> (OutVar -> LintM a) -> LintM a
+lintBinder :: HasDebugCallStack => BindingSite -> Var -> LintM a -> LintM a
lintBinder site var linterF
| isTyCoVar var = lintTyCoBndr var linterF
| otherwise = lintIdBndr NotTopLevel site var linterF
-lintTyCoBndr :: HasDebugCallStack => TyCoVar -> (OutTyCoVar -> LintM a) -> LintM a
+lintTyCoBndr :: HasDebugCallStack => TyCoVar -> LintM a -> LintM a
lintTyCoBndr tcv thing_inside
- = do { tcv_type' <- lintTypeAndSubst (varType tcv)
- ; let tcv_kind' = typeKind tcv_type'
+ = do { let tcv_type = varType tcv
+ tcv_kind = typeKind tcv_type
+ ; lintType (varType tcv)
-- See (FORALL1) and (FORALL2) in GHC.Core.Type
; if (isTyVar tcv)
then -- Check that in (forall (a:ki). blah) we have ki:Type
- lintL (isLiftedTypeKind tcv_kind') $
+ lintL (isLiftedTypeKind tcv_kind) $
hang (text "TyVar whose kind does not have kind Type:")
- 2 (ppr tcv <+> dcolon <+> ppr tcv_type' <+> dcolon <+> ppr tcv_kind')
+ 2 (ppr tcv <+> dcolon <+> ppr tcv_type <+> dcolon <+> ppr tcv_kind)
else -- Check that in (forall (cv::ty). blah),
-- then ty looks like (t1 ~# t2)
- lintL (isCoVarType tcv_type') $
+ lintL (isCoVarType tcv_type) $
text "CoVar with non-coercion type:" <+> pprTyVar tcv
- ; addInScopeTyCoVar tcv tcv_type' thing_inside }
+ ; addInScopeTyCoVar tcv thing_inside }
-lintIdBndrs :: forall a. TopLevelFlag -> [InId] -> ([OutId] -> LintM a) -> LintM a
+lintIdBndrs :: forall a. TopLevelFlag -> [Id] -> LintM a -> LintM a
lintIdBndrs top_lvl ids thing_inside
= go ids thing_inside
where
- go :: [Id] -> ([Id] -> LintM a) -> LintM a
- go [] thing_inside = thing_inside []
- go (id:ids) thing_inside = lintIdBndr top_lvl LetBind id $ \id' ->
- go ids $ \ids' ->
- thing_inside (id' : ids')
+ go :: [Id] -> LintM a -> LintM a
+ go [] thing_inside = thing_inside
+ go (id:ids) thing_inside = lintIdBndr top_lvl LetBind id $
+ go ids $
+ thing_inside
lintIdBndr :: TopLevelFlag -> BindingSite
- -> InVar -> (OutVar -> LintM a) -> LintM a
--- Do substitution on the type of a binder and add the var with this
--- new type to the in-scope set of the second argument
+ -> Var -> LintM a -> LintM a
-- ToDo: lint its rules
lintIdBndr top_lvl bind_site id thing_inside
= assertPpr (isId id) (ppr id) $
@@ -1869,9 +1831,9 @@ lintIdBndr top_lvl bind_site id thing_inside
; lintL (not (bind_site == LambdaBind && isEvaldUnfolding (idUnfolding id)))
(text "Lambda binder with value or OtherCon unfolding.")
- ; out_ty <- addLoc (IdTy id) (lintValueType id_ty)
+ ; addLoc (IdTy id) (lintValueType id_ty)
- ; addInScopeId id out_ty thing_inside }
+ ; addInScopeId id thing_inside }
where
id_ty = idType id
@@ -1891,62 +1853,44 @@ lintIdBndr top_lvl bind_site id thing_inside
{- Note [Linting types and coercions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Notice that
- lintType :: InType -> LintM ()
- lintCoercion :: InCoercion -> LintM ()
+ lintType :: Type -> LintM ()
+ lintCoercion :: Coercion -> LintM ()
Neither returns anything.
-If you need the kind of the type, then do `typeKind` and then apply
-the ambient substitution using `substTyM`. Note that the substitution
-empty unless there is shadowing or type-lets; and if the substitution is
-empty, the `substTyM` is a no-op.
-
-It is better to take the kind and then substitute, rather than substitute
-and then take the kind, becaues the kind is usually smaller.
-
-Note: you might wonder if we should apply the same logic to expressions.
-Why do we have
- lintExpr :: InExpr -> LintM OutType
-Partly inertia; but also taking the type of an expresison involve looking
-down a deep chain of let's, whereas that is not true of taking the kind
-of a type. It'd be worth an experiment though.
-
-Historical note: in the olden days we had
- lintType :: InType -> LintM OutType
-but that burned a huge amount of allocation building an OutType that was
-often discarded, or used only to get its kind.
-
-I also experimented with
- lintType :: InType -> LintM OutKind
-but that too was slower. It is also much simpler to return ()! If we
-return the kind we have to duplicate the logic in `typeKind`; and it is
-much worse for coercions.
+Note: you might wonder why we have
+ lintExpr :: CoreExpr -> LintM Type
+ lintType :: Type -> LintM ()
+
+That is, linting an expression yields its type, but linting a type does not
+yield its kind. Partly inertia; but:
+
+* Taking the type of an expresison involves looking down a deep chain of let's,
+ whereas that is not true of taking the kind of a type. It'd be worth an
+ experiment though.
+
+* I did experiment with
+ lintType :: Type -> LintM Kind
+ but that too was slower. It is also much simpler to return ()! If we return
+ the kind we have to duplicate the logic in `typeKind`; and it is much worse
+ for coercions.
-}
-lintValueType :: Type -> LintM OutType
+lintValueType :: Type -> LintM ()
-- Types only, not kinds
--- Check the type, and apply the substitution to it
--- See Note [Linting type lets]
lintValueType ty
= addLoc (InType ty) $
- do { ty' <- lintTypeAndSubst ty
- ; let sk = typeKind ty'
+ do { lintType ty
+ ; let sk = typeKind ty
; lintL (isTYPEorCONSTRAINT sk) $
hang (text "Ill-kinded type:" <+> ppr ty)
- 2 (text "has kind:" <+> ppr sk)
- ; return ty' }
+ 2 (text "has kind:" <+> ppr sk)}
checkTyCon :: TyCon -> LintM ()
checkTyCon tc
= checkL (not (isTcTyCon tc)) (text "Found TcTyCon:" <+> ppr tc)
-------------------
-lintTypeAndSubst :: InType -> LintM OutType
-lintTypeAndSubst ty = do { lintType ty; substTyM ty }
- -- In GHCi we may lint an expression with a free
- -- type variable. Then it won't be in the
- -- substitution, but it should be in scope
-
-lintType :: InType -> LintM ()
+lintType :: Type -> LintM ()
-- See Note [Linting types and coercions]
--
-- If you edit this function, you may need to update the GHC formalism
@@ -1956,8 +1900,7 @@ lintType (TyVarTy tv)
= failWithL (mkBadTyVarMsg tv)
| otherwise
- = do { _ <- lintVarOcc tv
- ; return () }
+ = lintVarOcc tv
lintType ty@(AppTy t1 t2)
| TyConApp {} <- t1
@@ -1965,7 +1908,7 @@ lintType ty@(AppTy t1 t2)
| otherwise
= do { let (fun_ty, arg_tys) = collect t1 [t2]
; lintType fun_ty
- ; fun_kind <- substTyM (typeKind fun_ty)
+ ; let fun_kind = typeKind fun_ty
; lint_ty_app ty fun_kind arg_tys }
where
collect (AppTy f a) as = collect f (a:as)
@@ -1997,21 +1940,21 @@ lintType ty@(FunTy af tw t1 t2)
lintType ty@(ForAllTy {})
= go [] ty
where
- go :: [OutTyCoVar] -> InType -> LintM ()
+ go :: [OutTyCoVar] -> Type -> LintM ()
-- Loop, collecting the forall-binders
go tcvs ty@(ForAllTy (Bndr tcv _) body_ty)
| not (isTyCoVar tcv)
= failWithL (text "Non-TyVar or Non-CoVar bound in type:" <+> ppr ty)
| otherwise
- = lintTyCoBndr tcv $ \tcv' ->
+ = lintTyCoBndr tcv $
do { -- See GHC.Core.TyCo.Rep Note [Unused coercion variable in ForAllTy]
-- Suspicious because it works on InTyCoVar; c.f. ForAllCo
when (isCoVar tcv) $
lintL (anyFreeVarsOfType (== tcv) body_ty) $
text "Covar does not occur in the body:" <+> (ppr tcv $$ ppr body_ty)
- ; go (tcv' : tcvs) body_ty }
+ ; go (tcv : tcvs) body_ty }
go tcvs body_ty
= do { lintType body_ty
@@ -2019,7 +1962,7 @@ lintType ty@(ForAllTy {})
lintType (CastTy ty co)
= do { lintType ty
- ; ty_kind <- substTyM (typeKind ty)
+ ; let ty_kind = typeKind ty
; co_lk <- lintStarCoercion co
; ensureEqTys ty_kind co_lk (mkCastTyErr ty co ty_kind co_lk) }
@@ -2027,14 +1970,14 @@ lintType (LitTy l) = lintTyLit l
lintType (CoercionTy co) = lintCoercion co
-----------------
-lintForAllBody :: [OutTyCoVar] -> InType -> LintM ()
+lintForAllBody :: [OutTyCoVar] -> Type -> LintM ()
-- Do the checks for the body of a forall-type
lintForAllBody tcvs body_ty
= do { -- For type variables, check for skolem escape
-- See Note [Phantom type variables in kinds] in GHC.Core.Type
-- The kind of (forall cv. th) is liftedTypeKind, so no
-- need to check for skolem-escape in the CoVar case
- body_kind <- substTyM (typeKind body_ty)
+ let body_kind = typeKind body_ty
; case occCheckExpand tcvs body_kind of
Just {} -> return ()
Nothing -> failWithL $
@@ -2045,7 +1988,7 @@ lintForAllBody tcvs body_ty
; checkValueType body_kind (text "the body of forall:" <+> ppr body_ty) }
-----------------
-lintTySynFamApp :: Bool -> InType -> TyCon -> [InType] -> LintM ()
+lintTySynFamApp :: Bool -> Type -> TyCon -> [Type] -> LintM ()
-- The TyCon is a type synonym or a type family (not a data family)
-- See Note [Linting type synonym applications]
-- c.f. GHC.Tc.Validity.check_syn_tc_app
@@ -2071,21 +2014,21 @@ lintTySynFamApp report_unsat ty tc tys
-----------------
-- Confirms that a kind is really TYPE r or Constraint
-checkValueType :: OutKind -> SDoc -> LintM ()
+checkValueType :: Kind -> SDoc -> LintM ()
checkValueType kind doc
= lintL (isTYPEorCONSTRAINT kind)
(text "Non-Type-like kind when Type-like expected:" <+> ppr kind $$
text "when checking" <+> doc)
-----------------
-lintArrow :: SDoc -> FunTyFlag -> InType -> InType -> InType -> LintM ()
+lintArrow :: SDoc -> FunTyFlag -> Type -> Type -> Type -> LintM ()
-- If you edit this function, you may need to update the GHC formalism
-- See Note [GHC Formalism]
lintArrow what af t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw
-- or lintArrow "coercion `blah'" k1 k2 kw
- = do { k1 <- substTyM (typeKind t1)
- ; k2 <- substTyM (typeKind t2)
- ; kw <- substTyM (typeKind tw)
+ = do { let k1 = typeKind t1
+ k2 = typeKind t2
+ kw = typeKind tw
; unless (isTYPEorCONSTRAINT k1) (report (text "argument") t1 k1)
; unless (isTYPEorCONSTRAINT k2) (report (text "result") t2 k2)
; unless (isMultiplicityTy kw) (report (text "multiplicity") tw kw)
@@ -2111,29 +2054,29 @@ lintTyLit (StrTyLit _) = return ()
lintTyLit (CharTyLit _) = return ()
-----------------
-lint_ty_app :: InType -> OutKind -> [InType] -> LintM ()
+lint_ty_app :: Type -> Kind -> [Type] -> LintM ()
lint_ty_app ty = lint_tyco_app (text "type" <+> quotes (ppr ty))
-lint_co_app :: HasDebugCallStack => Coercion -> OutKind -> [InType] -> LintM ()
+lint_co_app :: HasDebugCallStack => Coercion -> Kind -> [Type] -> LintM ()
lint_co_app co = lint_tyco_app (text "coercion" <+> quotes (ppr co))
-lint_tyco_app :: SDoc -> OutKind -> [InType] -> LintM ()
+lint_tyco_app :: SDoc -> Kind -> [Type] -> LintM ()
lint_tyco_app msg fun_kind arg_tys
-- See Note [Avoiding compiler perf traps when constructing error messages.]
- = do { _ <- lintApp msg (\ty -> do { lintType ty; substTyM ty })
- (\ty _ _ -> do { lintType ty; ki <- substTyM (typeKind ty); return (ki,()) })
- fun_kind arg_tys ()
+ = do { _ <- lintApp msg (\ty -> do { lintType ty; return ty })
+ (\ty _ _ -> do { lintType ty; return (typeKind ty,()) })
+ fun_kind arg_tys ()
; return () }
----------------
lintApp :: forall in_a acc. Outputable in_a =>
SDoc
- -> (in_a -> LintM OutType) -- Lint the thing and return its value
- -> (in_a -> Mult -> acc -> LintM (OutKind, acc)) -- Lint the thing and return its type
- -> OutType
+ -> (in_a -> LintM Type) -- Lint the thing and return its value
+ -> (in_a -> Mult -> acc -> LintM (Kind, acc)) -- Lint the thing and return its type
+ -> Type
-> [in_a] -- The arguments, always "In" things
-> acc -- Used (only) for UsageEnv in /term/ applications
- -> LintM (OutType,acc)
+ -> LintM (Type,acc)
-- lintApp is a performance-critical function, which deals with multiple
-- applications such as (/\a./\b./\c. expr) @ta @tb @tc
-- When returning the type of this expression we want to avoid substituting a:=ta,
@@ -2158,7 +2101,7 @@ lintApp msg lint_forall_arg lint_arrow_arg !orig_fun_ty all_args acc
; let init_subst = mkEmptySubst in_scope
- go :: Subst -> OutType -> acc -> [in_a] -> LintM (OutType, acc)
+ go :: Subst -> Type -> acc -> [in_a] -> LintM (Type, acc)
-- The Subst applies (only) to the fun_ty
-- c.f. GHC.Core.Type.piResultTys, which has a similar loop
@@ -2202,7 +2145,7 @@ lintApp msg lint_forall_arg lint_arrow_arg !orig_fun_ty all_args acc
-- explicitly and don't capture them as free variables. Otherwise this binder might
-- become a thunk that get's allocated in the hot code path.
-- See Note [Avoiding compiler perf traps when constructing error messages.]
-lint_app_fail_msg :: (Outputable a2) => SDoc -> OutType -> a2 -> SDoc -> SDoc
+lint_app_fail_msg :: (Outputable a2) => SDoc -> Type -> a2 -> SDoc -> SDoc
lint_app_fail_msg msg kfn arg_tys extra
= vcat [ hang (text "Application error in") 2 msg
, nest 2 (text "Function type =" <+> ppr kfn)
@@ -2215,7 +2158,7 @@ lint_app_fail_msg msg kfn arg_tys extra
* *
********************************************************************* -}
-lintCoreRule :: OutVar -> OutType -> CoreRule -> LintM ()
+lintCoreRule :: OutVar -> Type -> CoreRule -> LintM ()
lintCoreRule _ _ (BuiltinRule {})
= return () -- Don't bother
@@ -2223,7 +2166,7 @@ lintCoreRule fun fun_ty rule@(Rule { ru_name = name, ru_bndrs = bndrs
, ru_args = args, ru_rhs = rhs })
= noMultiplicityChecks $ -- Skip linearity checking for rules
-- See Note [Linting linearity]
- lintBinders LambdaBind bndrs $ \ _ ->
+ lintBinders LambdaBind bndrs $
do { (lhs_ty, _) <- lintCoreArgs (fun_ty, zeroUE) args
; (rhs_ty, _) <- case idJoinPointHood fun of
JoinPoint join_arity
@@ -2311,10 +2254,10 @@ Note [Join points and unfoldings/rules] in "GHC.Core.Opt.OccurAnal" for further
{- Note [Asymptotic efficiency]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-When linting coercions (and types actually) we return a linted
-(substituted) coercion. Then we often have to take the coercionKind of
-that returned coercion. If we get long chains, that can be asymptotically
-inefficient, notably in
+When linting coercions we traverse the coercion. Then we often have to take the
+coercionKind of that returned coercion. If we get long chains, that can be
+asymptotically inefficient, notably in
+
* TransCo
* InstCo
* SelCo (cf #9233)
@@ -2326,30 +2269,23 @@ the bad perf bites us in practice.
A solution would be to return the kind and role of the coercion,
as well as the linted coercion. Or perhaps even *only* the kind and role,
which is what used to happen. But that proved tricky and error prone
-(#17923), so now we return the coercion.
+(#17923).
-}
-- lintStarCoercion lints a coercion, confirming that its lh kind and
-- its rh kind are both *; also ensures that the role is Nominal
-- Returns the lh kind
-lintStarCoercion :: InCoercion -> LintM OutType
+lintStarCoercion :: Coercion -> LintM Type
lintStarCoercion g
= do { lintCoercion g
- ; Pair t1 t2 <- substCoKindM g
+ ; let Pair t1 t2 = coercionKind g
; checkValueType (typeKind t1) (text "the kind of the left type in" <+> ppr g)
; checkValueType (typeKind t2) (text "the kind of the right type in" <+> ppr g)
; lintRole g Nominal (coercionRole g)
; return t1 }
-substCoKindM :: InCoercion -> LintM (Pair OutType)
-substCoKindM co
- = do { let !(Pair lk rk) = coercionKind co
- ; lk' <- substTyM lk
- ; rk' <- substTyM rk
- ; return (Pair lk' rk') }
-
-lintCoercion :: HasDebugCallStack => InCoercion -> LintM ()
+lintCoercion :: HasDebugCallStack => Coercion -> LintM ()
-- See Note [Linting types and coercions]
--
-- If you edit this function, you may need to update the GHC formalism
@@ -2361,7 +2297,7 @@ lintCoercion (CoVarCo cv)
2 (text "With offending type:" <+> ppr (varType cv)))
| otherwise -- C.f. lintType (TyVarTy tv), which has better docs
- = do { _ <- lintVarOcc cv; return () }
+ = lintVarOcc cv
lintCoercion (Refl ty) = lintType ty
lintCoercion (GRefl _r ty MRefl) = lintType ty
@@ -2369,8 +2305,8 @@ lintCoercion (GRefl _r ty MRefl) = lintType ty
lintCoercion (GRefl _r ty (MCo co))
= do { lintType ty
; lintCoercion co
- ; tk <- substTyM (typeKind ty)
- ; tl <- substTyM (coercionLKind co)
+ ; let tk = typeKind ty
+ tl = coercionLKind co
; ensureEqTys tk tl $
hang (text "GRefl coercion kind mis-match:" <+> ppr co)
2 (vcat [ppr ty, ppr tk, ppr tl])
@@ -2403,8 +2339,8 @@ lintCoercion co@(AppCo co1 co2)
= do { lintCoercion co1
; lintCoercion co2
; let !(Pair lt1 rt1) = coercionKind co1
- ; lk1 <- substTyM (typeKind lt1)
- ; rk1 <- substTyM (typeKind rt1)
+ lk1 = typeKind lt1
+ rk1 = typeKind rt1
; lint_co_app co lk1 [coercionLKind co2]
; lint_co_app co rk1 [coercionRKind co2]
@@ -2421,7 +2357,7 @@ lintCoercion co@(ForAllCo {})
= do { _ <- go [] co; return () }
where
go :: [OutTyCoVar] -- Binders in reverse order
- -> InCoercion -> LintM Role
+ -> Coercion -> LintM Role
go tcvs co@(ForAllCo { fco_tcv = tcv, fco_visL = visL, fco_visR = visR
, fco_kind = kind_mco, fco_body = body_co })
| not (isTyCoVar tcv)
@@ -2431,15 +2367,15 @@ lintCoercion co@(ForAllCo {})
= do { mb_lk <- case kind_mco of
MRefl -> return Nothing
MCo kind_co -> Just <$> lintStarCoercion kind_co
- ; lintTyCoBndr tcv $ \tcv' ->
+ ; lintTyCoBndr tcv $
do { case mb_lk of
Nothing -> return ()
- Just lk -> ensureEqTys (varType tcv') lk $
+ Just lk -> ensureEqTys (varType tcv) lk $
text "Kind mis-match in ForallCo" <+> ppr co
-- I'm not very sure about this part, because it traverses body_co
-- but at least it's on a cold path (a ForallCo for a CoVar)
- -- Also it works on InTyCoVar and InCoercion, which is suspect
+ -- Also it works on InTyCoVar and Coercion, which is suspect
; when (isCoVar tcv) $
do { lintL (visL == coreTyLamForAllTyFlag && visR == coreTyLamForAllTyFlag) $
text "Invalid visibility flags in CoVar ForAllCo" <+> ppr co
@@ -2448,7 +2384,7 @@ lintCoercion co@(ForAllCo {})
text "Covar can only appear in Refl and GRefl: " <+> ppr co }
-- See (FC6) in Note [ForAllCo] in GHC.Core.TyCo.Rep
- ; role <- go (tcv':tcvs) body_co
+ ; role <- go (tcv:tcvs) body_co
; when (role == Nominal) $
lintL (visL `eqForAllVis` visR) $
@@ -2505,8 +2441,8 @@ lintCoercion co@(UnivCo { uco_role = r, uco_prov = prov
-- Check the to and from types
; lintType ty1
; lintType ty2
- ; tk1 <- substTyM (typeKind ty1)
- ; tk2 <- substTyM (typeKind ty2)
+ ; let tk1 = typeKind ty1
+ tk2 = typeKind ty2
; when (r /= Phantom && isTYPEorCONSTRAINT tk1 && isTYPEorCONSTRAINT tk2)
(checkTypes ty1 ty2)
@@ -2560,8 +2496,8 @@ lintCoercion (SymCo co) = lintCoercion co
lintCoercion co@(TransCo co1 co2)
= do { lintCoercion co1
; lintCoercion co2
- ; rk1 <- substTyM (coercionRKind co1)
- ; lk2 <- substTyM (coercionLKind co2)
+ ; let rk1 = coercionRKind co1
+ lk2 = coercionLKind co2
; ensureEqTys rk1 lk2
(hang (text "Trans coercion mis-match:" <+> ppr co)
2 (vcat [ppr (coercionKind co1), ppr (coercionKind co2)]))
@@ -2569,7 +2505,7 @@ lintCoercion co@(TransCo co1 co2)
lintCoercion the_co@(SelCo cs co)
= do { lintCoercion co
- ; Pair s t <- substCoKindM co
+ ; let Pair s t = coercionKind co
; if -- forall (both TyVar and CoVar)
| Just _ <- splitForAllTyCoVar_maybe s
@@ -2604,7 +2540,7 @@ lintCoercion the_co@(SelCo cs co)
lintCoercion the_co@(LRCo _lr co)
= do { lintCoercion co
- ; Pair s t <- substCoKindM co
+ ; let Pair s t = coercionKind co
; lintRole co Nominal (coercionRole co)
; case (splitAppTy_maybe s, splitAppTy_maybe t) of
(Just {}, Just {}) -> return ()
@@ -2618,14 +2554,12 @@ lintCoercion orig_co@(InstCo co arg)
go (InstCo co arg) args = do { lintCoercion arg; go co (arg:args) }
go co args = do { lintCoercion co
; let Pair lty rty = coercionKind co
- ; lty' <- substTyM lty
- ; rty' <- substTyM rty
; in_scope <- getInScope
; let subst = mkEmptySubst in_scope
- ; go_args (subst, lty') (subst,rty') args }
+ ; go_args (subst, lty) (subst,rty) args }
-------------
- go_args :: (Subst, OutType) -> (Subst,OutType) -> [InCoercion]
+ go_args :: (Subst, Type) -> (Subst,Type) -> [Coercion]
-> LintM ()
go_args _ _ []
= return ()
@@ -2634,11 +2568,11 @@ lintCoercion orig_co@(InstCo co arg)
; go_args lty1 rty1 args }
-------------
- go_arg :: (Subst, OutType) -> (Subst,OutType) -> InCoercion
- -> LintM ((Subst,OutType), (Subst,OutType))
+ go_arg :: (Subst, Type) -> (Subst,Type) -> Coercion
+ -> LintM ((Subst,Type), (Subst,Type))
go_arg (lsubst,lty) (rsubst,rty) arg
= do { lintRole arg Nominal (coercionRole arg)
- ; Pair arg_lty arg_rty <- substCoKindM arg
+ ; let Pair arg_lty arg_rty = coercionKind arg
; case (splitForAllTyCoVar_maybe lty, splitForAllTyCoVar_maybe rty) of
-- forall over tvar
@@ -2662,11 +2596,11 @@ lintCoercion orig_co@(InstCo co arg)
lintCoercion this_co@(AxiomCo ax cos)
= do { mapM_ lintCoercion cos
; lint_roles 0 (coAxiomRuleArgRoles ax) cos
- ; prs <- mapM substCoKindM cos
+ ; let prs = map coercionKind cos
; lint_ax ax prs }
where
- lint_ax :: CoAxiomRule -> [Pair OutType] -> LintM ()
+ lint_ax :: CoAxiomRule -> [Pair Type] -> LintM ()
lint_ax (BuiltInFamRew bif) prs
= checkL (isJust (bifrw_proves bif prs)) bad_bif
lint_ax (BuiltInFamInj bif) prs
@@ -2754,8 +2688,8 @@ lintBranch this_co fam_tc branch arg_kinds
= do { checkL (arg_kinds `equalLength` (ktvs ++ cvs)) $
(bad_ax this_co (text "lengths"))
- ; subst <- getSubst
- ; let empty_subst = zapSubst subst
+ ; in_scope <- getInScope
+ ; let empty_subst = mkEmptySubst in_scope
; _ <- foldlM check_ki (empty_subst, empty_subst)
(zip (ktvs ++ cvs) arg_kinds)
@@ -2880,12 +2814,12 @@ lint_axiom ax@(CoAxiom { co_ax_tc = tc, co_ax_branches = branches
lint_branch :: TyCon -> CoAxBranch -> LintM ()
lint_branch ax_tc (CoAxBranch { cab_tvs = tvs, cab_cvs = cvs
, cab_lhs = lhs_args, cab_rhs = rhs })
- = lintBinders LambdaBind (tvs ++ cvs) $ \_ ->
+ = lintBinders LambdaBind (tvs ++ cvs) $
do { let lhs = mkTyConApp ax_tc lhs_args
; lintType lhs
; lintType rhs
- ; lhs_kind <- substTyM (typeKind lhs)
- ; rhs_kind <- substTyM (typeKind rhs)
+ ; let lhs_kind = typeKind lhs
+ rhs_kind = typeKind rhs
; lintL (not (lhs_kind `typesAreApart` rhs_kind)) $
hang (text "Inhomogeneous axiom")
2 (text "lhs:" <+> ppr lhs <+> dcolon <+> ppr lhs_kind $$
@@ -2969,35 +2903,26 @@ type LintLevel = Int
-- If you edit this type, you may need to update the GHC formalism
-- See Note [GHC Formalism]
data LintEnv
- = LE { le_flags :: LintFlags -- Linting the result of this pass
- , le_loc :: [LintLocInfo] -- Locations
-
- , le_subst :: Subst
- -- Current substitution, for TyCoVars only.
- -- Non-CoVar Ids don't appear in here, not even in the InScopeSet
- -- Used for (a) cloning to avoid shadowing of TyCoVars,
- -- so that eqType works ok
- -- (b) substituting for let-bound tyvars, when we have
- -- (let @a = Int -> Int in ...)
-
- , le_level :: LintLevel
- , le_in_vars :: VarEnv (InVar, OutType, LintLevel)
- -- Maps an InVar (i.e. its unique) to its binding InVar
- -- and to its OutType
- -- /All/ in-scope variables are here (term variables,
- -- type variables, and coercion variables)
- -- Used at an occurrence of the InVar
+ = LE { le_flags :: LintFlags -- Linting the result of this pass
+ , le_loc :: [LintLocInfo] -- Locations
+ , le_level :: LintLevel
+ , le_in_scope :: InScopeSet
+
+ , le_in_vars :: VarEnv (Var, LintLevel)
+ -- Maps an Var (i.e. its unique) to its binding Var and level
+ -- /All/ in-scope variables are here (term variables,
+ -- type variables, and coercion variables)
+ -- Used at an occurrence of the Var
, le_joins :: UniqMap Id JoinOcc
-- ^ Join points in scope that are valid
- -- A subset of the InScopeSet in le_subst
-- See Note [Join points]
, le_ue_aliases :: NameEnv UsageEnv
-- See Note [Linting linearity]
-- Assigns usage environments to the alias-like binders,
-- as found in non-recursive lets.
- -- Domain is OutIds
+ -- Domain is Ids
, le_platform :: Platform -- ^ Target platform
, le_diagOpts :: DiagOpts -- ^ Target platform
@@ -3011,7 +2936,8 @@ data LintFlags
, lf_check_linearity :: Bool -- ^ See Note [Linting linearity]
, lf_check_fixed_rep :: Bool -- ^ See Note [Checking for representation polymorphism]
, lf_check_rubbish_lits :: Bool -- ^ See Note [Checking for rubbish literals]
- , lf_allow_weak_joins :: Bool -- ^ See Note [Linting join points with casts or ticks]
+ , lf_allow_weak_joins :: Bool -- ^ See Note [Linting join points with casts or ticks]
+ , lf_allow_beta_joins :: Bool -- ^ See Note [Join points and beta-redexes]
}
-- See Note [Checking StaticPtrs]
@@ -3078,20 +3004,6 @@ top-level bindings. See SimplCore Note [Grand plan for static forms].
The linter checks that no occurrence or `makeStatic` occurs nested.
-Note [Type substitution]
-~~~~~~~~~~~~~~~~~~~~~~~~
-Why do we need a type substitution? Consider
- /\(a:*). \(x:a). /\(a:*). id a x
-This is ill typed, because (renaming variables) it is really
- /\(a:*). \(x:a). /\(b:*). id b x
-Hence, when checking an application, we can't naively compare x's type
-(at its binding site) with its expected type (at a use site). So we
-rename type binders as we go, maintaining a substitution.
-
-The same substitution also supports let-type, current expressed as
- (/\(a:*). body) ty
-Here we substitute 'ty' for 'a' in 'body', on the fly.
-
Note [Linting type synonym applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When linting a type-synonym, or type-family, application
@@ -3353,12 +3265,12 @@ initL cfg m
where
vars = l_vars cfg
init_level = 0
- env = LE { le_flags = l_flags cfg
- , le_subst = mkEmptySubst (mkInScopeSetList vars)
- , le_level = init_level
- , le_in_vars = mkVarEnv [ (v,(v, varType v, init_level)) | v <- vars ]
- , le_joins = emptyUniqMap
- , le_loc = []
+ env = LE { le_flags = l_flags cfg
+ , le_level = init_level
+ , le_in_vars = mkVarEnv [ (v,(v, init_level)) | v <- vars ]
+ , le_in_scope = mkInScopeSetList vars
+ , le_joins = emptyUniqMap
+ , le_loc = []
, le_ue_aliases = emptyNameEnv
, le_platform = l_platform cfg
, le_diagOpts = l_diagOpts cfg
@@ -3421,8 +3333,7 @@ addMsg show_context env msgs msg
loc_msgs :: [(SrcLoc, SDoc)] -- Innermost first
loc_msgs = map dumpLoc (le_loc env)
- cxt_doc = vcat [ vcat $ reverse $ map snd loc_msgs
- , text "Substitution:" <+> ppr (le_subst env) ]
+ cxt_doc = vcat $ reverse $ map snd loc_msgs
context | show_context = cxt_doc
| otherwise = whenPprDebug cxt_doc
@@ -3449,73 +3360,45 @@ inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs
is_case_pat (LE { le_loc = CasePat {} : _ }) = True
is_case_pat _other = False
-addInScopeId :: InId -> OutType -> (OutId -> LintM a) -> LintM a
+addInScopeId :: Id -> LintM a -> LintM a
-- Unlike addInScopeTyCoVar, this function does no cloning; Ids never get cloned
-addInScopeId in_id out_ty thing_inside
+addInScopeId id thing_inside
= LintM $ \ env errs ->
- let !(out_id, env') = add env
- in unLintM (thing_inside out_id) env' errs
-
+ unLintM thing_inside (add env) errs
where
add env@(LE { le_level = level, le_in_vars = id_vars, le_joins = valid_joins
- , le_ue_aliases = aliases, le_subst = subst })
- = (out_id, env1)
+ , le_ue_aliases = aliases, le_in_scope = in_scope })
+ = env { le_level = level1, le_in_vars = in_vars'
+ , le_in_scope = in_scope `extendInScopeSet` id
+ , le_joins = valid_joins', le_ue_aliases = aliases' }
where
level1 = level + 1
- env1 = env { le_level = level1, le_in_vars = in_vars'
- , le_joins = valid_joins', le_ue_aliases = aliases' }
- in_vars' = extendVarEnv id_vars in_id (in_id, out_ty, level1)
- aliases' = delFromNameEnv aliases (idName in_id)
+ in_vars' = extendVarEnv id_vars id (id, level1)
+ aliases' = delFromNameEnv aliases (idName id)
-- aliases': when shadowing an alias, we need to make sure the
-- Id is no longer classified as such. E.g.
-- let x = <e1> in case x of x { _DEFAULT -> <e2> }
-- Occurrences of 'x' in e2 shouldn't count as occurrences of e1.
- -- A very tiny optimisation, not sure if it's really worth it
- -- Short-cut when the substitution is a no-op
- out_id | isEmptyTCvSubst subst = in_id
- | otherwise = setIdType in_id out_ty
-
valid_joins'
- | isJoinId out_id = addToUniqMap valid_joins in_id NormalJoinOcc -- Overwrite with new arity
- | otherwise = delFromUniqMap valid_joins in_id -- Remove any existing binding
+ | isJoinId id = addToUniqMap valid_joins id NormalJoinOcc -- Overwrite with new arity
+ | otherwise = delFromUniqMap valid_joins id -- Remove any existing binding
-addInScopeTyCoVar :: InTyCoVar -> OutType -> (OutTyCoVar -> LintM a) -> LintM a
+addInScopeTyCoVar :: TyCoVar -> LintM a -> LintM a
-- This function clones to avoid shadowing of TyCoVars
-addInScopeTyCoVar tcv tcv_type thing_inside
- = LintM $ \ env@(LE { le_level = level, le_in_vars = in_vars, le_subst = subst }) errs ->
- let (tcv', subst') = subst_bndr subst
- level' = level + 1
+addInScopeTyCoVar tcv thing_inside
+ = LintM $ \ env@(LE { le_level = level, le_in_vars = in_vars
+ , le_in_scope = in_scope }) errs ->
+ let level' = level + 1
env' = env { le_level = level'
- , le_in_vars = extendVarEnv in_vars tcv (tcv, tcv_type, level')
- , le_subst = subst' }
- in unLintM (thing_inside tcv') env' errs
- where
- subst_bndr subst
- | isEmptyTCvSubst subst -- No change in kind
- , not (tcv `elemInScopeSet` in_scope) -- Not already in scope
- = -- Do not extend the substitution, just the in-scope set
- (if (varType tcv `eqType` tcv_type) then (\x->x) else
- pprTrace "addInScopeTyCoVar" (
- vcat [ text "tcv" <+> ppr tcv <+> dcolon <+> ppr (varType tcv)
- , text "tcv_type" <+> ppr tcv_type ])) $
- (tcv, subst `extendSubstInScope` tcv)
-
- -- Clone, and extend the substitution
- | let tcv' = uniqAway in_scope (setVarType tcv tcv_type)
- = (tcv', extendTCvSubstWithClone subst tcv tcv')
- where
- in_scope = substInScopeSet subst
+ , le_in_scope = in_scope `extendInScopeSet` tcv
+ , le_in_vars = extendVarEnv in_vars tcv (tcv, level') }
+ in unLintM thing_inside env' errs
-getInVarEnv :: LintM (VarEnv (InId, OutType, LintLevel))
+getInVarEnv :: LintM (VarEnv (Id, LintLevel))
getInVarEnv = LintM (\env errs -> fromBoxedLResult (Just (le_in_vars env), errs))
-extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a
-extendTvSubstL tv ty m
- = LintM $ \ env errs ->
- unLintM m (env { le_subst = Type.extendTvSubst (le_subst env) tv ty }) errs
-
markAllJoinsBad :: LintM a -> LintM a
markAllJoinsBad m
= LintM $ \ env errs -> unLintM m (env { le_joins = emptyUniqMap }) errs
@@ -3549,54 +3432,42 @@ markAllJoinsBadIf False m = m
getValidJoins :: LintM (UniqMap Id JoinOcc)
getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs))
-getSubst :: LintM Subst
-getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs))
-
-substTyM :: InType -> LintM OutType
--- Apply the substitution to the type
--- The substitution is often empty, in which case it is a no-op
-substTyM ty
- = do { subst <- getSubst
- ; return (substTy subst ty) }
-
getUEAliases :: LintM (NameEnv UsageEnv)
getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs))
getInScope :: LintM InScopeSet
-getInScope = LintM (\ env errs -> fromBoxedLResult (Just (substInScopeSet $ le_subst env), errs))
+getInScope = LintM (\ env errs -> fromBoxedLResult (Just (le_in_scope env), errs))
-lintVarOcc :: InVar -> LintM OutType
+lintVarOcc :: Var -> LintM ()
-- Used at an occurrence of a variable: term variables, type variables, and coercion variables
-- Checks
-- - that it is in scope
-- - that it is not a GlobalId bound by a LocalId
--- - that the InType at the ocurrence matches the InType at the binding site
+-- - that the Type at the ocurrence matches the Type at the binding site
-- - that the variables free in its type are not shadowed at the occurrence site
lintVarOcc v_occ
| isGlobalId v_occ
- = return (idType v_occ)
+ = return ()
| otherwise
= do { in_var_env <- getInVarEnv
; case lookupVarEnv in_var_env v_occ of
Nothing -> failWithL (text pp_what <+> quotes (ppr v_occ)
<+> text "is out of scope")
- Just (v_bndr, out_ty, bind_level)
+ Just (v_bndr, bind_level)
-> do { let bndr_ty = idType v_bndr
; check_bad_global v_bndr
; check_occ_type_match bndr_ty
- ; check_occ_type_scope in_var_env bndr_ty bind_level
- ; return out_ty }
-
+ ; check_occ_type_scope in_var_env bndr_ty bind_level }
}
where
- occ_ty :: InType
+ occ_ty :: Type
occ_ty = idType v_occ
pp_what | isTyVar v_occ = "The type variable"
| isCoVar v_occ = "The coercion variable"
| otherwise = "The value variable"
- check_bad_global :: InVar -> LintM ()
+ check_bad_global :: Var -> LintM ()
-- 'check_bad_global' checks for the case where an /occurrence/ is
-- a GlobalId, but there is an enclosing binding for a LocalId.
-- NB: the in-scope variables are mostly LocalIds, checked by lintIdBndr,
@@ -3616,26 +3487,26 @@ lintVarOcc v_occ
| otherwise
= return ()
- check_occ_type_match :: InType -> LintM ()
+ check_occ_type_match :: Type -> LintM ()
-- Check that the type in /binder/ and the type in the /occurrence/ are the same
check_occ_type_match bndr_ty
- = ensureEqTys bndr_ty occ_ty $ -- Compares InTypes
+ = ensureEqTys bndr_ty occ_ty $ -- Compares Types
mkBndrOccTypeMismatchMsg v_occ bndr_ty occ_ty
- check_occ_type_scope :: VarEnv (InVar,OutType,LintLevel) -> InType -> LintLevel -> LintM ()
+ check_occ_type_scope :: VarEnv (Var,LintLevel) -> Type -> LintLevel -> LintM ()
-- Check that the free vars of the binder's type
-- are not shadowed at the occurrence site
check_occ_type_scope in_var_env bndr_ty bind_level
= checkL (null bad_fvs) $
mkBndrOccFreeVarMsg v_occ occ_ty bad_fvs
where
- bad_fvs :: [InVar]
+ bad_fvs :: [Var]
bad_fvs = filter is_bad (tyCoVarsOfTypeList bndr_ty)
- is_bad :: InVar -> Bool
+ is_bad :: Var -> Bool
-- True of a variable bound inside bind_level
is_bad v = case lookupVarEnv in_var_env v of
- Just (_, _, v_level) -> v_level > bind_level
+ Just (_, v_level) -> v_level > bind_level
Nothing -> True
lookupJoinId :: Id -> LintM (Maybe (JoinArity, JoinOcc))
@@ -3647,21 +3518,21 @@ lookupJoinId id
Just join_occ -> return $ Just (idJoinArity id, join_occ)
Nothing -> return Nothing }
-addAliasUE :: OutId -> UsageEnv -> LintM a -> LintM a
+addAliasUE :: Id -> UsageEnv -> LintM a -> LintM a
addAliasUE id ue thing_inside = LintM $ \ env errs ->
let new_ue_aliases =
extendNameEnv (le_ue_aliases env) (getName id) ue
in
unLintM thing_inside (env { le_ue_aliases = new_ue_aliases }) errs
-varCallSiteUsage :: OutId -> LintM UsageEnv
+varCallSiteUsage :: Id -> LintM UsageEnv
varCallSiteUsage id =
do m <- getUEAliases
return $ case lookupNameEnv m (getName id) of
Nothing -> singleUsageUE id
Just id_ue -> id_ue
-ensureEqTys :: OutType -> OutType -> SDoc -> LintM ()
+ensureEqTys :: Type -> Type -> SDoc -> LintM ()
-- check ty2 is subtype of ty1 (ie, has same structure but usage
-- annotations need only be consistent, not equal)
-- Assumes ty1,ty2 are have already had the substitution applied
@@ -3885,7 +3756,7 @@ mkLetErr bndr rhs
hang (text "Rhs:")
4 (ppr rhs)]
-mkTyAppMsg :: OutType -> Type -> SDoc
+mkTyAppMsg :: Type -> Type -> SDoc
mkTyAppMsg ty arg_ty
= vcat [text "Illegal type application:",
hang (text "Function type:")
@@ -4006,13 +3877,13 @@ mkJoinBndrOccMismatchMsg bndr join_arity_bndr join_arity_occ
, text "Arity at binding site:" <+> ppr join_arity_bndr
, text "Arity at occurrence: " <+> ppr join_arity_occ ]
-mkBndrOccTypeMismatchMsg :: InVar -> InType -> InType -> SDoc
+mkBndrOccTypeMismatchMsg :: Var -> Type -> Type -> SDoc
mkBndrOccTypeMismatchMsg var bndr_ty occ_ty
= vcat [ text "Mismatch in type between binder and occurrence"
, text "Binder: " <+> ppr var <+> dcolon <+> ppr bndr_ty
, text "Occurrence:" <+> ppr var <+> dcolon <+> ppr occ_ty ]
-mkBndrOccFreeVarMsg :: InVar -> InType -> [TyCoVar] -> SDoc
+mkBndrOccFreeVarMsg :: Var -> Type -> [TyCoVar] -> SDoc
mkBndrOccFreeVarMsg var occ_ty bad_tvs
= vcat [ text "Free vars of type are shadowed:" <+> ppr bad_tvs
, text "Occurrence:" <+> ppr var <+> dcolon <+> ppr occ_ty ]
=====================================
compiler/GHC/Core/Opt/OccurAnal.hs
=====================================
@@ -2676,6 +2676,8 @@ occAnalArgs :: OccEnv -> CoreExpr -> [CoreExpr]
-> WithUsageDetails CoreExpr
-- The `fun` argument is just an accumulating parameter,
-- the base for building the application we return
+--
+-- We have applied markAllNonTail to the returned usage-details
occAnalArgs env fun args one_shots
= go emptyDetails fun args one_shots
where
@@ -2686,7 +2688,9 @@ occAnalArgs env fun args one_shots
encl | Var f <- fun, isDeadEndSig (idDmdSig f) = OccScrut
| otherwise = OccVanilla
- go uds fun [] _ = WUD uds fun
+ go uds fun [] _ = WUD (markAllNonTail uds) fun
+ -- markAllNonTail: calls in arguments are not tail calls!
+
go uds fun (arg:args) one_shots
= go (uds `andUDs` arg_uds) (fun `App` arg') args one_shots'
where
@@ -2778,8 +2782,7 @@ occAnalApp env (Var fun_id, args, ticks)
all_uds = fun_uds `andUDs` final_args_uds
- !final_args_uds = markAllNonTail $
- markAllInsideLamIf (isRhsEnv env && is_exp) $
+ !final_args_uds = markAllInsideLamIf (isRhsEnv env && is_exp) $
-- isRhsEnv: see Note [OccEncl]
args_uds
-- We mark the free vars of the argument of a constructor or PAP
@@ -2809,33 +2812,46 @@ occAnalApp env (Var fun_id, args, ticks)
-- See Note [Sources of one-shot information], bullet point A']
occAnalApp env (fun, args, ticks)
- = let app_out = mkTicks ticks app'
- in WUD (markAllNonTail (fun_uds `andUDs` args_uds)) app_out
-
+ = WUD (fun_uds `andUDs` args_uds) (mkTicks ticks app')
where
!(WUD args_uds app') = occAnalArgs env fun' args []
- !(WUD fun_uds fun') = occAnal (addAppCtxt env args) fun
- -- The addAppCtxt is a bit cunning. One iteration of the simplifier
- -- often leaves behind beta redexes like
- -- (\x y -> e) a1 a2
- -- Here we would like to mark x,y as one-shot, and treat the whole
- -- thing much like a let. We do this by pushing some OneShotLam items
- -- onto the context stack.
-
-addAppCtxt :: OccEnv -> [Arg CoreBndr] -> OccEnv
-addAppCtxt env@(OccEnv { occ_one_shots = ctxt }) args
- | n_val_args > 0
- = env { occ_one_shots = replicate n_val_args OneShotLam ++ ctxt
- , occ_encl = OccVanilla }
- -- OccVanilla: the function part of the application
- -- is no longer on OccRhs or OccScrut
- | otherwise
- = env
- where
- n_val_args = valArgCount args
+ !(WUD fun_uds fun') = go_fun env fun args
+
+ -- See Note [occAnal for applications]
+ go_fun env (Lam bndr body) (_ : args)
+ = addInScopeOne env bndr $ \ env' ->
+ let !(WUD body_uds body') = go_fun env' body args
+ !bndr' = tagLamBinder body_uds bndr
+ in WUD body_uds (Lam bndr' body')
+ go_fun env fun args
+ | null args
+ = occAnal env fun
+ | otherwise
+ = let !env' = env { occ_encl = OccVanilla }
+ -- OccVanilla: the function part of the
+ -- application is no longer OccRhs or OccScrut
+ !(WUD fun_uds fun') = occAnal env' fun
+ in WUD (markAllNonTail fun_uds) fun'
+{- Note [occAnal for applications]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+One iteration of the simplifier sometimes leaves behind beta redexes like
+ (\x y -> e) a1 a2
+This happens particularly in worker/wrapper; see Note [Join points and beta-redexes]
+in GHC.Core.Lint. In these cases there are two things we want to take care of
+in the occurrence analyser:
+
+* We don't want to mark variables inside `e` as `InsideLam`; that would just
+ delay inlining them for another iteration of the Simplifier.
+
+* If there is a join-point invocation inside `e`, we don't want to complain about
+ lost join points. See Note [Join points and beta-redexes] in GHC.Core.Lint for
+ more detail.
+
+It is easy to address both of these: in `occAnalApp`, simply walk down the
+function, matching lambdas with arguments. This is done by the local `go_fun`
+loop.
-{-
Note [Sources of one-shot information]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The occurrence analyser obtains one-shot-lambda information from two sources:
=====================================
compiler/GHC/Core/Opt/WorkWrap/Utils.hs
=====================================
@@ -241,10 +241,10 @@ mkWwBodies opts fun_id ww_arity arg_vars res_ty demands res_cpr
= (work_args, work_args, work_marks)
call_work work_fn = mkVarApps (Var work_fn) work_call_args
- call_rhs fn_rhs = mkAppsBeta fn_rhs fn_args
- -- See Note [Join points and beta-redexes]
+ call_rhs fn_rhs = mkApps fn_rhs fn_args
+ -- See Note [Join points and beta-redexes] in GHC.Core.Lint
wrapper_body = mkLams cloned_arg_vars . wrap_fn_cpr . wrap_fn_str . call_work
- -- See Note [Call-by-value for worker args]
+ -- See Note [Call-by-value for worker args]
work_seq_str_flds = mkStrictFieldSeqs (zip work_lam_args work_call_str)
worker_body = mkLams work_lam_args . work_seq_str_flds . work_fn_cpr . call_rhs
worker_args_dmds= [ idDemandInfo v | v <- work_call_args, isId v]
@@ -280,14 +280,6 @@ mkWwBodies opts fun_id ww_arity arg_vars res_ty demands res_cpr
arity_ok | isJoinId fun_id = ww_arity <= n_dmds
| otherwise = ww_arity == n_dmds
--- | Version of 'GHC.Core.mkApps' that does beta reduction on-the-fly.
--- PRECONDITION: The arg expressions are not free in any of the lambdas binders.
-mkAppsBeta :: CoreExpr -> [CoreArg] -> CoreExpr
--- The precondition holds for our call site in mkWwBodies, because all the FVs
--- of as are either cloned_arg_vars (and thus fresh) or fresh worker args.
-mkAppsBeta (Lam b body) (a:as) = bindNonRec b a $! mkAppsBeta body as
-mkAppsBeta f as = mkApps f as
-
-- See Note [Limit w/w arity]
isWorkerSmallEnough :: Int -> Int -> [Var] -> Bool
isWorkerSmallEnough max_worker_args old_n_args vars
@@ -525,36 +517,6 @@ Solution is simple: put the void argument /last/:
c.f Note [SpecConstr void argument insertion] in GHC.Core.Opt.SpecConstr
-Note [Join points and beta-redexes]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Originally, the worker would invoke the original function by calling it with
-arguments, thus producing a beta-redex for the simplifier to munch away:
-
- \x y z -> e => (\x y z -> e) wx wy wz
-
-Now that we have special rules about join points, however, this is Not Good if
-the original function is itself a join point, as then it may contain invocations
-of other join points:
-
- join j1 x = ...
- join j2 y = if y == 0 then 0 else j1 y
-
- =>
-
- join j1 x = ...
- join $wj2 y# = let wy = I# y# in (\y -> if y == 0 then 0 else jump j1 y) wy
- join j2 y = case y of I# y# -> jump $wj2 y#
-
-There can't be an intervening lambda between a join point's declaration and its
-occurrences, so $wj2 here is wrong. But of course, this is easy enough to fix:
-
- ...
- let join $wj2 y# = let wy = I# y# in let y = wy in if y == 0 then 0 else j1 y
- ...
-
-Hence we simply do the beta-reduction here. (This would be harder if we had to
-worry about hygiene, but luckily wy is freshly generated.)
-
Note [Freshen WW arguments]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we do a worker/wrapper split, we must freshen the arg vars of the original
=====================================
compiler/GHC/Core/Subst.hs
=====================================
@@ -13,7 +13,8 @@ module GHC.Core.Subst (
-- ** Substituting into expressions and related types
deShadowBinds, substRuleInfo, substRulesForImportedIds,
- substTyUnchecked, substCo, substExpr, substExprSC, substBind, substBindSC,
+ substTy, substTyUnchecked, substCo,
+ substExpr, substExprSC, substBind, substBindSC,
substUnfolding, substUnfoldingSC,
lookupIdSubst, lookupIdSubst_maybe, substIdType, substIdOcc,
substTickish, substDVarSet, substIdInfo,
@@ -42,8 +43,7 @@ import GHC.Core.FVs
import GHC.Core.Seq
import GHC.Core.Utils
- -- We are defining local versions
-import GHC.Core.Type hiding ( substTy )
+import GHC.Core.Type
import GHC.Core.Coercion( mkCoVarCo, substCoVarBndr )
import GHC.Core.TyCo.FVs
=====================================
compiler/GHC/Core/SubstTypeLets.hs
=====================================
@@ -0,0 +1,127 @@
+{-
+(c) The University of Glasgow 2006
+(c) The GRASP/AQUA Project, Glasgow University, 1993-1998
+-}
+
+module GHC.Core.SubstTypeLets(
+ substTypeLets
+ ) where
+
+import GHC.Prelude
+
+import GHC.Core
+import GHC.Core.Subst
+import GHC.Core.Utils( mkInScopeSetBndrs )
+
+import GHC.Types.Var
+
+import GHC.Utils.Misc( mapSnd )
+import GHC.Utils.Outputable
+import GHC.Utils.Panic
+
+{- Note [Substituting type-lets]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+When desugaring pattern matching we really, really need non-Lint-acceptable type-lets.
+Suppose we have
+ f (MkT a (Just a (x::a)) (y::a)) = rhs1
+ f (MkT b (Nothing b) (z::b)) = rhs2
+where
+ MkT :: ā a. Maybe a -> a -> T
+
+We desugar this to
+ f x = case x of
+ MkT w (v :: Maybe w) (p:w)
+ -> let { a=w, b=w }
+ in let { y:a=p, z:b=p }
+ in case v of
+ Just a (x:a) -> rhs1 [y::a]
+ Nothing b -> rhs2 [z::b]
+
+Look at those type-lets { a=w, b=w }. They make the type variables in the
+/two/ separately-typechecked clauses for `f` line up with the /single/ pattern
+match on `x`, which binds the type variable `w`.
+
+Key point: the body of the let is only type-correct /after/ substituting
+a:=w, b:=w. Even the next let, { y:a=p } isn't type-correct without that
+substitution, because (p:w).
+
+So the `substTypeLets` pass runs before we Lint the output of the desugarer.
+When it finds a nested type-let
+ let @a = ty in body
+it substitutes a:=ty in `body`
+
+Wrinkles
+
+(STL1) It only substitutes /nested/ type-lets, not top level.
+
+(STL2) You might think that we'd run it unconditionally, after desugaring. But actually,
+ the Simplifier (or SimpleOpt) will deal with these type-lets, so it is just Lint
+ that we must placate. We don't want to incur the cost of this pass except when
+ we are Linting.
+
+ TL;DR: we do substTypeLets as a pre-pass to the Lint pass that immediately follows
+ desugaring. See `GHC.Core.lintPassResult`, and the `lpr_preSubst` field in
+ `LintPassResultConfig`.
+-}
+
+substTypeLets :: CoreProgram -> CoreProgram
+substTypeLets binds = map stl_top binds
+ where
+ stl_top (NonRec b r) = NonRec b (stlExpr empty_subst r)
+ stl_top (Rec prs) = Rec (mapSnd (stlExpr empty_subst) prs)
+
+ empty_subst = mkEmptySubst $
+ mkInScopeSetBndrs binds
+
+----------------------
+stlBind :: Subst -> CoreBind -> (Subst, CoreBind)
+stlBind subst (Rec prs)
+ = assertPpr (not (any isTyVar bndrs)) (ppr prs) $
+ (subst', Rec prs')
+ where
+ (bndrs,rhss) = unzip prs
+ (subst', bndrs') = substRecBndrs subst bndrs
+ rhss' = map (stlExpr subst') rhss
+ prs' = bndrs' `zip` rhss'
+
+stlBind subst (NonRec bndr rhs)
+ = (subst', NonRec bndr' (stlExpr subst rhs))
+ where
+ (subst', bndr') = substBndr subst bndr
+
+----------------------
+stlExpr :: Subst -> CoreExpr -> CoreExpr
+
+stlExpr subst (Let (NonRec tv (Type ty)) body)
+ = -- This equation is the main payload of the entire pass!
+ stlExpr (extendTvSubst subst tv ty) body
+
+stlExpr subst (Let bind body)
+ = Let bind' (stlExpr subst' body)
+ where
+ (subst', bind') = stlBind subst bind
+
+stlExpr subst (Lam bndr body)
+ = Lam bndr' (stlExpr subst' body)
+ where
+ (subst', bndr') = substBndr subst bndr
+
+stlExpr subst (Case scrut bndr ty alts)
+ = Case (stlExpr subst scrut) bndr' (substTy subst ty)
+ (map stl_alt alts)
+ where
+ (subst', bndr') = substBndr subst bndr
+
+ stl_alt (Alt con bndrs rhs)
+ = Alt con bndrs' (stlExpr subst'' rhs)
+ where
+ (subst'', bndrs') = substBndrs subst' bndrs
+
+-- Simple cases
+stlExpr _ (Lit l) = Lit l
+stlExpr subst (Var v) = lookupIdSubst subst v
+stlExpr subst (App e1 e2) = App (stlExpr subst e1) (stlExpr subst e2)
+stlExpr subst (Type ty) = Type (substTy subst ty)
+stlExpr subst (Tick t e) = Tick (substTickish subst t) (stlExpr subst e)
+stlExpr subst (Cast e co) = Cast (stlExpr subst e) (substCo subst co)
+stlExpr subst (Coercion co) = Coercion (substCo subst co)
=====================================
compiler/GHC/Driver/Config/Core/Lint.hs
=====================================
@@ -52,6 +52,7 @@ endPassHscEnvIO hsc_env name_ppr_ctx pass binds rules
-- | Type-check a 'CoreProgram'. See Note [Core Lint guarantee].
lintCoreBindings :: DynFlags -> CoreToDo -> [Var] -> CoreProgram -> WarnsAndErrs
+-- ToDo: this function is not called within GHC. Why does it exist?
lintCoreBindings dflags coreToDo vars -- binds
= lintCoreBindings' $ LintConfig
{ l_diagOpts = initDiagOpts dflags
@@ -104,10 +105,15 @@ initLintPassResultConfig dflags extra_vars pass = LintPassResultConfig
{ lpr_diagOpts = initDiagOpts dflags
, lpr_platform = targetPlatform dflags
, lpr_makeLintFlags = perPassFlags dflags pass
- , lpr_passPpr = ppr pass
+ , lpr_passPpr = ppr pass
+ , lpr_preSubst = doPreSubst pass
, lpr_localsInScope = extra_vars
}
+doPreSubst :: CoreToDo -> Bool
+doPreSubst CoreDesugar = True
+doPreSubst _ = False
+
perPassFlags :: DynFlags -> CoreToDo -> LintFlags
perPassFlags dflags pass
= (defaultLintFlags dflags)
@@ -116,7 +122,8 @@ perPassFlags dflags pass
, lf_check_static_ptrs = check_static_ptrs
, lf_check_linearity = check_linearity
, lf_check_rubbish_lits = check_rubbish
- , lf_allow_weak_joins = allow_weak_joins }
+ , lf_allow_weak_joins = allow_weak_joins
+ , lf_allow_beta_joins = allow_beta_joins }
where
-- See Note [Checking for global Ids]
check_globals = case pass of
@@ -158,6 +165,11 @@ perPassFlags dflags pass
CorePrep -> True
_ -> False
+ -- See Note [Join points and beta-redexes] in GHC.Core.Lint
+ allow_beta_joins = case pass of
+ CoreDoWorkerWrapper -> True
+ _ -> False
+
initLintConfig :: DynFlags -> [Var] -> LintConfig
initLintConfig dflags vars =LintConfig
{ l_diagOpts = initDiagOpts dflags
@@ -175,4 +187,5 @@ defaultLintFlags dflags = LF { lf_check_global_ids = False
, lf_check_fixed_rep = True
, lf_check_rubbish_lits = True
, lf_allow_weak_joins = False
+ , lf_allow_beta_joins = False
}
=====================================
compiler/ghc.cabal.in
=====================================
@@ -411,6 +411,7 @@ Library
GHC.Core.SimpleOpt
GHC.Core.Stats
GHC.Core.Subst
+ GHC.Core.SubstTypeLets
GHC.Core.Tidy
GHC.CoreToIface
GHC.CoreToStg
=====================================
testsuite/tests/corelint/LintEtaExpand.stderr
=====================================
@@ -1,32 +1,16 @@
<no location info>: warning:
⢠The first argument of ācoerceā does not have a fixed runtime representation:
a :: TYPE k
- Substitution: <InScope = {a q}
- IdSubst = []
- TvSubst = []
- CvSubst = []>
in coerce BAD 1
<no location info>: warning:
⢠The first argument of ācoerceā does not have a fixed runtime representation:
āqā is not concrete.
- Substitution: <InScope = {a q}
- IdSubst = []
- TvSubst = []
- CvSubst = []>
in coerce BAD 2
<no location info>: warning:
⢠The result of the first argument of the primop ācatch#ā does not have a fixed runtime representation:
a :: TYPE q
- Substitution: <InScope = {a q}
- IdSubst = []
- TvSubst = []
- CvSubst = []>
in catch# BAD 1
<no location info>: warning:
⢠The result of the first argument of the primop ācatch#ā does not have a fixed runtime representation:
āqā is not concrete.
- Substitution: <InScope = {a q}
- IdSubst = []
- TvSubst = []
- CvSubst = []>
in catch# BAD 2
=====================================
testsuite/tests/corelint/T21115b.stderr
=====================================
@@ -6,10 +6,6 @@ T21115b.hs:9:1: warning:
In the body of lambda with binder ds :: Double#
In the body of a let with binder fail :: (# #) -> Int#
In the body of a let with binder fail :: (# #) -> Int#
- Substitution: <InScope = {}
- IdSubst = []
- TvSubst = []
- CvSubst = []>
*** Offending Program ***
Rec {
$trModule = Module (TrNameS "main"#) (TrNameS "T21115b"#)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b97d30ebf122333335da4371514ad86ā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b97d30ebf122333335da4371514ad86ā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/supersven/correctly_propagate_host-build-target] Unset CFLAGS for install phase
by Sven Tennie (ļ¼ supersven) 06 Apr '26
by Sven Tennie (ļ¼ supersven) 06 Apr '26
06 Apr '26
Sven Tennie pushed to branch wip/supersven/correctly_propagate_host-build-target at Glasgow Haskell Compiler / GHC
Commits:
38a28bd0 by Sven Tennie at 2026-04-06T11:46:06+02:00
Unset CFLAGS for install phase
- - - - -
1 changed file:
- .gitlab/ci.sh
Changes:
=====================================
.gitlab/ci.sh
=====================================
@@ -628,6 +628,10 @@ function install_bindist() {
*)
read -r -a args <<< "${INSTALL_CONFIGURE_ARGS:-}"
+ # These are meant for the ./configure script of the build phase
+ unset CFLAGS
+ unset CONF_CC_OPTS_STAGE2
+
run ${CONFIGURE_WRAPPER:-} ./configure \
--prefix="$instdir" \
"${args[@]+"${args[@]}"}" || fail "bindist configure failed"
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38a28bd0e82f3463372ea9f960d3550ā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38a28bd0e82f3463372ea9f960d3550ā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Add utility pprTrace_ function
by Marge Bot (ļ¼ marge-bot) 06 Apr '26
by Marge Bot (ļ¼ marge-bot) 06 Apr '26
06 Apr '26
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
4bf040c6 by sheaf at 2026-04-05T14:56:29-04:00
Add utility pprTrace_ function
This function is useful for quick debugging, as it can be added to a
where clause to pretty-print debugging information:
fooBar x y
| cond = body1
| otherwise = body2
where
!_ = pprTrace_ "fooBar" $
vcat [ text "x:" <+> ppr x
, text "y:" <+> ppr y
, text "cond:" <+> ppr cond
]
- - - - -
eb2d16cb by Andrew Lelechenko at 2026-04-06T05:02:32-04:00
base: improve error message for Data.Char.chr
As per https://github.com/haskell/core-libraries-committee/issues/384
- - - - -
6 changed files:
- compiler/GHC/Utils/Trace.hs
- libraries/base/changelog.md
- libraries/base/tests/enum01.stdout
- libraries/base/tests/enum01.stdout-alpha-dec-osf3
- libraries/base/tests/enum01.stdout-ws-64
- libraries/ghc-internal/src/GHC/Internal/Char.hs
Changes:
=====================================
compiler/GHC/Utils/Trace.hs
=====================================
@@ -1,6 +1,7 @@
-- | Tracing utilities
module GHC.Utils.Trace
( pprTrace
+ , pprTrace_
, pprTraceM
, pprTraceDebug
, pprTraceIt
@@ -43,6 +44,22 @@ pprTrace str doc x
| unsafeHasNoDebugOutput = x
| otherwise = pprDebugAndThen traceSDocContext trace (text str) doc x
+-- | A version of 'pprTrace' that is useful for quick debugging:
+--
+-- @
+-- fooBar x y
+-- | cond = body1
+-- | otherwise = body2
+-- where
+-- !_ = pprTrace_ "fooBar" $
+-- vcat [ text "x:" <+> ppr x
+-- , text "y:" <+> ppr y
+-- , text "cond:" <+> ppr cond
+-- ]
+-- @
+pprTrace_ :: String -> SDoc -> ()
+pprTrace_ str doc = pprTrace str doc ()
+
pprTraceM :: Applicative f => String -> SDoc -> f ()
pprTraceM str doc = pprTrace str doc (pure ())
=====================================
libraries/base/changelog.md
=====================================
@@ -28,6 +28,7 @@
* Hide implementation details when throwing exceptions in throw and throwSTM. ([CLC proposal #387](https://github.com/haskell/core-libraries-committee/issues/387))
* Change `hIsReadable` and `hIsWritable` such that they always throw a respective exception when encountering a closed or semi-closed handle, not just in the case of a file handle. ([CLC proposal #371](github.com/haskell/core-libraries-committee/issues/371))
* Annotate `onException` continuation with `WhileHandling`. ([CLC Proposal #397](https://github.com/haskell/core-libraries-committee/issues/397))
+ * Improve error message for `Data.Char.chr`. ([CLC Proposal #384](https://github.com/haskell/core-libraries-committee/issues/384))
## 4.22.0.0 *TBA*
* Shipped with GHC 9.14.1
=====================================
libraries/base/tests/enum01.stdout
=====================================
@@ -81,7 +81,7 @@ Testing Enum Char:
pred (maxBound::Char) = '\1114110'
pred (minBound::Char) = error "Prelude.Enum.Char.pred: bad argument"
(map (toEnum::Int->Char) [123,ord (minBound::Char), ord(maxBound::Char)]) = "{\NUL\1114111"
- (toEnum::Int->Char) (minBound::Int) = error "Prelude.chr: bad argument: (-2147483648)"
+ (toEnum::Int->Char) (minBound::Int) = error "Data.Char.chr: argument outside Unicode range: 0..1114111: (-2147483648)"
(map fromEnum ['X',minBound,maxBound]) = [88,0,1114111]
(take 7 ['\NUL' .. ]) = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK"
(take 7 ['\250' .. ]) = "\250\251\252\253\254\255\256"
=====================================
libraries/base/tests/enum01.stdout-alpha-dec-osf3
=====================================
@@ -65,7 +65,7 @@ Testing Enum Char:
pred (maxBound::Char) = '\1114110'
pred (minBound::Char) = error "Prelude.Enum.Char.pred: bad argument"
(map (toEnum::Int->Char) [123,ord (minBound::Char), ord(maxBound::Char)]) = "{\NUL\1114111"
- (toEnum::Int->Char) (minBound::Int) = error "Prelude.chr: bad argument"
+ (toEnum::Int->Char) (minBound::Int) = error "Data.Char.chr: argument outside Unicode range: 0..1114111:"
(map fromEnum ['X',minBound,maxBound]) = [88,0,1114111]
(take 7 ['\NUL' .. ]) = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK"
(take 7 ['\250' .. ]) = "\250\251\252\253\254\255\256"
=====================================
libraries/base/tests/enum01.stdout-ws-64
=====================================
@@ -81,7 +81,7 @@ Testing Enum Char:
pred (maxBound::Char) = '\1114110'
pred (minBound::Char) = error "Prelude.Enum.Char.pred: bad argument"
(map (toEnum::Int->Char) [123,ord (minBound::Char), ord(maxBound::Char)]) = "{\NUL\1114111"
- (toEnum::Int->Char) (minBound::Int) = error "Prelude.chr: bad argument: (-9223372036854775808)"
+ (toEnum::Int->Char) (minBound::Int) = error "Data.Char.chr: argument outside Unicode range: 0..1114111: (-9223372036854775808)"
(map fromEnum ['X',minBound,maxBound]) = [88,0,1114111]
(take 7 ['\NUL' .. ]) = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK"
(take 7 ['\250' .. ]) = "\250\251\252\253\254\255\256"
=====================================
libraries/ghc-internal/src/GHC/Internal/Char.hs
=====================================
@@ -12,7 +12,7 @@ module GHC.Internal.Char
import GHC.Internal.Classes (eqChar, neChar)
import GHC.Internal.Base (otherwise, (++))
-import GHC.Internal.Err (errorWithoutStackTrace)
+import GHC.Internal.Err (error)
import GHC.Internal.Show
import GHC.Internal.Prim (chr#, int2Word#, leWord#, Int#, Char#)
import GHC.Internal.Types (Char(..), Int(..), isTrue#)
@@ -29,4 +29,7 @@ safe_chr# i#
{-# NOINLINE chr_error #-}
chr_error :: Int# -> Char#
-chr_error i# = errorWithoutStackTrace ("Prelude.chr: bad argument: " ++ showSignedInt (I# 9#) (I# i#) "")
+chr_error i# = error ("Data.Char.chr: argument outside Unicode range: 0..1114111: " ++ showSignedInt (I# 9#) (I# i#) "")
+-- It's not really "Data.Char", but we assume that
+-- the majority of users will import it from "base:Data.Char"
+-- and not from "ghc-internal:GHC.Internal.Char".
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e924580d77c483967fd2d3d4591ceā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e924580d77c483967fd2d3d4591ceā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/ani/precise-fun-loc] make sure 3 error messages are displayed for MonadFailErrors
by Apoorv Ingle (ļ¼ ani) 06 Apr '26
by Apoorv Ingle (ļ¼ ani) 06 Apr '26
06 Apr '26
Apoorv Ingle pushed to branch wip/ani/precise-fun-loc at Glasgow Haskell Compiler / GHC
Commits:
d9a967c6 by Apoorv Ingle at 2026-04-05T20:01:51-05:00
make sure 3 error messages are displayed for MonadFailErrors
- - - - -
2 changed files:
- compiler/GHC/Tc/Types/ErrCtxt.hs
- testsuite/tests/monadfail/MonadFailErrors.stderr
Changes:
=====================================
compiler/GHC/Tc/Types/ErrCtxt.hs
=====================================
@@ -373,7 +373,8 @@ data HsCtxt
isHsCtxtLandmark :: HsCtxt -> Bool
-isHsCtxtLandmark (DerivBindCtxt{}) = True
-isHsCtxtLandmark (FunResCtxt{}) = True
+isHsCtxtLandmark (DerivBindCtxt{}) = True
+isHsCtxtLandmark (FunResCtxt{}) = True
isHsCtxtLandmark (VDQWarningCtxt{}) = True
+isHsCtxtLandmark (StmtErrCtxtPat{}) = True
isHsCtxtLandmark _ = False
=====================================
testsuite/tests/monadfail/MonadFailErrors.stderr
=====================================
@@ -14,6 +14,10 @@ MonadFailErrors.hs:14:5: error: [GHC-39999]
In the expression:
do Just x <- undefined
undefined
+ In an equation for āgeneralā:
+ general
+ = do Just x <- undefined
+ undefined
MonadFailErrors.hs:28:5: error: [GHC-39999]
⢠No instance for āMonadFail Identityā
@@ -23,6 +27,10 @@ MonadFailErrors.hs:28:5: error: [GHC-39999]
In the expression:
do Just x <- undefined
undefined
+ In an equation for āidentityā:
+ identity
+ = do Just x <- undefined
+ undefined
MonadFailErrors.hs:42:5: error: [GHC-39999]
⢠No instance for āMonadFail ((->) r)ā
@@ -32,4 +40,8 @@ MonadFailErrors.hs:42:5: error: [GHC-39999]
In the expression:
do Just x <- undefined
undefined
+ In an equation for āreaderā:
+ reader
+ = do Just x <- undefined
+ undefined
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d9a967c67e7f7eb48353d3c19be639fā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d9a967c67e7f7eb48353d3c19be639fā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/ani/precise-fun-loc] 26 commits: Bump default language edition to GHC2024
by Apoorv Ingle (ļ¼ ani) 06 Apr '26
by Apoorv Ingle (ļ¼ ani) 06 Apr '26
06 Apr '26
Apoorv Ingle pushed to branch wip/ani/precise-fun-loc at Glasgow Haskell Compiler / GHC
Commits:
7fbb4fcb by Rodrigo Mesquita at 2026-04-01T12:16:33+00:00
Bump default language edition to GHC2024
As per the accepted ghc-proposal#632
Fixes #26039
- - - - -
5ae43275 by Peng Fan at 2026-04-01T19:01:06-04:00
NCG/LA64: add cmpxchg and xchg primops
And append some new instructions for LA664 uarch.
Apply fix to cmpxchg-prim by Andreas Klebinger.
Suggestions in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15515
- - - - -
8f95534a by Duncan Coutts at 2026-04-01T19:01:52-04:00
Remove signal-based ticker implementations
Fixes issue #27073
All supported platforms should work with the pthreads + nanosleep based
ticker implementation. This avoids all the problems with using signals.
In practice, all supported platforms were probably using the non-signal
tickers already, which is probably why we do not get lots of reports
about deadlocks and other weirdness: we were definately using functions
that are not async signal safe in the tick handler (such as fflush to
flussh the eventlog).
Only Solaris was explicitly using the timer_create ticker impl, and even
Solaris could probably use the pthreads one (if anyone cared: Solaris is
no longer a Teir 3 supported platform).
Plausibly the only supported platform that this will change will be AIX,
which should now use the pthreads impl.
- - - - -
51b32b0d by Duncan Coutts at 2026-04-01T19:01:52-04:00
Tidy up some timer/ticker comments elsewhere
- - - - -
7562bcd7 by Duncan Coutts at 2026-04-01T19:01:52-04:00
Remove now-unused install_vtalrm_handler
Support function used by both of the signal-based ticker
implementations.
- - - - -
6da127c7 by Duncan Coutts at 2026-04-01T19:01:52-04:00
No longer probe for timer_create in rts/configure
It was only used by the TimerCreate.c ticker impl.
- - - - -
3fd490fa by Duncan Coutts at 2026-04-01T19:01:53-04:00
Note that rtsTimerSignal is deprecated.
- - - - -
63099b0f by Simon Jakobi at 2026-04-01T19:02:39-04:00
Add perf test for #13960
Closes #13960.
- - - - -
58009c14 by Apoorv Ingle at 2026-04-02T09:51:24+01:00
Streamline expansions using HsExpansion (#25001)
Notes added [Error Context Stack] [Typechecking by expansion: overview]
Notes updated Note [Expanding HsDo with XXExprGhcRn] [tcApp: typechecking applications]
-------------------------
Metric Decrease:
T9020
-------------------------
There are 2 key changes:
1. `HsExpand` datatype mediates between expansions
2. Replace `ErrCtxtM` to a simpler `HsCtxt` that does not depend on a `TidyEnv`
This has some consequences detailed below:
1. `HsExpand` datatype mediates between expansions
* Simplifies the implementations of `tcExpr` to work on `XExpr`
* Removes `VACtxt` (and its associated `VAExpansion` and `VACall`) datatype, it is subsumed by simply a `SrcSpan`.
* Removes the function `addHeadCtxt` as it is now mearly setting a location
* The function `tcValArgs` does its own argument number management
* move `splitHsTypes` out of `tcApp`
* Removes special case of tcBody from `tcLambdaMatches`
* Removes special case of `dsExpr` for `ExpandedThingTc`
* Renames `tcMonoExpr` -> `tcMonoLExpr`, `tcMonoExprNC` -> `tcMonoLExpr`
* Renames `EValArg`, `EValArgQL` fields: `ea_ctxt` -> `ea_loc_span` and `eaql_ctx` -> `eaql_loc_span`
* Remove `PopErrCtxt` from `XXExprGhcRn`
* `fun_orig` in tcInstFun depends on the SrcSpan of the head of the application chain (similar to addArgCtxt)
- it references the application chain head if it is user located, or
uses the error context stack as a fallback if it's a generated
location
* Make a new variant `GeneratedSrcSpan` in `SrcSpan` for HIEAst Nodes
- Expressions wrapped around `GeneratedSrcSpan` are ignored and never added to the error context stack
- In Explicit list expansion `fromListN` is wrapped with a `GeneratedSrcSpan` with `GeneratedSrcSpanDetails` field to store the original srcspan
2. Replace `ErrCtxtM` to a simpler `HsCtxt` that does not depend on a `TidyEnv`
* Merge `HsThingRn` to `HsCtxt`
* Landmark Error messages are now just computed on the fly
* Make HsExpandedRn and HsExpandedTc payload a located HsExpr GhcRn
* `HsCtxt` are tidied and zonked at the end right before printing
Co-authored-by: simonpj <simon.peytonjones(a)gmail.com>
- - - - -
bc4b4487 by Zubin Duggal at 2026-04-03T14:22:27-04:00
driver: recognise .dyn_o as a valid object file to link if passed on the command line.
This allows plugins compiled with this suffix to run.
Fixes #24486
- - - - -
5ebb9121 by Simon Jakobi at 2026-04-03T14:23:11-04:00
Add regression test for #16145
Closes #16145.
- - - - -
c1fc1c44 by Simon Peyton Jones at 2026-04-03T19:56:07-04:00
Refactor eta-expansion in Prep
The Prep pass does eta-expansion but I found cases where it was
doing bad things. So I refactored and simplified it quite a bit.
In the new design
* There is no distinction between `rhs` and `body`; in particular,
lambdas can now appear anywhere, rather than just as the RHS of
a let-binding.
* This change led to a significant simplification of Prep, and
a more straightforward explanation of eta-expansion. See the new
Note [Eta expansion]
* The consequences is that CoreToStg needs to handle naked lambdas.
This is very easy; but it does need a unique supply, which forces
some simple refactoring. Having a unique supply to hand is probably
a good thing anyway.
- - - - -
21beda2c by Simon Peyton Jones at 2026-04-03T19:56:07-04:00
Clarify Note [Interesting dictionary arguments]
Ticket #26831 ended up concluding that the code for
GHC.Core.Opt.Specialise.interestingDict was good, but the
commments were a bit inadequate.
This commit improves the comments slightly.
- - - - -
3eaac1f2 by Simon Peyton Jones at 2026-04-03T19:56:07-04:00
Make inlining a bit more eager for overloaded functions
If we have
f d = ... (class-op d x y) ...
we should be eager to inline `f`, because that may change the
higher order call (class-op d x y) into a call to a statically
known function.
See the discussion on #26831.
Even though this does a bit /more/ inlining, compile times
decrease by an average of 0.4%.
Compile time changes:
DsIncompleteRecSel3(normal) 431,786,104 -2.2%
ManyAlternatives(normal) 670,883,768 -1.6%
ManyConstructors(normal) 3,758,493,832 -2.6% GOOD
MultilineStringsPerf(normal) 29,900,576 -2.8%
T14052Type(ghci) 1,047,600,848 -1.2%
T17836(normal) 392,852,328 -5.2%
T18478(normal) 442,785,768 -1.4%
T21839c(normal) 341,536,992 -14.1% GOOD
T3064(normal) 174,086,152 +5.3% BAD
T5631(normal) 506,867,800 +1.0%
hard_hole_fits(normal) 209,530,736 -1.3%
info_table_map_perf(normal) 19,523,093,184 -1.2%
parsing001(normal) 377,810,528 -1.1%
pmcOrPats(normal) 60,075,264 -0.5%
geo. mean -0.4%
minimum -14.1%
maximum +5.3%
Runtime changes
haddock.Cabal(normal) 27,351,988,792 -0.7%
haddock.base(normal) 26,997,212,560 -0.6%
haddock.compiler(normal) 219,531,332,960 -1.0%
Metric Decrease:
LinkableUsage01
ManyConstructors
T17949
T21839c
T13035
TcPlugin_RewritePerf
hard_hole_fits
Metric Increase:
T3064
- - - - -
5cbc2c82 by Matthew Pickering at 2026-04-03T19:57:02-04:00
bytecode: Add magic header/version to bytecode files
In order to avoid confusing errors when using stale interface files (ie
from an older compiler version), we add a simple header/version check
like the one for interface files.
Fixes #27068
- - - - -
d95a1936 by fendor at 2026-04-03T19:57:02-04:00
Add constants for bytecode in-memory buffer size
Introduce a common constant for the default size of the .gbc and
.bytecodelib binary buffer.
The buffer is by default set to 1 MB.
- - - - -
b822c30a by mangoiv at 2026-04-03T19:57:49-04:00
testsuite: filter stderr for static001 on darwin
This reactivates the test on x86_64 darwin as this should have been done
long ago and ignores warnings emitted by ranlib on newer version of the
darwin toolchain since they are benign. (no symbols for stub libraries)
Fixes #27116
- - - - -
28ce1f8a by Andreas Klebinger at 2026-04-03T19:58:44-04:00
Give the Data instance for ModuleName a non-bottom toConstr implementation.
I've also taken the liberty to add Note [Data.Data instances for GHC AST Types]
describing some of the uses of Data.Data I could find.
Fixes #27129
- - - - -
8ca41ffe by mangoiv at 2026-04-03T19:59:30-04:00
issue template: fix add bug label
- - - - -
3981db0c by Sylvain Henry at 2026-04-03T20:00:33-04:00
Add more canned GC functions for common register patterns (#27142)
Based on analysis of heap-check sites across the GHC compiler and Cabal,
the following patterns were not covered by existing canned GC functions
but occurred frequently enough to warrant specialisation:
stg_gc_ppppp -- 5 GC pointers
stg_gc_ip -- unboxed word + GC pointer
stg_gc_pi -- GC pointer + unboxed word
stg_gc_ii -- two unboxed words
stg_gc_bpp -- byte (I8) + two GC pointers
Adding these reduces the fraction of heap-check sites falling back to
the generic GC path from ~1.4% to ~0.4% when compiling GHC itself.
Co-Authored-By: Claude Sonnet 4.6 <noreply(a)anthropic.com>
- - - - -
d17d1435 by Matthew Pickering at 2026-04-03T20:01:19-04:00
Make home unit dependencies stored as sets
Co-authored-by: Wolfgang Jeltsch <wolfgang(a)well-typed.com>
- - - - -
92a97015 by Simon Peyton Jones at 2026-04-05T00:58:57+01:00
Add Invariant (NoTypeShadowing) to Core
This commit addresses #26868, by adding
a new invariant (NoTypeShadowing) to Core.
See Note [No type-shadowing in Core] in GHC.Core
- - - - -
8b5a5020 by Simon Peyton Jones at 2026-04-05T00:58:57+01:00
Major refactor of free-variable functions
For some time we have had two free-variable mechanims for types:
* The "FV" mechanism, embodied in GHC.Utils.FV, which worked OK, but
was fragile where eta-expansion was concerned.
* The TyCoFolder mechanism, using a one-shot EndoOS accumulator
I finally got tired of this and refactored the whole thing, thereby
addressing #27080. Now we have
* `GHC.Types.Var.FV`, which has a composable free-variable result type,
very much in the spirit of the old `FV`, but much more robust.
(It uses the "one shot trick".)
* GHC.Core.TyCo.FVs now has just one technology for free variables.
All this led to a lot of renaming.
There are couple of error-message changes. The change in T18451
makes an already-poor error message even more mysterious. But
it really needs a separate look.
We also now traverse the AST in a different order leading to a different
but still deterministic order for FVs and test output has been adjusted
accordingly.
- - - - -
4bf040c6 by sheaf at 2026-04-05T14:56:29-04:00
Add utility pprTrace_ function
This function is useful for quick debugging, as it can be added to a
where clause to pretty-print debugging information:
fooBar x y
| cond = body1
| otherwise = body2
where
!_ = pprTrace_ "fooBar" $
vcat [ text "x:" <+> ppr x
, text "y:" <+> ppr y
, text "cond:" <+> ppr cond
]
- - - - -
9a91e070 by Apoorv Ingle at 2026-04-05T19:49:30-05:00
compute a more accuate application chain head location
- - - - -
27e242f0 by Apoorv Ingle at 2026-04-05T20:00:36-05:00
make sure 3 error messages are displayed for MonadFailErrors
- - - - -
366 changed files:
- .gitlab/ci.sh
- .gitlab/issue_templates/default.md
- compiler/GHC.hs
- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/ByteCode/Serialize.hs
- compiler/GHC/CmmToAsm/LA64/CodeGen.hs
- compiler/GHC/CmmToAsm/LA64/Instr.hs
- compiler/GHC/CmmToAsm/LA64/Ppr.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Subst.hs
- compiler/GHC/Core/Tidy.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Phases.hs
- compiler/GHC/Hs/DocString.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Expr.hs-boot
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Utils.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Parser/HaddockLex.x
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Expr.hs-boot
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Lit.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Splice.hs-boot
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Runtime/Debugger/Breakpoints.hs
- compiler/GHC/Stg/Lint.hs
- compiler/GHC/StgToCmm/Heap.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Infer.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Hole.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Do.hs
- + compiler/GHC/Tc/Gen/Expand.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Expr.hs-boot
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Match.hs-boot
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Instance/FunDeps.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Class.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Types/BasicTypes.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/CtLoc.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Types/Origin.hs-boot
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Utils/TcType.hs-boot
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/Types/Error.hs
- + compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/Name/Set.hs
- compiler/GHC/Types/SrcLoc.hs
- + compiler/GHC/Types/Var/FV.hs
- compiler/GHC/Types/Var/Set.hs
- compiler/GHC/Unit/Finder.hs
- compiler/GHC/Unit/Home/Graph.hs
- compiler/GHC/Unit/State.hs
- + compiler/GHC/Unit/State.hs-boot
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/EndoOS.hs
- ā compiler/GHC/Utils/FV.hs
- compiler/GHC/Utils/Logger.hs
- compiler/GHC/Utils/Trace.hs
- compiler/Language/Haskell/Syntax/Module/Name.hs
- compiler/ghc.cabal.in
- docs/users_guide/exts/control.rst
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Info.hs
- ā m4/fp_check_timer_create.m4
- rts/HeapStackCheck.cmm
- rts/RtsSymbols.c
- rts/Timer.c
- rts/configure.ac
- rts/include/rts/Timer.h
- rts/include/stg/MiscClosures.h
- rts/include/stg/SMP.h
- rts/posix/Signals.c
- rts/posix/Signals.h
- rts/posix/Ticker.c
- ā rts/posix/ticker/Setitimer.c
- ā rts/posix/ticker/TimerCreate.c
- testsuite/driver/testlib.py
- testsuite/tests/ado/ado004.hs
- testsuite/tests/annotations/should_fail/annfail02.hs
- testsuite/tests/annotations/should_fail/annfail02.stderr
- testsuite/tests/arityanal/should_compile/Arity01.stderr
- testsuite/tests/arityanal/should_compile/Arity05.stderr
- testsuite/tests/arityanal/should_compile/Arity08.stderr
- testsuite/tests/arityanal/should_compile/Arity11.stderr
- testsuite/tests/arityanal/should_compile/Arity14.stderr
- testsuite/tests/array/should_run/arr020.hs
- testsuite/tests/core-to-stg/T19700.hs
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/cpranal/should_compile/T18401.stderr
- testsuite/tests/deSugar/should_fail/DsStrictFail.hs
- testsuite/tests/deriving/should_compile/T15798b.hs
- testsuite/tests/deriving/should_compile/T15798c.hs
- testsuite/tests/deriving/should_compile/T15798c.stderr
- testsuite/tests/deriving/should_compile/T24955a.hs
- testsuite/tests/deriving/should_compile/T24955a.stderr
- testsuite/tests/deriving/should_compile/T24955b.hs
- testsuite/tests/deriving/should_compile/T24955c.hs
- testsuite/tests/deriving/should_fail/T10598_fail4.hs
- testsuite/tests/deriving/should_fail/T10598_fail4.stderr
- testsuite/tests/deriving/should_fail/T10598_fail5.hs
- testsuite/tests/deriving/should_fail/T10598_fail5.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail4.stderr
- testsuite/tests/dmdanal/sigs/T22241.hs
- testsuite/tests/driver/all.T
- testsuite/tests/driver/bytecode-object/Makefile
- testsuite/tests/driver/bytecode-object/all.T
- testsuite/tests/gadt/T20485.hs
- testsuite/tests/ghci.debugger/scripts/all.T
- testsuite/tests/ghci.debugger/scripts/break012.hs
- testsuite/tests/ghci.debugger/scripts/break012.stdout
- testsuite/tests/ghci/prog-mhu001/prog-mhu001c.stdout
- testsuite/tests/ghci/prog-mhu002/all.T
- testsuite/tests/ghci/scripts/Makefile
- testsuite/tests/ghci/should_run/all.T
- testsuite/tests/indexed-types/should_compile/T15322.hs
- testsuite/tests/indexed-types/should_compile/T15322.stderr
- testsuite/tests/indexed-types/should_fail/T2693.stderr
- testsuite/tests/indexed-types/should_fail/T5439.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/linear/should_fail/T18888.hs
- testsuite/tests/module/T20007.hs
- testsuite/tests/module/T20007.stderr
- testsuite/tests/module/mod90.hs
- testsuite/tests/module/mod90.stderr
- testsuite/tests/monadfail/MonadFailErrors.stderr
- testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.hs
- testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.hs
- testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
- testsuite/tests/overloadedrecflds/should_fail/all.T
- testsuite/tests/parser/should_fail/ParserNoLambdaCase.hs
- testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail9.stderr
- testsuite/tests/parser/should_fail/T16270h.hs
- testsuite/tests/parser/should_fail/T16270h.stderr
- testsuite/tests/parser/should_fail/readFail001.hs
- testsuite/tests/parser/should_fail/readFail001.stderr
- testsuite/tests/partial-sigs/should_compile/SomethingShowable.hs
- testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr
- testsuite/tests/partial-sigs/should_compile/T10403.stderr
- testsuite/tests/partial-sigs/should_compile/T12844.stderr
- testsuite/tests/partial-sigs/should_compile/T15039a.stderr
- testsuite/tests/partial-sigs/should_compile/T15039b.stderr
- testsuite/tests/partial-sigs/should_compile/T15039c.stderr
- testsuite/tests/partial-sigs/should_compile/T15039d.stderr
- testsuite/tests/partial-sigs/should_fail/T10999.stderr
- testsuite/tests/partial-sigs/should_fail/T12634.stderr
- + testsuite/tests/perf/compiler/T13960.hs
- testsuite/tests/perf/compiler/all.T
- testsuite/tests/plugins/Makefile
- + testsuite/tests/plugins/T24486-plugin/Makefile
- + testsuite/tests/plugins/T24486-plugin/Setup.hs
- + testsuite/tests/plugins/T24486-plugin/T24486-plugin.cabal
- + testsuite/tests/plugins/T24486-plugin/T24486_Plugin.hs
- + testsuite/tests/plugins/T24486.hs
- + testsuite/tests/plugins/T24486_Helper.hs
- testsuite/tests/plugins/all.T
- testsuite/tests/plugins/late-plugin/LatePlugin.hs
- testsuite/tests/plugins/test-defaulting-plugin.stderr
- testsuite/tests/polykinds/T15789.stderr
- testsuite/tests/polykinds/T18451.stderr
- testsuite/tests/polykinds/T7151.hs
- testsuite/tests/polykinds/T7151.stderr
- testsuite/tests/polykinds/T7328.stderr
- testsuite/tests/polykinds/T7433.hs
- testsuite/tests/polykinds/T7433.stderr
- testsuite/tests/printer/T17697.stderr
- testsuite/tests/profiling/should_run/callstack001.stdout
- testsuite/tests/programs/andy_cherry/test.T
- testsuite/tests/rebindable/rebindable6.stderr
- testsuite/tests/rename/should_fail/T10668.hs
- testsuite/tests/rename/should_fail/T10668.stderr
- testsuite/tests/rename/should_fail/T12681.hs
- testsuite/tests/rename/should_fail/T12681.stderr
- testsuite/tests/rename/should_fail/T13568.hs
- testsuite/tests/rename/should_fail/T13568.stderr
- testsuite/tests/rename/should_fail/T13644.hs
- testsuite/tests/rename/should_fail/T13644.stderr
- testsuite/tests/rename/should_fail/T13847.hs
- testsuite/tests/rename/should_fail/T13847.stderr
- testsuite/tests/rename/should_fail/T14032c.hs
- testsuite/tests/rename/should_fail/T19843l.hs
- testsuite/tests/rename/should_fail/T19843l.stderr
- testsuite/tests/rename/should_fail/T25901_imp_hq_fail_5.stderr
- testsuite/tests/rename/should_fail/T25901_imp_sq_fail_2.stderr
- testsuite/tests/rename/should_fail/T5385.hs
- testsuite/tests/rename/should_fail/T5385.stderr
- testsuite/tests/rep-poly/RepPolyRecordUpdate.stderr
- testsuite/tests/roles/should_fail/Roles5.hs
- testsuite/tests/roles/should_fail/Roles5.stderr
- testsuite/tests/runghc/Makefile
- + testsuite/tests/runghc/T16145.hs
- + testsuite/tests/runghc/T16145.stdout
- + testsuite/tests/runghc/T16145_aux.hs
- testsuite/tests/runghc/all.T
- testsuite/tests/showIface/DocsInHiFile.hs
- testsuite/tests/showIface/DocsInHiFile1.stdout
- testsuite/tests/showIface/DocsInHiFileTH.hs
- testsuite/tests/showIface/DocsInHiFileTH.stdout
- testsuite/tests/showIface/DocsInHiFileTHExternal.hs
- testsuite/tests/showIface/HaddockIssue849.hs
- testsuite/tests/showIface/HaddockIssue849.stdout
- testsuite/tests/showIface/HaddockOpts.hs
- testsuite/tests/showIface/HaddockOpts.stdout
- testsuite/tests/showIface/HaddockSpanIssueT24378.hs
- testsuite/tests/showIface/HaddockSpanIssueT24378.stdout
- testsuite/tests/showIface/MagicHashInHaddocks.hs
- testsuite/tests/showIface/MagicHashInHaddocks.stdout
- testsuite/tests/showIface/Makefile
- testsuite/tests/showIface/NoExportList.hs
- testsuite/tests/showIface/NoExportList.stdout
- testsuite/tests/showIface/PragmaDocs.stdout
- testsuite/tests/showIface/ReExports.stdout
- testsuite/tests/simplCore/T9646/test.T
- testsuite/tests/simplCore/should_compile/DsSpecPragmas.stderr
- testsuite/tests/simplCore/should_compile/T15205.stderr
- testsuite/tests/simplCore/should_compile/T21960.hs
- testsuite/tests/simplCore/should_compile/T24229a.stderr
- testsuite/tests/simplCore/should_compile/T24229b.stderr
- testsuite/tests/simplCore/should_compile/T24359a.stderr
- testsuite/tests/simplCore/should_compile/T26116.stderr
- testsuite/tests/simplCore/should_compile/T26709.stderr
- testsuite/tests/simplCore/should_compile/T4908.stderr
- testsuite/tests/simplCore/should_compile/spec-inline.stderr
- testsuite/tests/th/TH_Promoted1Tuple.hs
- testsuite/tests/th/TH_Roles1.hs
- testsuite/tests/typecheck/no_skolem_info/T20063.stderr
- + testsuite/tests/typecheck/should_compile/ExpansionQLIm.hs
- testsuite/tests/typecheck/should_compile/MutRec.hs
- testsuite/tests/typecheck/should_compile/T10770a.hs
- testsuite/tests/typecheck/should_compile/T11339.hs
- testsuite/tests/typecheck/should_compile/T11397.hs
- testsuite/tests/typecheck/should_compile/T13526.hs
- testsuite/tests/typecheck/should_compile/T14590.stderr
- testsuite/tests/typecheck/should_compile/T18467.hs
- testsuite/tests/typecheck/should_compile/T18467.stderr
- testsuite/tests/typecheck/should_compile/T25180.stderr
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_compile/free_monad_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/tc081.hs
- testsuite/tests/typecheck/should_compile/tc141.hs
- testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion1.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
- testsuite/tests/typecheck/should_fail/T10971d.stderr
- testsuite/tests/typecheck/should_fail/T12589.stderr
- testsuite/tests/typecheck/should_fail/T13311.stderr
- testsuite/tests/typecheck/should_fail/T17773.stderr
- testsuite/tests/typecheck/should_fail/T23427.hs
- testsuite/tests/typecheck/should_fail/T2846b.stderr
- testsuite/tests/typecheck/should_fail/T3323.stderr
- testsuite/tests/typecheck/should_fail/T3613.stderr
- testsuite/tests/typecheck/should_fail/T6069.stderr
- testsuite/tests/typecheck/should_fail/T6078.hs
- testsuite/tests/typecheck/should_fail/T7453.hs
- testsuite/tests/typecheck/should_fail/T7453.stderr
- testsuite/tests/typecheck/should_fail/T7851.stderr
- testsuite/tests/typecheck/should_fail/T7857.stderr
- testsuite/tests/typecheck/should_fail/T8570.hs
- testsuite/tests/typecheck/should_fail/T8570.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/tcfail083.hs
- testsuite/tests/typecheck/should_fail/tcfail083.stderr
- testsuite/tests/typecheck/should_fail/tcfail084.hs
- testsuite/tests/typecheck/should_fail/tcfail084.stderr
- testsuite/tests/typecheck/should_fail/tcfail094.hs
- testsuite/tests/typecheck/should_fail/tcfail094.stderr
- testsuite/tests/typecheck/should_fail/tcfail102.stderr
- testsuite/tests/typecheck/should_fail/tcfail128.stderr
- testsuite/tests/typecheck/should_fail/tcfail140.stderr
- testsuite/tests/typecheck/should_fail/tcfail181.stderr
- testsuite/tests/typecheck/should_run/T1735.hs
- testsuite/tests/typecheck/should_run/T1735_Help/Basics.hs
- testsuite/tests/typecheck/should_run/T3731.hs
- testsuite/tests/vdq-rta/should_fail/T24159_type_syntax_th_fail.script
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.hs
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
- testsuite/tests/warnings/should_fail/T24396c.hs
- testsuite/tests/warnings/should_fail/T24396c.stderr
- testsuite/tests/wasm/should_run/control-flow/LoadCmmGroup.hs
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Parsers.hs
- utils/check-exact/Transform.hs
- utils/check-exact/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
- utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9af140d496ca06466d1d14678fe90ā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9af140d496ca06466d1d14678fe90ā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T27078] 40 commits: ghc-boot: remove unused SizedSeq instances and functions
by Simon Peyton Jones (ļ¼ simonpj) 05 Apr '26
by Simon Peyton Jones (ļ¼ simonpj) 05 Apr '26
05 Apr '26
Simon Peyton Jones pushed to branch wip/T27078 at Glasgow Haskell Compiler / GHC
Commits:
cf942119 by Cheng Shao at 2026-03-30T15:24:37-04:00
ghc-boot: remove unused SizedSeq instances and functions
This commit removes unused `SizedSeq` instances and functions, only
keeping the bits we need for hpc tick sequence for now.
- - - - -
22c5b7cc by Cheng Shao at 2026-03-30T15:24:38-04:00
ghci: remove unused GHCi.BinaryArray
This patch removes the unused `GHCi.BinaryArray` module from `ghci`.
Closes #27108.
- - - - -
77abb4ab by Cheng Shao at 2026-03-30T15:25:21-04:00
testsuite: mark T17912 as fragile on Windows
T17912 is still fragile on Windows, it sometimes unexpectedly pass in
CI. This especially strains our already scarce Windows CI runner
resources. Mark it as fragile on Windows for the time being.
- - - - -
d741a6cc by Andreas Klebinger at 2026-03-31T04:39:33-04:00
Bump minimum shake version for hadrian.
We also add the shake version we want to stack.yaml
Fixes #26884
- - - - -
5e556f9e by Vladislav Zavialov at 2026-03-31T04:40:16-04:00
Status check for the HsType~HsExpr refactoring (#25121)
Add a test case to track the status of a refactoring project within GHC
whose goal is to arrive at the following declaration:
type HsType = HsExpr
The rationale for this is to increase code reuse between the term- and
type-level code in the compiler front-end (AST, parser, renamer, type checker).
The status report is saved to testsuite/tests/ghc-api/T25121_status.stdout
and provides useful insights into what needs to happen to make progress on
the ticket.
- - - - -
acffb1b1 by fendor at 2026-03-31T04:41:02-04:00
Extract Binary instances to `GHC.ByteCode.Binary`
- - - - -
e2ea8e25 by fendor at 2026-03-31T04:41:02-04:00
Add `seqNonEmpty` for evaluating `NonEmpty a`
- - - - -
048b00b7 by fendor at 2026-03-31T04:41:02-04:00
Record `LinkableUsage` instead of `Linkable` in `LoaderState`
Retaining a ByteCode `Linkable` after it has been loaded retains its
`UnlinkedBCO`, keeping it alive for the remainder of the program.
This starts accumulating a lot of `UnlinkedBCO` and memory over time.
However, the `Linkable` is merely used to later record its usage in
`mkObjectUsage`, which is used for recompilation checking.
However, this is incorrect, as the interface file and bytecode objects
could be in different states, e.g. the interface changes, but the
bytecode library hasn't changed so we don't need to recompile and vice
versa.
By computing a `Fingerprint` for the `ModuleByteCode`, and recording it
in the `LinkableUsage`, we know precisely whether the `ByteCode` object
on disk is outdated.
Thus, parts of this commit just makes sure that we efficiently compute a
`Fingerprint` for `ModuleByteCode` and store it in the on-disk
representation of `ModuleByteCode`.
We change the `LoaderState` to retain `LinkableUsage`, which is smaller
representation of a `Linkable`. This allows us to free the unneeded
fields of `Linkable` after linking them.
We declare the following memory invariants that this commit implements:
* No `LinkablePart` should be retained from `LoaderState`.
* `Linkable`s should be unloaded after they have been loaded.
These invariants are unfortunately tricky to automatically uphold, so we
are simply documenting our assumptions for now.
We introduce the `linkable-space` test which makes sure that after
loading, no `DotGBC` or `UnlinkedBCO` is retained.
-------------------------
Metric Increase:
MultiLayerModulesTH_OneShot
-------------------------
We allocate a bit more, but the peak number of bytes doesn't change.
While a bit unfortunate, accepting the metric increase.
We add multiple new performance measurements where we were able to
observe the desired memory invariants. Further, we add regression tests
to validate that the recompilation checker behaves more correct than
before.
- - - - -
2d1c1997 by Simon Jakobi at 2026-03-31T04:41:46-04:00
Eliminate dictionary-passing in ListMap operations
Mark the ListMap helpers 'INLINABLE' so importing modules can specialise
the 'TrieMap (ListMap m)' methods and avoid recursive dictionary-passing.
See Note [Making ListMap operations specialisable].
Fixes #27097
- - - - -
ed2c6570 by Cheng Shao at 2026-03-31T04:42:33-04:00
testsuite: fix testdir cleanup logic on Windows
testdir cleanup is unreliable on Windows (#13162) and despite existing
hacks in the driver, new failure mode has occurred. This patch makes
it print the warning and carry on when failed to clean up a testdir,
instead of reporting a spurious framework failure. See added comment
for detailed explanation.
- - - - -
d9388e29 by Simon Jakobi at 2026-03-31T13:14:59-04:00
Add regression test for #18177
Closes #18177.
Assisted-by: Codex
- - - - -
6a10045c by mangoiv at 2026-03-31T13:15:43-04:00
ci: allow metric decrease for two tests on i386
There has been a nightly failure on i386 due to a compiler runtime
improvement on i386 debian 12. We allow that.
Metric Decrease (test_env='i386-linux-deb12'):
T12707 T8095
- - - - -
7fbb4fcb by Rodrigo Mesquita at 2026-04-01T12:16:33+00:00
Bump default language edition to GHC2024
As per the accepted ghc-proposal#632
Fixes #26039
- - - - -
5ae43275 by Peng Fan at 2026-04-01T19:01:06-04:00
NCG/LA64: add cmpxchg and xchg primops
And append some new instructions for LA664 uarch.
Apply fix to cmpxchg-prim by Andreas Klebinger.
Suggestions in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15515
- - - - -
8f95534a by Duncan Coutts at 2026-04-01T19:01:52-04:00
Remove signal-based ticker implementations
Fixes issue #27073
All supported platforms should work with the pthreads + nanosleep based
ticker implementation. This avoids all the problems with using signals.
In practice, all supported platforms were probably using the non-signal
tickers already, which is probably why we do not get lots of reports
about deadlocks and other weirdness: we were definately using functions
that are not async signal safe in the tick handler (such as fflush to
flussh the eventlog).
Only Solaris was explicitly using the timer_create ticker impl, and even
Solaris could probably use the pthreads one (if anyone cared: Solaris is
no longer a Teir 3 supported platform).
Plausibly the only supported platform that this will change will be AIX,
which should now use the pthreads impl.
- - - - -
51b32b0d by Duncan Coutts at 2026-04-01T19:01:52-04:00
Tidy up some timer/ticker comments elsewhere
- - - - -
7562bcd7 by Duncan Coutts at 2026-04-01T19:01:52-04:00
Remove now-unused install_vtalrm_handler
Support function used by both of the signal-based ticker
implementations.
- - - - -
6da127c7 by Duncan Coutts at 2026-04-01T19:01:52-04:00
No longer probe for timer_create in rts/configure
It was only used by the TimerCreate.c ticker impl.
- - - - -
3fd490fa by Duncan Coutts at 2026-04-01T19:01:53-04:00
Note that rtsTimerSignal is deprecated.
- - - - -
63099b0f by Simon Jakobi at 2026-04-01T19:02:39-04:00
Add perf test for #13960
Closes #13960.
- - - - -
58009c14 by Apoorv Ingle at 2026-04-02T09:51:24+01:00
Streamline expansions using HsExpansion (#25001)
Notes added [Error Context Stack] [Typechecking by expansion: overview]
Notes updated Note [Expanding HsDo with XXExprGhcRn] [tcApp: typechecking applications]
-------------------------
Metric Decrease:
T9020
-------------------------
There are 2 key changes:
1. `HsExpand` datatype mediates between expansions
2. Replace `ErrCtxtM` to a simpler `HsCtxt` that does not depend on a `TidyEnv`
This has some consequences detailed below:
1. `HsExpand` datatype mediates between expansions
* Simplifies the implementations of `tcExpr` to work on `XExpr`
* Removes `VACtxt` (and its associated `VAExpansion` and `VACall`) datatype, it is subsumed by simply a `SrcSpan`.
* Removes the function `addHeadCtxt` as it is now mearly setting a location
* The function `tcValArgs` does its own argument number management
* move `splitHsTypes` out of `tcApp`
* Removes special case of tcBody from `tcLambdaMatches`
* Removes special case of `dsExpr` for `ExpandedThingTc`
* Renames `tcMonoExpr` -> `tcMonoLExpr`, `tcMonoExprNC` -> `tcMonoLExpr`
* Renames `EValArg`, `EValArgQL` fields: `ea_ctxt` -> `ea_loc_span` and `eaql_ctx` -> `eaql_loc_span`
* Remove `PopErrCtxt` from `XXExprGhcRn`
* `fun_orig` in tcInstFun depends on the SrcSpan of the head of the application chain (similar to addArgCtxt)
- it references the application chain head if it is user located, or
uses the error context stack as a fallback if it's a generated
location
* Make a new variant `GeneratedSrcSpan` in `SrcSpan` for HIEAst Nodes
- Expressions wrapped around `GeneratedSrcSpan` are ignored and never added to the error context stack
- In Explicit list expansion `fromListN` is wrapped with a `GeneratedSrcSpan` with `GeneratedSrcSpanDetails` field to store the original srcspan
2. Replace `ErrCtxtM` to a simpler `HsCtxt` that does not depend on a `TidyEnv`
* Merge `HsThingRn` to `HsCtxt`
* Landmark Error messages are now just computed on the fly
* Make HsExpandedRn and HsExpandedTc payload a located HsExpr GhcRn
* `HsCtxt` are tidied and zonked at the end right before printing
Co-authored-by: simonpj <simon.peytonjones(a)gmail.com>
- - - - -
bc4b4487 by Zubin Duggal at 2026-04-03T14:22:27-04:00
driver: recognise .dyn_o as a valid object file to link if passed on the command line.
This allows plugins compiled with this suffix to run.
Fixes #24486
- - - - -
5ebb9121 by Simon Jakobi at 2026-04-03T14:23:11-04:00
Add regression test for #16145
Closes #16145.
- - - - -
c1fc1c44 by Simon Peyton Jones at 2026-04-03T19:56:07-04:00
Refactor eta-expansion in Prep
The Prep pass does eta-expansion but I found cases where it was
doing bad things. So I refactored and simplified it quite a bit.
In the new design
* There is no distinction between `rhs` and `body`; in particular,
lambdas can now appear anywhere, rather than just as the RHS of
a let-binding.
* This change led to a significant simplification of Prep, and
a more straightforward explanation of eta-expansion. See the new
Note [Eta expansion]
* The consequences is that CoreToStg needs to handle naked lambdas.
This is very easy; but it does need a unique supply, which forces
some simple refactoring. Having a unique supply to hand is probably
a good thing anyway.
- - - - -
21beda2c by Simon Peyton Jones at 2026-04-03T19:56:07-04:00
Clarify Note [Interesting dictionary arguments]
Ticket #26831 ended up concluding that the code for
GHC.Core.Opt.Specialise.interestingDict was good, but the
commments were a bit inadequate.
This commit improves the comments slightly.
- - - - -
3eaac1f2 by Simon Peyton Jones at 2026-04-03T19:56:07-04:00
Make inlining a bit more eager for overloaded functions
If we have
f d = ... (class-op d x y) ...
we should be eager to inline `f`, because that may change the
higher order call (class-op d x y) into a call to a statically
known function.
See the discussion on #26831.
Even though this does a bit /more/ inlining, compile times
decrease by an average of 0.4%.
Compile time changes:
DsIncompleteRecSel3(normal) 431,786,104 -2.2%
ManyAlternatives(normal) 670,883,768 -1.6%
ManyConstructors(normal) 3,758,493,832 -2.6% GOOD
MultilineStringsPerf(normal) 29,900,576 -2.8%
T14052Type(ghci) 1,047,600,848 -1.2%
T17836(normal) 392,852,328 -5.2%
T18478(normal) 442,785,768 -1.4%
T21839c(normal) 341,536,992 -14.1% GOOD
T3064(normal) 174,086,152 +5.3% BAD
T5631(normal) 506,867,800 +1.0%
hard_hole_fits(normal) 209,530,736 -1.3%
info_table_map_perf(normal) 19,523,093,184 -1.2%
parsing001(normal) 377,810,528 -1.1%
pmcOrPats(normal) 60,075,264 -0.5%
geo. mean -0.4%
minimum -14.1%
maximum +5.3%
Runtime changes
haddock.Cabal(normal) 27,351,988,792 -0.7%
haddock.base(normal) 26,997,212,560 -0.6%
haddock.compiler(normal) 219,531,332,960 -1.0%
Metric Decrease:
LinkableUsage01
ManyConstructors
T17949
T21839c
T13035
TcPlugin_RewritePerf
hard_hole_fits
Metric Increase:
T3064
- - - - -
5cbc2c82 by Matthew Pickering at 2026-04-03T19:57:02-04:00
bytecode: Add magic header/version to bytecode files
In order to avoid confusing errors when using stale interface files (ie
from an older compiler version), we add a simple header/version check
like the one for interface files.
Fixes #27068
- - - - -
d95a1936 by fendor at 2026-04-03T19:57:02-04:00
Add constants for bytecode in-memory buffer size
Introduce a common constant for the default size of the .gbc and
.bytecodelib binary buffer.
The buffer is by default set to 1 MB.
- - - - -
b822c30a by mangoiv at 2026-04-03T19:57:49-04:00
testsuite: filter stderr for static001 on darwin
This reactivates the test on x86_64 darwin as this should have been done
long ago and ignores warnings emitted by ranlib on newer version of the
darwin toolchain since they are benign. (no symbols for stub libraries)
Fixes #27116
- - - - -
28ce1f8a by Andreas Klebinger at 2026-04-03T19:58:44-04:00
Give the Data instance for ModuleName a non-bottom toConstr implementation.
I've also taken the liberty to add Note [Data.Data instances for GHC AST Types]
describing some of the uses of Data.Data I could find.
Fixes #27129
- - - - -
8ca41ffe by mangoiv at 2026-04-03T19:59:30-04:00
issue template: fix add bug label
- - - - -
3981db0c by Sylvain Henry at 2026-04-03T20:00:33-04:00
Add more canned GC functions for common register patterns (#27142)
Based on analysis of heap-check sites across the GHC compiler and Cabal,
the following patterns were not covered by existing canned GC functions
but occurred frequently enough to warrant specialisation:
stg_gc_ppppp -- 5 GC pointers
stg_gc_ip -- unboxed word + GC pointer
stg_gc_pi -- GC pointer + unboxed word
stg_gc_ii -- two unboxed words
stg_gc_bpp -- byte (I8) + two GC pointers
Adding these reduces the fraction of heap-check sites falling back to
the generic GC path from ~1.4% to ~0.4% when compiling GHC itself.
Co-Authored-By: Claude Sonnet 4.6 <noreply(a)anthropic.com>
- - - - -
d17d1435 by Matthew Pickering at 2026-04-03T20:01:19-04:00
Make home unit dependencies stored as sets
Co-authored-by: Wolfgang Jeltsch <wolfgang(a)well-typed.com>
- - - - -
92a97015 by Simon Peyton Jones at 2026-04-05T00:58:57+01:00
Add Invariant (NoTypeShadowing) to Core
This commit addresses #26868, by adding
a new invariant (NoTypeShadowing) to Core.
See Note [No type-shadowing in Core] in GHC.Core
- - - - -
8b5a5020 by Simon Peyton Jones at 2026-04-05T00:58:57+01:00
Major refactor of free-variable functions
For some time we have had two free-variable mechanims for types:
* The "FV" mechanism, embodied in GHC.Utils.FV, which worked OK, but
was fragile where eta-expansion was concerned.
* The TyCoFolder mechanism, using a one-shot EndoOS accumulator
I finally got tired of this and refactored the whole thing, thereby
addressing #27080. Now we have
* `GHC.Types.Var.FV`, which has a composable free-variable result type,
very much in the spirit of the old `FV`, but much more robust.
(It uses the "one shot trick".)
* GHC.Core.TyCo.FVs now has just one technology for free variables.
All this led to a lot of renaming.
There are couple of error-message changes. The change in T18451
makes an already-poor error message even more mysterious. But
it really needs a separate look.
We also now traverse the AST in a different order leading to a different
but still deterministic order for FVs and test output has been adjusted
accordingly.
- - - - -
4bf040c6 by sheaf at 2026-04-05T14:56:29-04:00
Add utility pprTrace_ function
This function is useful for quick debugging, as it can be added to a
where clause to pretty-print debugging information:
fooBar x y
| cond = body1
| otherwise = body2
where
!_ = pprTrace_ "fooBar" $
vcat [ text "x:" <+> ppr x
, text "y:" <+> ppr y
, text "cond:" <+> ppr cond
]
- - - - -
e36a6470 by Simon Peyton Jones at 2026-04-05T20:33:38+01:00
Experiement wth killing off special treatment...
...of type lets in Lint,
* add special treatment of join points in OccurAnal
* special passs after the desugarer
* Worker-wrapper uses lambdas
- - - - -
4ade9978 by Simon Peyton Jones at 2026-04-05T20:33:38+01:00
Delete the substition stuff in Lint
- - - - -
33ba976f by Simon Peyton Jones at 2026-04-05T20:33:38+01:00
Wibbles
- - - - -
c3b648ea by Simon Peyton Jones at 2026-04-06T00:23:53+01:00
More wibbles
- - - - -
419 changed files:
- .gitlab/ci.sh
- .gitlab/issue_templates/default.md
- compiler/GHC.hs
- compiler/GHC/Builtin/PrimOps.hs
- + compiler/GHC/ByteCode/Binary.hs
- + compiler/GHC/ByteCode/Recomp/Binary.hs
- compiler/GHC/ByteCode/Serialize.hs
- compiler/GHC/CmmToAsm/LA64/CodeGen.hs
- compiler/GHC/CmmToAsm/LA64/Instr.hs
- compiler/GHC/CmmToAsm/LA64/Ppr.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Subst.hs
- + compiler/GHC/Core/SubstTypeLets.hs
- compiler/GHC/Core/Tidy.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Data/TrieMap.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Hooks.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Phases.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/Driver/Plugins.hs
- compiler/GHC/Hs/DocString.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Expr.hs-boot
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/HsToCore/Usage.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Utils.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Iface/Recomp/Types.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Linker/ByteCode.hs
- compiler/GHC/Linker/Deps.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Linker/Types.hs
- compiler/GHC/Parser/HaddockLex.x
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Expr.hs-boot
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Lit.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Splice.hs-boot
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Runtime/Debugger/Breakpoints.hs
- compiler/GHC/Runtime/Loader.hs
- compiler/GHC/Stg/Lint.hs
- compiler/GHC/StgToCmm/Heap.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Infer.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Hole.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Do.hs
- + compiler/GHC/Tc/Gen/Expand.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Expr.hs-boot
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Match.hs-boot
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Instance/FunDeps.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Class.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Types/BasicTypes.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/CtLoc.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Types/Origin.hs-boot
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Utils/TcType.hs-boot
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/Types/Error.hs
- + compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/Name/Set.hs
- compiler/GHC/Types/SrcLoc.hs
- + compiler/GHC/Types/Var/FV.hs
- compiler/GHC/Types/Var/Set.hs
- compiler/GHC/Unit/Finder.hs
- compiler/GHC/Unit/Home/Graph.hs
- compiler/GHC/Unit/Home/ModInfo.hs
- compiler/GHC/Unit/Module/Deps.hs
- compiler/GHC/Unit/Module/Status.hs
- compiler/GHC/Unit/State.hs
- + compiler/GHC/Unit/State.hs-boot
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/EndoOS.hs
- ā compiler/GHC/Utils/FV.hs
- compiler/GHC/Utils/Logger.hs
- compiler/GHC/Utils/Misc.hs
- compiler/GHC/Utils/Trace.hs
- compiler/Language/Haskell/Syntax/Module/Name.hs
- compiler/ghc.cabal.in
- docs/users_guide/exts/control.rst
- ghc/GHCi/Leak.hs
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Info.hs
- hadrian/hadrian.cabal
- hadrian/stack.yaml
- libraries/base/tests/IO/all.T
- libraries/ghc-boot/GHC/Data/SizedSeq.hs
- ā libraries/ghci/GHCi/BinaryArray.hs
- libraries/ghci/ghci.cabal.in
- ā m4/fp_check_timer_create.m4
- rts/HeapStackCheck.cmm
- rts/RtsSymbols.c
- rts/Timer.c
- rts/configure.ac
- rts/include/rts/Timer.h
- rts/include/stg/MiscClosures.h
- rts/include/stg/SMP.h
- rts/posix/Signals.c
- rts/posix/Signals.h
- rts/posix/Ticker.c
- ā rts/posix/ticker/Setitimer.c
- ā rts/posix/ticker/TimerCreate.c
- testsuite/driver/testlib.py
- testsuite/tests/ado/ado004.hs
- testsuite/tests/annotations/should_fail/annfail02.hs
- testsuite/tests/annotations/should_fail/annfail02.stderr
- testsuite/tests/arityanal/should_compile/Arity01.stderr
- testsuite/tests/arityanal/should_compile/Arity05.stderr
- testsuite/tests/arityanal/should_compile/Arity08.stderr
- testsuite/tests/arityanal/should_compile/Arity11.stderr
- testsuite/tests/arityanal/should_compile/Arity14.stderr
- testsuite/tests/array/should_run/arr020.hs
- + testsuite/tests/bytecode/TLinkable/BCOTemplate.hs
- + testsuite/tests/bytecode/TLinkable/LinkableUsage01.stderr
- + testsuite/tests/bytecode/TLinkable/LinkableUsage02.stderr
- + testsuite/tests/bytecode/TLinkable/Makefile
- + testsuite/tests/bytecode/TLinkable/all.T
- + testsuite/tests/bytecode/TLinkable/genLinkables.sh
- + testsuite/tests/bytecode/TLinkable/linkable-space.hs
- + testsuite/tests/bytecode/TLinkable/linkable-space.stdout
- testsuite/tests/core-to-stg/T19700.hs
- testsuite/tests/corelint/LintEtaExpand.stderr
- testsuite/tests/corelint/T21115b.stderr
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/cpranal/should_compile/T18401.stderr
- testsuite/tests/deSugar/should_fail/DsStrictFail.hs
- testsuite/tests/deriving/should_compile/T15798b.hs
- testsuite/tests/deriving/should_compile/T15798c.hs
- testsuite/tests/deriving/should_compile/T15798c.stderr
- testsuite/tests/deriving/should_compile/T24955a.hs
- testsuite/tests/deriving/should_compile/T24955a.stderr
- testsuite/tests/deriving/should_compile/T24955b.hs
- testsuite/tests/deriving/should_compile/T24955c.hs
- testsuite/tests/deriving/should_fail/T10598_fail4.hs
- testsuite/tests/deriving/should_fail/T10598_fail4.stderr
- testsuite/tests/deriving/should_fail/T10598_fail5.hs
- testsuite/tests/deriving/should_fail/T10598_fail5.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail4.stderr
- testsuite/tests/dmdanal/sigs/T22241.hs
- + testsuite/tests/driver/T18177.hs
- testsuite/tests/driver/all.T
- testsuite/tests/driver/bytecode-object/Makefile
- testsuite/tests/driver/bytecode-object/all.T
- testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp_th.stdout
- + testsuite/tests/driver/recomp022/A1.hs
- + testsuite/tests/driver/recomp022/A2.hs
- + testsuite/tests/driver/recomp022/A3.hs
- + testsuite/tests/driver/recomp022/B.hs
- + testsuite/tests/driver/recomp022/C.hs
- + testsuite/tests/driver/recomp022/Makefile
- + testsuite/tests/driver/recomp022/all.T
- + testsuite/tests/driver/recomp022/recomp022a.stdout
- + testsuite/tests/driver/recomp022/recomp022b.stdout
- testsuite/tests/gadt/T20485.hs
- + testsuite/tests/ghc-api/T25121_status.hs
- + testsuite/tests/ghc-api/T25121_status.stdout
- testsuite/tests/ghc-api/all.T
- testsuite/tests/ghci.debugger/scripts/all.T
- testsuite/tests/ghci.debugger/scripts/break012.hs
- testsuite/tests/ghci.debugger/scripts/break012.stdout
- testsuite/tests/ghci/prog-mhu001/prog-mhu001c.stdout
- testsuite/tests/ghci/prog-mhu002/all.T
- testsuite/tests/ghci/scripts/Makefile
- testsuite/tests/ghci/should_run/BinaryArray.hs
- testsuite/tests/ghci/should_run/all.T
- testsuite/tests/indexed-types/should_compile/T15322.hs
- testsuite/tests/indexed-types/should_compile/T15322.stderr
- testsuite/tests/indexed-types/should_fail/T2693.stderr
- testsuite/tests/indexed-types/should_fail/T5439.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/linear/should_fail/T18888.hs
- testsuite/tests/module/T20007.hs
- testsuite/tests/module/T20007.stderr
- testsuite/tests/module/mod90.hs
- testsuite/tests/module/mod90.stderr
- testsuite/tests/monadfail/MonadFailErrors.stderr
- testsuite/tests/overloadedrecflds/should_fail/NoFieldSelectorsFail.hs
- testsuite/tests/overloadedrecflds/should_fail/T18999_NoDisambiguateRecordFields.hs
- testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
- testsuite/tests/overloadedrecflds/should_fail/all.T
- testsuite/tests/parser/should_fail/ParserNoLambdaCase.hs
- testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail9.stderr
- testsuite/tests/parser/should_fail/T16270h.hs
- testsuite/tests/parser/should_fail/T16270h.stderr
- testsuite/tests/parser/should_fail/readFail001.hs
- testsuite/tests/parser/should_fail/readFail001.stderr
- testsuite/tests/partial-sigs/should_compile/SomethingShowable.hs
- testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr
- testsuite/tests/partial-sigs/should_compile/T10403.stderr
- testsuite/tests/partial-sigs/should_compile/T12844.stderr
- testsuite/tests/partial-sigs/should_compile/T15039a.stderr
- testsuite/tests/partial-sigs/should_compile/T15039b.stderr
- testsuite/tests/partial-sigs/should_compile/T15039c.stderr
- testsuite/tests/partial-sigs/should_compile/T15039d.stderr
- testsuite/tests/partial-sigs/should_fail/T10999.stderr
- testsuite/tests/partial-sigs/should_fail/T12634.stderr
- + testsuite/tests/perf/compiler/T13960.hs
- testsuite/tests/perf/compiler/all.T
- testsuite/tests/plugins/Makefile
- + testsuite/tests/plugins/T24486-plugin/Makefile
- + testsuite/tests/plugins/T24486-plugin/Setup.hs
- + testsuite/tests/plugins/T24486-plugin/T24486-plugin.cabal
- + testsuite/tests/plugins/T24486-plugin/T24486_Plugin.hs
- + testsuite/tests/plugins/T24486.hs
- + testsuite/tests/plugins/T24486_Helper.hs
- testsuite/tests/plugins/all.T
- testsuite/tests/plugins/late-plugin/LatePlugin.hs
- testsuite/tests/plugins/test-defaulting-plugin.stderr
- testsuite/tests/polykinds/T15789.stderr
- testsuite/tests/polykinds/T18451.stderr
- testsuite/tests/polykinds/T7151.hs
- testsuite/tests/polykinds/T7151.stderr
- testsuite/tests/polykinds/T7328.stderr
- testsuite/tests/polykinds/T7433.hs
- testsuite/tests/polykinds/T7433.stderr
- testsuite/tests/printer/T17697.stderr
- testsuite/tests/profiling/should_run/callstack001.stdout
- testsuite/tests/programs/andy_cherry/test.T
- testsuite/tests/rebindable/rebindable6.stderr
- testsuite/tests/rename/should_fail/T10668.hs
- testsuite/tests/rename/should_fail/T10668.stderr
- testsuite/tests/rename/should_fail/T12681.hs
- testsuite/tests/rename/should_fail/T12681.stderr
- testsuite/tests/rename/should_fail/T13568.hs
- testsuite/tests/rename/should_fail/T13568.stderr
- testsuite/tests/rename/should_fail/T13644.hs
- testsuite/tests/rename/should_fail/T13644.stderr
- testsuite/tests/rename/should_fail/T13847.hs
- testsuite/tests/rename/should_fail/T13847.stderr
- testsuite/tests/rename/should_fail/T14032c.hs
- testsuite/tests/rename/should_fail/T19843l.hs
- testsuite/tests/rename/should_fail/T19843l.stderr
- testsuite/tests/rename/should_fail/T25901_imp_hq_fail_5.stderr
- testsuite/tests/rename/should_fail/T25901_imp_sq_fail_2.stderr
- testsuite/tests/rename/should_fail/T5385.hs
- testsuite/tests/rename/should_fail/T5385.stderr
- testsuite/tests/rep-poly/RepPolyRecordUpdate.stderr
- testsuite/tests/roles/should_fail/Roles5.hs
- testsuite/tests/roles/should_fail/Roles5.stderr
- testsuite/tests/runghc/Makefile
- + testsuite/tests/runghc/T16145.hs
- + testsuite/tests/runghc/T16145.stdout
- + testsuite/tests/runghc/T16145_aux.hs
- testsuite/tests/runghc/all.T
- testsuite/tests/showIface/DocsInHiFile.hs
- testsuite/tests/showIface/DocsInHiFile1.stdout
- testsuite/tests/showIface/DocsInHiFileTH.hs
- testsuite/tests/showIface/DocsInHiFileTH.stdout
- testsuite/tests/showIface/DocsInHiFileTHExternal.hs
- testsuite/tests/showIface/HaddockIssue849.hs
- testsuite/tests/showIface/HaddockIssue849.stdout
- testsuite/tests/showIface/HaddockOpts.hs
- testsuite/tests/showIface/HaddockOpts.stdout
- testsuite/tests/showIface/HaddockSpanIssueT24378.hs
- testsuite/tests/showIface/HaddockSpanIssueT24378.stdout
- testsuite/tests/showIface/MagicHashInHaddocks.hs
- testsuite/tests/showIface/MagicHashInHaddocks.stdout
- testsuite/tests/showIface/Makefile
- testsuite/tests/showIface/NoExportList.hs
- testsuite/tests/showIface/NoExportList.stdout
- testsuite/tests/showIface/PragmaDocs.stdout
- testsuite/tests/showIface/ReExports.stdout
- testsuite/tests/simplCore/T9646/test.T
- testsuite/tests/simplCore/should_compile/DsSpecPragmas.stderr
- testsuite/tests/simplCore/should_compile/T15205.stderr
- testsuite/tests/simplCore/should_compile/T21960.hs
- testsuite/tests/simplCore/should_compile/T24229a.stderr
- testsuite/tests/simplCore/should_compile/T24229b.stderr
- testsuite/tests/simplCore/should_compile/T24359a.stderr
- testsuite/tests/simplCore/should_compile/T26116.stderr
- testsuite/tests/simplCore/should_compile/T26709.stderr
- testsuite/tests/simplCore/should_compile/T4908.stderr
- testsuite/tests/simplCore/should_compile/spec-inline.stderr
- testsuite/tests/th/TH_Promoted1Tuple.hs
- testsuite/tests/th/TH_Roles1.hs
- testsuite/tests/typecheck/no_skolem_info/T20063.stderr
- + testsuite/tests/typecheck/should_compile/ExpansionQLIm.hs
- testsuite/tests/typecheck/should_compile/MutRec.hs
- testsuite/tests/typecheck/should_compile/T10770a.hs
- testsuite/tests/typecheck/should_compile/T11339.hs
- testsuite/tests/typecheck/should_compile/T11397.hs
- testsuite/tests/typecheck/should_compile/T13526.hs
- testsuite/tests/typecheck/should_compile/T14590.stderr
- testsuite/tests/typecheck/should_compile/T18467.hs
- testsuite/tests/typecheck/should_compile/T18467.stderr
- testsuite/tests/typecheck/should_compile/T25180.stderr
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_compile/free_monad_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/tc081.hs
- testsuite/tests/typecheck/should_compile/tc141.hs
- testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion1.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
- testsuite/tests/typecheck/should_fail/T10971d.stderr
- testsuite/tests/typecheck/should_fail/T12589.stderr
- testsuite/tests/typecheck/should_fail/T13311.stderr
- testsuite/tests/typecheck/should_fail/T17773.stderr
- testsuite/tests/typecheck/should_fail/T23427.hs
- testsuite/tests/typecheck/should_fail/T2846b.stderr
- testsuite/tests/typecheck/should_fail/T3323.stderr
- testsuite/tests/typecheck/should_fail/T3613.stderr
- testsuite/tests/typecheck/should_fail/T6069.stderr
- testsuite/tests/typecheck/should_fail/T6078.hs
- testsuite/tests/typecheck/should_fail/T7453.hs
- testsuite/tests/typecheck/should_fail/T7453.stderr
- testsuite/tests/typecheck/should_fail/T7851.stderr
- testsuite/tests/typecheck/should_fail/T7857.stderr
- testsuite/tests/typecheck/should_fail/T8570.hs
- testsuite/tests/typecheck/should_fail/T8570.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/tcfail083.hs
- testsuite/tests/typecheck/should_fail/tcfail083.stderr
- testsuite/tests/typecheck/should_fail/tcfail084.hs
- testsuite/tests/typecheck/should_fail/tcfail084.stderr
- testsuite/tests/typecheck/should_fail/tcfail094.hs
- testsuite/tests/typecheck/should_fail/tcfail094.stderr
- testsuite/tests/typecheck/should_fail/tcfail102.stderr
- testsuite/tests/typecheck/should_fail/tcfail128.stderr
- testsuite/tests/typecheck/should_fail/tcfail140.stderr
- testsuite/tests/typecheck/should_fail/tcfail181.stderr
- testsuite/tests/typecheck/should_run/T1735.hs
- testsuite/tests/typecheck/should_run/T1735_Help/Basics.hs
- testsuite/tests/typecheck/should_run/T3731.hs
- testsuite/tests/vdq-rta/should_fail/T24159_type_syntax_th_fail.script
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.hs
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
- testsuite/tests/warnings/should_fail/T24396c.hs
- testsuite/tests/warnings/should_fail/T24396c.stderr
- testsuite/tests/wasm/should_run/control-flow/LoadCmmGroup.hs
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Parsers.hs
- utils/check-exact/Transform.hs
- utils/check-exact/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
- utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e4baa453015a7134d49da08309f37cā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e4baa453015a7134d49da08309f37cā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-reinstallable-base] Onward [skip ci]
by Simon Peyton Jones (ļ¼ simonpj) 05 Apr '26
by Simon Peyton Jones (ļ¼ simonpj) 05 Apr '26
05 Apr '26
Simon Peyton Jones pushed to branch wip/spj-reinstallable-base at Glasgow Haskell Compiler / GHC
Commits:
667ee7bd by Simon Peyton Jones at 2026-04-06T00:22:35+01:00
Onward [skip ci]
including renaming GHC.Builtin.Utils to GHC.Builtin
- - - - -
40 changed files:
- compiler/GHC/Builtin/Utils.hs ā compiler/GHC/Builtin.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/Types/Prim.hs
- compiler/GHC/Core.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Binary.hs
- compiler/GHC/Iface/Errors/Types.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/StgToCmm/DataCon.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Deriv/RdrNames.hs
- compiler/GHC/Tc/Errors/Hole.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Types/Name.hs
- compiler/GHC/Types/Name/Cache.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Unit/External.hs
- compiler/ghc.cabal.in
- libraries/base/src/Data/Array/Byte.hs
- libraries/base/src/Data/Complex.hs
- libraries/base/src/Data/Fixed.hs
- libraries/base/src/Data/Semigroup.hs
- libraries/base/src/GHC/Fingerprint.hs
- libraries/base/src/GHC/KnownKeyNames.hs
- libraries/base/src/System/Timeout.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Data.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/667ee7bdcc7bce865b9c33b2e4c27e6ā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/667ee7bdcc7bce865b9c33b2e4c27e6ā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
05 Apr '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
4bf040c6 by sheaf at 2026-04-05T14:56:29-04:00
Add utility pprTrace_ function
This function is useful for quick debugging, as it can be added to a
where clause to pretty-print debugging information:
fooBar x y
| cond = body1
| otherwise = body2
where
!_ = pprTrace_ "fooBar" $
vcat [ text "x:" <+> ppr x
, text "y:" <+> ppr y
, text "cond:" <+> ppr cond
]
- - - - -
1 changed file:
- compiler/GHC/Utils/Trace.hs
Changes:
=====================================
compiler/GHC/Utils/Trace.hs
=====================================
@@ -1,6 +1,7 @@
-- | Tracing utilities
module GHC.Utils.Trace
( pprTrace
+ , pprTrace_
, pprTraceM
, pprTraceDebug
, pprTraceIt
@@ -43,6 +44,22 @@ pprTrace str doc x
| unsafeHasNoDebugOutput = x
| otherwise = pprDebugAndThen traceSDocContext trace (text str) doc x
+-- | A version of 'pprTrace' that is useful for quick debugging:
+--
+-- @
+-- fooBar x y
+-- | cond = body1
+-- | otherwise = body2
+-- where
+-- !_ = pprTrace_ "fooBar" $
+-- vcat [ text "x:" <+> ppr x
+-- , text "y:" <+> ppr y
+-- , text "cond:" <+> ppr cond
+-- ]
+-- @
+pprTrace_ :: String -> SDoc -> ()
+pprTrace_ str doc = pprTrace str doc ()
+
pprTraceM :: Applicative f => String -> SDoc -> f ()
pprTraceM str doc = pprTrace str doc (pure ())
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bf040c6420f5916f436ea37ab9e609ā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bf040c6420f5916f436ea37ab9e609ā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][master] 2 commits: Add Invariant (NoTypeShadowing) to Core
by Marge Bot (ļ¼ marge-bot) 05 Apr '26
by Marge Bot (ļ¼ marge-bot) 05 Apr '26
05 Apr '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
92a97015 by Simon Peyton Jones at 2026-04-05T00:58:57+01:00
Add Invariant (NoTypeShadowing) to Core
This commit addresses #26868, by adding
a new invariant (NoTypeShadowing) to Core.
See Note [No type-shadowing in Core] in GHC.Core
- - - - -
8b5a5020 by Simon Peyton Jones at 2026-04-05T00:58:57+01:00
Major refactor of free-variable functions
For some time we have had two free-variable mechanims for types:
* The "FV" mechanism, embodied in GHC.Utils.FV, which worked OK, but
was fragile where eta-expansion was concerned.
* The TyCoFolder mechanism, using a one-shot EndoOS accumulator
I finally got tired of this and refactored the whole thing, thereby
addressing #27080. Now we have
* `GHC.Types.Var.FV`, which has a composable free-variable result type,
very much in the spirit of the old `FV`, but much more robust.
(It uses the "one shot trick".)
* GHC.Core.TyCo.FVs now has just one technology for free variables.
All this led to a lot of renaming.
There are couple of error-message changes. The change in T18451
makes an already-poor error message even more mysterious. But
it really needs a separate look.
We also now traverse the AST in a different order leading to a different
but still deterministic order for FVs and test output has been adjusted
accordingly.
- - - - -
90 changed files:
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Subst.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Expr.hs-boot
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Lit.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Splice.hs-boot
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Hole.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Instance/FunDeps.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/Types/Name/Set.hs
- + compiler/GHC/Types/Var/FV.hs
- compiler/GHC/Types/Var/Set.hs
- compiler/GHC/Utils/EndoOS.hs
- ā compiler/GHC/Utils/FV.hs
- compiler/ghc.cabal.in
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/cpranal/should_compile/T18401.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail4.stderr
- testsuite/tests/indexed-types/should_fail/T2693.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/partial-sigs/should_compile/T10403.stderr
- testsuite/tests/partial-sigs/should_compile/T12844.stderr
- testsuite/tests/partial-sigs/should_compile/T15039a.stderr
- testsuite/tests/partial-sigs/should_compile/T15039b.stderr
- testsuite/tests/partial-sigs/should_compile/T15039c.stderr
- testsuite/tests/partial-sigs/should_compile/T15039d.stderr
- testsuite/tests/partial-sigs/should_fail/T10999.stderr
- testsuite/tests/partial-sigs/should_fail/T12634.stderr
- testsuite/tests/polykinds/T15789.stderr
- testsuite/tests/polykinds/T18451.stderr
- testsuite/tests/polykinds/T7328.stderr
- testsuite/tests/simplCore/should_compile/DsSpecPragmas.stderr
- testsuite/tests/simplCore/should_compile/T24229a.stderr
- testsuite/tests/simplCore/should_compile/T24229b.stderr
- testsuite/tests/simplCore/should_compile/T24359a.stderr
- testsuite/tests/simplCore/should_compile/T26116.stderr
- testsuite/tests/simplCore/should_compile/T4908.stderr
- testsuite/tests/simplCore/should_compile/spec-inline.stderr
- testsuite/tests/typecheck/no_skolem_info/T20063.stderr
- testsuite/tests/typecheck/should_compile/T25180.stderr
- testsuite/tests/typecheck/should_compile/free_monad_hole_fits.stderr
- testsuite/tests/typecheck/should_fail/T10971d.stderr
- testsuite/tests/typecheck/should_fail/T12589.stderr
- testsuite/tests/typecheck/should_fail/T13311.stderr
- testsuite/tests/typecheck/should_fail/T17773.stderr
- testsuite/tests/typecheck/should_fail/T2846b.stderr
- testsuite/tests/typecheck/should_fail/T7851.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d17d1435d1ac1f1e4f806181da944eā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d17d1435d1ac1f1e4f806181da944eā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/marge_bot_batch_merge_job] Add utility pprTrace_ function
by Marge Bot (ļ¼ marge-bot) 05 Apr '26
by Marge Bot (ļ¼ marge-bot) 05 Apr '26
05 Apr '26
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
5e924580 by sheaf at 2026-04-05T12:05:13-04:00
Add utility pprTrace_ function
This function is useful for quick debugging, as it can be added to a
where clause to pretty-print debugging information:
fooBar x y
| cond = body1
| otherwise = body2
where
!_ = pprTrace_ "fooBar" $
vcat [ text "x:" <+> ppr x
, text "y:" <+> ppr y
, text "cond:" <+> ppr cond
]
- - - - -
1 changed file:
- compiler/GHC/Utils/Trace.hs
Changes:
=====================================
compiler/GHC/Utils/Trace.hs
=====================================
@@ -1,6 +1,7 @@
-- | Tracing utilities
module GHC.Utils.Trace
( pprTrace
+ , pprTrace_
, pprTraceM
, pprTraceDebug
, pprTraceIt
@@ -43,6 +44,22 @@ pprTrace str doc x
| unsafeHasNoDebugOutput = x
| otherwise = pprDebugAndThen traceSDocContext trace (text str) doc x
+-- | A version of 'pprTrace' that is useful for quick debugging:
+--
+-- @
+-- fooBar x y
+-- | cond = body1
+-- | otherwise = body2
+-- where
+-- !_ = pprTrace_ "fooBar" $
+-- vcat [ text "x:" <+> ppr x
+-- , text "y:" <+> ppr y
+-- , text "cond:" <+> ppr cond
+-- ]
+-- @
+pprTrace_ :: String -> SDoc -> ()
+pprTrace_ str doc = pprTrace str doc ()
+
pprTraceM :: Applicative f => String -> SDoc -> f ()
pprTraceM str doc = pprTrace str doc (pure ())
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e924580d77c483967fd2d3d4591ce1ā¦
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e924580d77c483967fd2d3d4591ce1ā¦
You're receiving this email because of your account on gitlab.haskell.org.
1
0