[Git][ghc/ghc][wip/T24359] 7 commits: Deal correctly with Given CallStack constraints
sheaf (@sheaf)
gitlab at gitlab.haskell.org
Tue Feb 18 10:04:41 UTC 2025
sheaf pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC
Commits:
e22a14fc by Simon Peyton Jones at 2025-02-11T16:21:10+00:00
Deal correctly with Given CallStack constraints
As #25675 showed, the CallStack solving mechanism was failing
to account for Given CallStack constraints.
This small patch fixes it and improves the Notes.
Small improvement to GHCi debugger output in break011, break024,
which is discussed on the MR !13883
- - - - -
db3e810f by Simon Peyton Jones at 2025-02-12T09:12:30-05:00
Fix inlineBoringOk again
This MR fixes #25713, which turned out to be a consequence of not
completing #17182.
I think I have now gotten it right. See the new
Note [inlineBoringOk]
- - - - -
3ea75ab8 by sheaf at 2025-02-17T16:49:40+01:00
Account for skolem escape in mightEqualLater
This commit:
1. Refactors checkTyEqRhs to allow it be called in pure contexts,
which means it skips doing any on-the-fly promotion.
2. Calls checkTyEqRhs in mightEqualLater to check whether it a
MetaTv can unify with a RHS or whether that would cause e.g.
skolem escape errors or concreteness errors.
Fixes #25744
- - - - -
1e80abe6 by Simon Peyton Jones at 2025-02-18T11:04:26+01:00
Specialising expressions -- at last
This MR addresses #24359, which implements the GHC proposal 493 on SPECIALISE pragmas.
* The old code path (using SpecSig and SpecPrag) still exists.
* The new code path (using SpecSigE and SpecPragE) runs alongside it.
* All SPECIALISE pragmas are routed through the new code path, except
if you give multiple type sigs, when the old code path is still used.
* Main documentation: Note [Handling new-form SPECIALISE pragmas] in
GHC.Tc.Gen.Sig`
Thanks to @sheaf for helping with this MR.
The Big Thing is to introduce
{-# SPECIALISE forall x. f @Int x True #-}
where you can give type arguments and value argument to specialise; and
you can quantify them with forall, just as in Rules.
I thought it was going to be pretty simple, but it was a Long, Long Saga.
Highlights
* Overview Note [Handling new-form SPECIALISE pragmas] in GHC.Tc.Gen.Sig
- New data constructor `SpecSigE` in data type `L.H.S.Binds.Sig`
- New data construtor `SpecPragE` in data type `GHC.Hs.Binds.TcSpecPrag`
- Renamer: uses `checkSpecESigShape` to decide which function to assocate the
SPECIALISE pragma with
- Some of the action is in `GHC.Tc.Gen.Sig.tcSpecPrag`
- The rest is in `GHC.HsToCore.Binds.dsSpec`
* All of GHC.Tc.Gen.Rule is moved into GHC.Tc.Gen.Sig, because the code is
very closely related.
* The forall'd binders for SPECIALISE are the same as those for a RULE, so I
refactored, introducing data type `L.H.S.Binds.RuleBndrs`, with functions
to rename, zonk, typecheck it. I refactored this data type a bit; nicer now.
* On the LHS of RULES, or SPECIALISE, we want to disable the tricky mechanims
described in Note [Desugaring non-canonical evidence] in GHC.HsToCore.Expr.
Previously it wasn't fully disabled (just set to the empty set), and that
didn't quite work in the new regime.
* There are knock-on changes to Template Haskell.
* For the LHS of a RULE and a SPECIALISE expression, I wanted to simplify
it /without/ inlining the let-bindings for evidence variables. I added
a flag `so_inline` to the SimpleOpt optimiser to support this. The
entry point is `GHC.Core.SimpleOpt.simpleOptExprNoInline`
* Since forever we have had a hack for type variables on the LHS of
RULES. I took the opportunity to tidy this up. The main action is
in the zonker. See GHC.Tc.Zonk.Type Note [Free tyvars on rule LHS],
and especially data construtor `SkolemiseFlexi`
in data type `GHC.Tc.Zonk.Env.ZonkFlexi`
* Move `scopedSort` from GHC.Core.TyCo.FVs to GHC.Core.Predicate
Reason: it now works for Ids as well, and I wanted to use isEvVar,
which is defined in GHC.Core.Predicate
Avoiding module loops meant that instead of exporting GHC.Core.TyCo.Tidy
from GHC.Core.Type, modules now import the former directly.
I also took the opportunity to remove unused exports
from GHC.Core.Type.hs-boot
* Flag stuff:
- Add flag `-Wdeprecated-pragmas` and use it to control the warning when
using old-style SPECIALISE pragmas with multiple type ascriptions,
- Add flag `-Wuseless-specialisations` and use it to control the warning emitted
when GHC determines that a SPECIALISE pragma would have no effect. Don't
want if the SPECIALISE is SPECIALISE INLINE (#4444)
In response to #25389, we continue to generate these seemingly code for these
seemingly useless SPECIALISE pragmas
- Adds deprecations to Template Haskell `pragSpecD` and `pracSpecInlD`,
* Split up old-style SPECIALISE pragmas in GHC.Internal.Float,
GHC.Internal.Numeric, GHC.Internal.Real
* Remove useless SPECIALISE pragmas in Data.Array (updating the array submodule)
Smaller things:
- Update the Users Guide
- Add mention of the changes to the 9.14 release notes as well as
the Template Haskell changelog,
- - - - -
627d36b0 by Simon Peyton Jones at 2025-02-18T11:04:30+01:00
Warn about rules that previously quantified over equalities
- - - - -
2a8fea45 by sheaf at 2025-02-18T11:04:30+01:00
Add -Wrule-lhs-equalities warning
This commit adds a new warning flag, -Wrule-lhs-equalities, which
controls the warning message that is emitted when the LHS of a RULE
gives rise to equality constraints that previous GHC versions would
have quantified over.
GHC instead discards such RULES, as GHC was never able to generate
a rule template that would ever fire; it's better to be explicit about
the fact that the RULE doesn't work.
- - - - -
38069f78 by sheaf at 2025-02-18T11:04:30+01:00
New plan from Feb 10
- - - - -
166 changed files:
- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Builtin/PrimOps/Ids.hs
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/CSE.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Predicate.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/Tidy.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/Ppr.hs
- compiler/GHC/Core/TyCo/Tidy.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Type.hs-boot
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/Core/Unfold/Make.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/Driver/Config.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Stats.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Errors/Ppr.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Foreign/Call.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/Iface/Decl.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Runtime/Debugger.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/Runtime/Heap/Inspect.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/HsType.hs
- − compiler/GHC/Tc/Gen/Rule.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/Solver/Types.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/Tc/Zonk/Env.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Var.hs
- compiler/Language/Haskell/Syntax/Binds.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- docs/users_guide/9.14.1-notes.rst
- docs/users_guide/exts/pragmas.rst
- docs/users_guide/using-warnings.rst
- libraries/array
- libraries/ghc-boot-th/GHC/Internal/TH/Ppr.hs
- libraries/ghc-internal/src/GHC/Internal/Float.hs
- libraries/ghc-internal/src/GHC/Internal/Numeric.hs
- libraries/ghc-internal/src/GHC/Internal/Real.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
- libraries/template-haskell/Language/Haskell/TH/Lib.hs
- libraries/template-haskell/changelog.md
- + testsuite/tests/deSugar/should_compile/T10251.stderr
- testsuite/tests/diagnostic-codes/codes.stdout
- testsuite/tests/ghci.debugger/scripts/break011.stdout
- testsuite/tests/ghci.debugger/scripts/break024.stdout
- testsuite/tests/interface-stability/template-haskell-exports.stdout
- testsuite/tests/parser/should_compile/OpaqueParseWarn1.stderr
- testsuite/tests/parser/should_fail/T7848.stderr
- + testsuite/tests/profiling/should_run/T25675.hs
- + testsuite/tests/profiling/should_run/T25675.stdout
- testsuite/tests/profiling/should_run/all.T
- + testsuite/tests/simplCore/should_compile/DsSpecPragmas.hs
- + testsuite/tests/simplCore/should_compile/DsSpecPragmas.stderr
- testsuite/tests/simplCore/should_compile/T12603.stdout
- testsuite/tests/simplCore/should_compile/T15445.stderr
- testsuite/tests/simplCore/should_compile/T22375DataFamily.stderr
- + testsuite/tests/simplCore/should_compile/T24359a.hs
- + testsuite/tests/simplCore/should_compile/T24359a.stderr
- + testsuite/tests/simplCore/should_compile/T25389.hs
- + testsuite/tests/simplCore/should_compile/T25389.stderr
- + testsuite/tests/simplCore/should_compile/T25713.hs
- + testsuite/tests/simplCore/should_compile/T25713.stderr
- testsuite/tests/simplCore/should_compile/T4398.stderr
- testsuite/tests/simplCore/should_compile/T5821.hs
- testsuite/tests/simplCore/should_compile/T8537.stderr
- + testsuite/tests/simplCore/should_compile/T9578b.hs
- testsuite/tests/simplCore/should_compile/all.T
- − testsuite/tests/simplCore/should_compile/simpl016.stderr
- + testsuite/tests/simplCore/should_fail/T25117a.hs
- + testsuite/tests/simplCore/should_fail/T25117a.stderr
- + testsuite/tests/simplCore/should_fail/T25117b.hs
- + testsuite/tests/simplCore/should_fail/T25117b.stderr
- testsuite/tests/simplCore/should_fail/all.T
- + testsuite/tests/simplCore/should_run/T24359b.hs
- + testsuite/tests/simplCore/should_run/T24359b.stdout
- testsuite/tests/simplCore/should_run/all.T
- + testsuite/tests/th/T13123.stderr
- testsuite/tests/th/T19363.stdout
- testsuite/tests/th/T7064.stdout
- testsuite/tests/th/TH_pragma.hs
- testsuite/tests/th/TH_pragma.stderr
- + testsuite/tests/typecheck/should_compile/RuleEqs.hs
- + testsuite/tests/typecheck/should_compile/RuleEqs.stderr
- testsuite/tests/typecheck/should_compile/T10504.stderr
- testsuite/tests/typecheck/should_compile/T2494.stderr
- + testsuite/tests/typecheck/should_compile/T25744.hs
- + testsuite/tests/typecheck/should_compile/TcSpecPragmas.hs
- + testsuite/tests/typecheck/should_compile/TcSpecPragmas.stderr
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_compile/tc186.hs
- testsuite/tests/typecheck/should_compile/tc212.hs
- + testsuite/tests/typecheck/should_fail/SpecPragmasFail.hs
- + testsuite/tests/typecheck/should_fail/SpecPragmasFail.stderr
- testsuite/tests/typecheck/should_fail/T5853.stderr
- + testsuite/tests/warnings/should_compile/SpecMultipleTys.hs
- + testsuite/tests/warnings/should_compile/SpecMultipleTys.stderr
- testsuite/tests/warnings/should_compile/T19296.stderr
- testsuite/tests/warnings/should_compile/all.T
- + testsuite/tests/warnings/should_fail/SpecEMultipleTys.hs
- + testsuite/tests/warnings/should_fail/SpecEMultipleTys.stderr
- testsuite/tests/warnings/should_fail/all.T
- utils/check-exact/ExactPrint.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/359b4807be5ebd45211cb9d6d46c41ab453245af...38069f78f8ed366f5363222f2b49ac97ccc0ec9e
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/359b4807be5ebd45211cb9d6d46c41ab453245af...38069f78f8ed366f5363222f2b49ac97ccc0ec9e
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250218/d187a593/attachment-0001.html>
More information about the ghc-commits
mailing list