Simon Peyton Jones pushed to branch wip/T24464 at Glasgow Haskell Compiler / GHC Commits: 4b1048a3 by Simon Peyton Jones at 2026-02-03T22:38:40+00:00 Simplify the treatment of static forms This MR implements GHC proposal 732: simplify static forms, https://github.com/ghc-proposals/ghc-proposals/pull/732 thereby addressing #26556. See `Note [Grand plan for static forms]` in GHC.Iface.Tidy.StaticPtrTable The main changes are: * There is a new, simple rule for (static e), namely that the free term variables of `e` must be bound at top level. The check is done in the `HsStatic` case of `GHC.Rename.Expr.rnExpr` * That in turn substantially simplifies the info that the typechecker carries around in its type environment. Hooray. * The desugarer emits static bindings to top level directly; see the `HsStatic` case of `dsExpr`. * There is no longer any special static-related magic in the FloatOut pass. And the main Simplifier pipeline no longer needs a special case to run FloatOut even with -O0. Hooray. All this forced an unexpected change to the pattern match checker. It recursively invokes the main Hs desugarer when it wants to take a look at a term to spot some special cases (notably constructor applications). We don't want to emit any nested (static e) bindings to top level a second time! Yikes. That forced a modest refactor in GHC.HsToCore.Pmc: * The `dsl_nablas` field of `DsLclEnv` now has a `NoPmc` case, which says "I'm desugaring just for pattern-match checking purposes". * When that flag is set we don't emit static binds. That in turn forces a cascade of refactoring, but the net effect is an improvement; less risk of duplicated (even exponential?) work. 10% metric decrease, on some architectures, of compile-time max-bytes-used on T15304. Metric Decrease: T15304 - - - - - 59 changed files: - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/CoreToStg/AddImplicitBinds.hs - compiler/GHC/Driver/Config/Core/Lint.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/GuardedRHSs.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/HsToCore/Types.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/TyCl/Instance.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/Origin.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Monad.hs - − compiler/GHC/Tc/Utils/TcMType.hs-boot - compiler/GHC/Tc/Zonk/TcType.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_run/CgStaticPointers.hs - testsuite/tests/codeGen/should_run/CgStaticPointersNoFullLazyness.hs - testsuite/tests/ghci/scripts/T20150.stdout - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail01.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail03.stderr - testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b1048a305181d6b94b888975a36f01c... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b1048a305181d6b94b888975a36f01c... You're receiving this email because of your account on gitlab.haskell.org.