[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: tag inference: don't confuse functions with their return values
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 7fe4f2ec by Luite Stegeman at 2026-06-17T05:35:09-04:00 tag inference: don't confuse functions with their return values inferTagRhs was mixing up taggedness for closures and return values for function closures. We really shouldn't assign TagTuple to a properly tagged function returning a tuple. We fix this by keeping track of functions (TagFun) separately from values (TagVal) and keeping track of their return value. TagFun is also used for join points. fixes #27005 - - - - - 4671c126 by Sebastian Graf at 2026-06-17T05:35:55-04:00 Seed the simplifier's in-scope set for open expressions simplifyExpr simplifies expressions typed at the GHCi prompt and the results of Template Haskell splices. Such an expression may be open: at a GHCi debugger breakpoint its free variables include RuntimeUnk skolems standing for as-yet-unknown types. The simplifier began with an in-scope set holding only the wildcard binder, so when it instantiated the unsafeCoerce# wrapper that GHCi builds around a result, it formed a substitution whose range mentioned a free skolem that was not in scope. That breaks the substitution invariant and, in a compiler built with assertions, trips substTy's sanity check. Seed the initial in-scope set with the free variables of the expression. For a closed expression this adds nothing. See Note [Seed the in-scope set for open expressions]. Fixes #17833 and its duplicate #21118. - - - - - 0dedf9a8 by Alan Zimmerman at 2026-06-17T16:29:17-04:00 TTG: Add extension points to HsConDetails Extend HsConDetails as data HsConDetails p arg rec = PrefixCon !(XPrefixCon p) [arg] -- C @t1 @t2 p1 p2 p3 | RecCon !(XRecCon p) rec -- C { x = p1, y = p2 } | InfixCon !(XInfixCon p) arg arg -- p1 `C` p2 | XHsConDetails !(XXHsConDetails p) type family XPrefixCon p type family XRecCon p type family XInfixCon p type family XXHsConDetails p - - - - - 8d6a14f6 by Sebastian Graf at 2026-06-17T16:29:18-04:00 Desugar a `case` scrutinee only once (#27383, #20251) In `dsExpr` for `HsCase` we desugared the scrutinee /twice/: once to build the Core `case` itself, and again inside `matchWrapper`, which re-desugared the source scrutinee (via `addHsScrutTmCs`) purely to record long-distance information for the pattern-match checker. For a single `case` that is merely wasteful. But for nested cases it is catastrophic. Consider case (case (case e of ... ) of ... ) of ... Desugaring the outer scrutinee desugars the middle `case` twice, each of which desugars the inner `case` twice, and so on. The work doubles at every level, so desugaring takes O(2^n) time in the nesting depth. That is the blowup reported in #27383; it is also what makes the machine-generated program in #20251 take an age to compile. The fix is simple. `matchWrapper` is handed the scrutinee anyway, so we give it the Core expression we have /already/ desugared, and record the long-distance term constraint with `addCoreScrutTmCs` instead of re-desugaring from source. This is just what `matchSinglePatVar` already does for single-pattern matches. So: * `matchWrapper` now takes `Maybe [CoreExpr]` rather than `Maybe [LHsExpr GhcTc]`. * The `HsCase` equation of `dsExpr` passes the already-desugared `core_discrim`; the arrow desugarer passes its match variables. * `addHsScrutTmCs` had no other use, so it is gone. Desugaring is now linear in the nesting depth. (The coverage checker still runs `simpleOptExpr` over each scrutinee, which leaves the total at O(n^2); that is ample.) The long-distance information itself is unchanged: the checker sees precisely the Core that backs the generated code. Test: deSugar/should_compile/T27383 - - - - - 6865d2ae by Rodrigo Mesquita at 2026-06-17T16:29:19-04:00 fix: Save FastStrings in the PMC There is no point in adding the unique to the occurrence FastString we create, since it is part of the Id anyway. Adding it to the FastString, meant each FastString was unique unnecessarily! In a separate branch, running the compiler on test `InstanceMatching` observed 30000 `FastString`s created by this code path. Plus, `fsLit "pm"` follows the existing pattern in `mkPmId`. - - - - - 82 changed files: - + changelog.d/T17833 - + changelog.d/fix-exponential-case-desugar-27383 - + changelog.d/tag-inference-27005 - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Match.hs-boot - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/EnforceEpt.hs - compiler/GHC/Stg/EnforceEpt/Rewrite.hs - compiler/GHC/Stg/EnforceEpt/TagSig.hs - compiler/GHC/Stg/EnforceEpt/Types.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/ThToHs.hs - compiler/Language/Haskell/Syntax/Binds.hs - compiler/Language/Haskell/Syntax/Decls.hs - compiler/Language/Haskell/Syntax/Pat.hs - compiler/Language/Haskell/Syntax/Type.hs - testsuite/tests/core-to-stg/T14895.stderr - + testsuite/tests/deSugar/should_compile/T27383.hs - testsuite/tests/deSugar/should_compile/all.T - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/ghci.debugger/scripts/all.T - testsuite/tests/haddock/should_compile_flag_haddock/T24221.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/parser/should_compile/T20452.stderr - testsuite/tests/printer/Test24533.stdout - testsuite/tests/simplCore/should_compile/T4201.stdout - + testsuite/tests/simplCore/should_run/T27005.hs - + testsuite/tests/simplCore/should_run/T27005.stdout - + testsuite/tests/simplCore/should_run/T27005_aux.hs - testsuite/tests/simplCore/should_run/all.T - testsuite/tests/simplStg/should_compile/T24806.hs - testsuite/tests/simplStg/should_compile/T24806.stderr - + testsuite/tests/simplStg/should_compile/T27005b.hs - + testsuite/tests/simplStg/should_compile/T27005b.stderr - testsuite/tests/simplStg/should_compile/all.T - testsuite/tests/simplStg/should_compile/inferTags004.hs - testsuite/tests/simplStg/should_compile/inferTags004.stderr - + testsuite/tests/simplStg/should_run/T27005a.hs - + testsuite/tests/simplStg/should_run/T27005a.stdout - testsuite/tests/simplStg/should_run/all.T - utils/check-exact/ExactPrint.hs - utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs - utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs - utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs - utils/haddock/haddock-api/src/Haddock/Convert.hs - utils/haddock/haddock-api/src/Haddock/GhcUtils.hs - utils/haddock/haddock-api/src/Haddock/Interface/Create.hs - utils/haddock/haddock-api/src/Haddock/Interface/LexParseRn.hs - utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs - utils/haddock/haddock-api/src/Haddock/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c1fd991d80eb2a8b530a0980ac5a63... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c1fd991d80eb2a8b530a0980ac5a63... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)