Simon Peyton Jones pushed to branch wip/T27862 at Glasgow Haskell Compiler / GHC Commits: 38d421fb by Sylvain Henry at 2026-11-16T16:02:22-05:00 CoreMap: look up a non-recursive let with the key order of the store xtE stored a `Let (NonRec b r) e` with the body e as the first key and the right-hand side r as the second key. lkE used the opposite order. When a trie level holds one entry, GenMap compares the full keys with (==), and the difference has no effect. When a trie level holds two entries, a lookup of an expression with a non-recursive let fails. A later insert of an equal expression then overwrites the first entry. Now xtE stores the key in the order that lkE uses. Effects of the bug: CSE did not share identical bindings when a module had two different bindings that hold a non-recursive let or join point (#27892). The pattern-match checker gave different representatives to equal guard or view expressions, and thus reported spurious non-exhaustive matches. Fixes #27892. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> - - - - - fa5bc4c0 by Sylvain Henry at 2026-11-16T16:02:22-05:00 CoreMap: ignore the multiplicities of binders BndrMap keyed a binder on its type and on its multiplicity, and eqDeBruijnExpr compared the multiplicities of lambda binders. But the multiplicity of a let binder has no meaning (Note [Multiplicity of let binders] in GHC.Types.Var), and Core-to-core passes do not keep the multiplicities of lambda binders correct (Note [Linting linearity] in GHC.Core.Lint). Thus the trie separated terms that are equal. The key-order bug fixed in the previous commit hid this bug. With that fix, the pattern-match checker gave different representatives to two equal view expressions when one let came from the source and the other let came from the beta-reduction of a linear lambda. Now BndrMap is TypeMapG again, as before the linear types commit, and eqDeBruijnExpr ignores the multiplicities of lambda binders. The haddocks of CoreMap and eqCoreExpr state this contract. Fixes #28095. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - fa6b8c9e by Simon Peyton Jones at 2026-11-16T16:03:04-05:00 Swap visibilities in mkSymCo As #28123 showed, `mkSymCo` was failing to swap visibility flags in `ForAllCo`. Fixing that in turn showed that the change to `mkEtaForAllMCo` that allegedly fixed #27557 was utterly wrong, and should simply be un-done. I have added some comments to document the invariants. - - - - - a251280b by Simon Peyton Jones at 2026-11-17T00:06:58+00:00 Better desugaring for bang patterns Ticket #27862 showed that we were desugaring bang patterns in a silly way, which led to bad code. This small fix makes it much better. I ended up refactoring `decomposeFirstPat` to be of type (LPat -> LPat) instead of (Pat -> Pat) which made it much easier to keep the locations correct. On the way I also fixed #28137, a missing warning. See Note [Tidying patterns] which has new (TP1) and (TP2) and Note [Grouping equations] especially (GE1) - - - - - 39 changed files: - + changelog.d/27892 - + changelog.d/T27137 - + changelog.d/T27862 - + changelog.d/T28123 - compiler/GHC/Core/Map/Expr.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/TyCo/Make.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/HsToCore/Pmc.hs - testsuite/tests/ado/T22483.stderr - + testsuite/tests/deSugar/should_compile/T27862.hs - + testsuite/tests/deSugar/should_compile/T27862.stderr - + testsuite/tests/deSugar/should_compile/T27862a.hs - + testsuite/tests/deSugar/should_compile/T27862a.stderr - + testsuite/tests/deSugar/should_compile/T27862b.hs - + testsuite/tests/deSugar/should_compile/T27862b.stderr - + testsuite/tests/deSugar/should_compile/T27862c.hs - + testsuite/tests/deSugar/should_compile/T27862c.stderr - + testsuite/tests/deSugar/should_compile/T27862d.hs - + testsuite/tests/deSugar/should_compile/T27862d.stderr - + testsuite/tests/deSugar/should_compile/T28137.hs - + testsuite/tests/deSugar/should_compile/T28137.stderr - testsuite/tests/deSugar/should_compile/all.T - testsuite/tests/deSugar/should_run/dsrun008.stderr - testsuite/tests/pmcheck/should_compile/T24234.stderr - + testsuite/tests/pmcheck/should_compile/T27892a.hs - + testsuite/tests/pmcheck/should_compile/T28095.hs - testsuite/tests/pmcheck/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T27892.hs - + testsuite/tests/simplCore/should_compile/T27892.stderr - + testsuite/tests/simplCore/should_compile/T28095a.hs - + testsuite/tests/simplCore/should_compile/T28095a.stderr - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/typecheck/should_fail/tcfail203a.stderr - + testsuite/tests/vdq-rta/should_compile/T28123.hs - testsuite/tests/vdq-rta/should_compile/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b158922b0ca34529a1e6d120f49e513... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b158922b0ca34529a1e6d120f49e513... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Simon Peyton Jones (@simonpj)