Simon Peyton Jones pushed to branch wip/T26746 at Glasgow Haskell Compiler / GHC
Commits:
96c19504 by Simon Peyton Jones at 2026-01-12T23:49:44+00:00
wibbles
- - - - -
3 changed files:
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Solver/Equality.hs
Changes:
=====================================
compiler/GHC/Core/FamInstEnv.hs
=====================================
@@ -1061,10 +1061,10 @@ lookup_fam_inst_env' lookup_mode (FamIE _ ie) fam match_tys
, fi_tys = tpl_tys }) = do
subst <- tcMatchTys tpl_tys match_tys1
return (FamInstMatch { fim_instance = item
- , fim_tys = substTyVars subst tpl_tvs `chkAppend` match_tys2
- , fim_cos = assert (all (isJust . lookupCoVar subst) tpl_cvs) $
- substCoVars subst tpl_cvs
- })
+ , fim_tys = substTyVars subst tpl_tvs `chkAppend` match_tys2
+ , fim_cos = assert (all (isJust . lookupCoVar subst) tpl_cvs) $
+ substCoVars subst tpl_cvs
+ })
where
(match_tys1, match_tys2) = split_tys tpl_tys
=====================================
compiler/GHC/Tc/Instance/Family.hs
=====================================
@@ -451,25 +451,27 @@ tcLookupDataFamInst_maybe fam_inst_envs tc tc_args
| otherwise
= Nothing
--- | 'tcUnwrapNewtype_mabye' gets rid of top-level newtypes,
--- potentially also looking through newtype /instances/
+-- | 'tcUnwrapNewtype_mabye' gets rid of /one layer/ of top-level newtypes
--
-- It is only used by the type inference engine (specifically, when
-- solving representational equality), and hence it is careful to unwrap
-- only if the relevant data constructor is in scope. That's why
-- it gets a GlobalRdrEnv argument.
--
--- It is careful not to unwrap data/newtype instances if it can't
--- unwrap the newtype inside it. Such care is necessary for proper
--- error messages.
+-- It is capable of unwrapping a newtype /instance/. E.g
+-- data D a
+-- newtype instance D Int = MkD Bool
+-- Then `tcUnwrapNewtype_maybe (D Int)` will unwrap to give the `Bool` inside.
+-- However, it is careful not to unwrap data/newtype instances if it can't
+-- unwrap the newtype inside it; that might in the example if `MkD` was
+-- not in scope. Such care is necessary for proper error messages.
--
-- It does not look through type families.
--- It does not normalise arguments to a tycon.
+-- It does not normalise arguments to the tycon.
--
--- If the result is Just ((gres, co), rep_ty), then
+-- If the result is Just (gre, co, rep_ty), then
-- co : ty ~R rep_ty
--- gres are the GREs for the data constructors that
--- had to be in scope
+-- gre is the GRE for the data constructor that had to be in scope
tcUnwrapNewtype_maybe :: FamInstEnvs
-> GlobalRdrEnv
-> Type
=====================================
compiler/GHC/Tc/Solver/Equality.hs
=====================================
@@ -333,14 +333,6 @@ can_eq_nc rewritten rdr_env envs ev eq_rel ty1 ps_ty1 ty2 ps_ty2
| Just ty1' <- coreView ty1 = can_eq_nc rewritten rdr_env envs ev eq_rel ty1' ps_ty1 ty2 ps_ty2
| Just ty2' <- coreView ty2 = can_eq_nc rewritten rdr_env envs ev eq_rel ty1 ps_ty1 ty2' ps_ty2
--- When working with ReprEq, unwrap newtypes.
--- See Note [Eager reflexivity check]
--- See Note [Unwrap newtypes first]
--- This must be above the TyVarTy case, in order to guarantee (TyEq:N)
---
--- We unwrap *one layer only*; `can_eq_newtype_nc` then loops back to
--- `can_eq_nc`. If there is a recursive newtype, so that we keep
--- unwrapping, the depth limit in `can_eq_newtype_nc` will blow up.
can_eq_nc _rewritten _rdr_env _envs ev eq_rel ty1 _ ty2 _
| ReprEq <- eq_rel
, TyConApp tc1 tys1 <- ty1
@@ -366,6 +358,14 @@ can_eq_nc _rewritten _rdr_env _envs ev eq_rel ty1 _ ty2 _
ok _ _ [] = False -- Oversaturated TyCon
ok _ _ _ = pprPanic "can_eq_nc:mismatch" (ppr ty1 $$ ppr ty2)
+-- Unwrap newtypes, when in ReprEq only
+-- See Note [Eager reflexivity check]
+-- See Note [Unwrap newtypes first]
+-- This must be above the TyVarTy case, in order to guarantee (TyEq:N)
+--
+-- We unwrap *one layer only*; `can_eq_newtype_nc` then loops back to
+-- `can_eq_nc`. If there is a recursive newtype, so that we keep
+-- unwrapping, the depth limit in `can_eq_newtype_nc` will blow up.
can_eq_nc _rewritten rdr_env envs ev eq_rel ty1 ps_ty1 ty2 ps_ty2
| ReprEq <- eq_rel
, Just stuff1 <- tcUnwrapNewtype_maybe envs rdr_env ty1
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96c19504a9da2088d19701a5f12e49b…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96c19504a9da2088d19701a5f12e49b…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T26615] 5 commits: hurd: Fix getExecutablePath build
by Simon Peyton Jones (@simonpj) 13 Jan '26
by Simon Peyton Jones (@simonpj) 13 Jan '26
13 Jan '26
Simon Peyton Jones pushed to branch wip/T26615 at Glasgow Haskell Compiler / GHC
Commits:
f3c18890 by Samuel Thibault at 2026-01-10T15:48:22+01:00
hurd: Fix getExecutablePath build
3939a8bf93e27 ("GNU/Hurd: Add getExecutablePath support") added using
/proc/self/exe for GNU/Hurd but missed adding the required imports for
the corresponding code.
- - - - -
7f15bd15 by Samuel Thibault at 2026-01-12T07:16:25-05:00
Fix the OS string encoding for GNU/Hurd
Following https://github.com/haskell/cabal/pull/9434/files , and as seen
in the various gnu_HOST_OS usages in the source code, it is expected that
GNU/Hurd is advertised as "gnu", like the autotools do.
- - - - -
1db2f240 by Andrew Lelechenko at 2026-01-12T07:17:06-05:00
Add since annotation for Data.Bifoldable1
Fixes #26432
- - - - -
e038a383 by Sven Tennie at 2026-01-12T07:17:49-05:00
Ignore Windows CI tool directories in Git
Otherwise, we see thousands of changes in `git status` which is very
confusing to work with.
- - - - -
259c8371 by Simon Peyton Jones at 2026-01-12T23:03:53+00:00
Make SpecContr rules fire a bit later
See #26615 and Note [SpecConstr rule activation]
- - - - -
22 changed files:
- .gitignore
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Unfold/Make.hs
- libraries/base/src/Data/Bifoldable1.hs
- libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
- libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
- testsuite/tests/simplCore/should_compile/T14003.stderr
- testsuite/tests/simplCore/should_compile/T19672.stderr
- testsuite/tests/simplCore/should_compile/T21763.stderr
- testsuite/tests/simplCore/should_compile/T21763a.stderr
- + testsuite/tests/simplCore/should_compile/T26615.hs
- + testsuite/tests/simplCore/should_compile/T26615.stderr
- + testsuite/tests/simplCore/should_compile/T26615a.hs
- testsuite/tests/simplCore/should_compile/T4908.stderr
- testsuite/tests/simplCore/should_compile/all.T
- testsuite/tests/simplCore/should_compile/spec-inline.stderr
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22b7540f08f5fef054217c204ec7a7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22b7540f08f5fef054217c204ec7a7…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
13 Jan '26
Bodigrim pushed new branch wip/since-for-rts-maxn at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/since-for-rts-maxn
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
6b8198f1 by Apoorv Ingle at 2026-01-12T15:07:33-06:00
rebase changes
- - - - -
2 changed files:
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Utils/Unify.hs
Changes:
=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -75,9 +75,6 @@ import GHC.Utils.Panic
import GHC.Data.Maybe
-import qualified GHC.LanguageExtensions as LangExt
-
-
{- *********************************************************************
* *
HsExprArg: auxiliary data type
@@ -480,43 +477,6 @@ with_get_ds mthing =
; return (expr_tc, ds_flag, sig_ty)
}
-
-
--- | Variant of 'getDeepSubsumptionFlag' which enables a top-level subsumption
--- in order to implement the plan of Note [Typechecking data constructors].
-getDeepSubsumptionFlag_DataConHead :: HsExpr GhcTc -> TcM DeepSubsumptionFlag
-getDeepSubsumptionFlag_DataConHead app_head =
- do { user_ds <- xoptM LangExt.DeepSubsumption
- ; traceTc "getDeepSubsumptionFlag_DataConHead" (ppr app_head)
- ; return $
- if | user_ds
- -> Deep DeepSub
- | otherwise
- -> go app_head
- }
- where
- go :: HsExpr GhcTc -> DeepSubsumptionFlag
- go app_head
- | XExpr (ConLikeTc (RealDataCon {})) <- app_head
- = Deep TopSub
- | XExpr (ExpandedThingTc _ f) <- app_head
- = go f
- | XExpr (WrapExpr _ f) <- app_head
- = go f
- | HsVar _ f <- app_head
- , isDataConId (unLoc f)
- = Deep TopSub
- | HsApp _ f _ <- app_head
- = go (unLoc f)
- | HsAppType _ f _ <- app_head
- = go (unLoc f)
- | OpApp _ _ f _ <- app_head
- = go (unLoc f)
- | HsPar _ f <- app_head
- = go (unLoc f)
- | otherwise
- = Shallow
-
{- *********************************************************************
* *
Record selectors
=====================================
compiler/GHC/Tc/Utils/Unify.hs
=====================================
@@ -93,12 +93,13 @@ import qualified GHC.LanguageExtensions as LangExt
import GHC.Builtin.Types
import GHC.Types.Name
-import GHC.Types.Id( idType )
+import GHC.Types.Id( idType, isDataConId )
import GHC.Types.Var as Var
import GHC.Types.Var.Set
import GHC.Types.Var.Env
import GHC.Types.Basic
import GHC.Types.Unique.Set (nonDetEltsUniqSet)
+import GHC.Types.SrcLoc (unLoc)
import GHC.Utils.Misc
import GHC.Utils.Outputable as Outputable
@@ -2031,14 +2032,36 @@ getDeepSubsumptionFlag =
getDeepSubsumptionFlag_DataConHead :: HsExpr GhcTc -> TcM DeepSubsumptionFlag
getDeepSubsumptionFlag_DataConHead app_head =
do { user_ds <- xoptM LangExt.DeepSubsumption
+ ; traceTc "getDeepSubsumptionFlag_DataConHead" (ppr app_head)
; return $
if | user_ds
-> Deep DeepSub
- | XExpr (ConLikeTc (RealDataCon {})) <- app_head
- -> Deep TopSub
| otherwise
- -> Shallow
- }
+ -> go app_head
+ }
+ where
+ go :: HsExpr GhcTc -> DeepSubsumptionFlag
+ go app_head
+ | XExpr (ConLikeTc (RealDataCon {})) <- app_head
+ = Deep TopSub
+ | XExpr (ExpandedThingTc _ f) <- app_head
+ = go f
+ | XExpr (WrapExpr _ f) <- app_head
+ = go f
+ | HsVar _ f <- app_head
+ , isDataConId (unLoc f)
+ = Deep TopSub
+ | HsApp _ f _ <- app_head
+ = go (unLoc f)
+ | HsAppType _ f _ <- app_head
+ = go (unLoc f)
+ | OpApp _ _ f _ <- app_head
+ = go (unLoc f)
+ | HsPar _ f <- app_head
+ = go (unLoc f)
+ | otherwise
+ = Shallow
+
-- | 'tc_sub_type_deep' is where the actual work happens for deep subsumption.
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6b8198f1d3f0d7fd7d599c449ede1d7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6b8198f1d3f0d7fd7d599c449ede1d7…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-apporv-Oct24] 84 commits: Remove unused known keys and names for type representations
by Apoorv Ingle (@ani) 13 Jan '26
by Apoorv Ingle (@ani) 13 Jan '26
13 Jan '26
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
bc36268a by Wolfgang Jeltsch at 2025-12-21T16:23:24-05:00
Remove unused known keys and names for type representations
This removes the known-key and corresponding name variables for
`TrName`, `TrNameD`, `TypeRep`, `KindRepTypeLitD`, `TypeLitSort`, and
`mkTrType`, as they are apparently nowhere used in GHC’s source code.
- - - - -
ff5050e9 by Wolfgang Jeltsch at 2025-12-21T16:24:04-05:00
Remove unused known keys and names for natural operations
This removes the known-key and corresponding name variables for
`naturalAndNot`, `naturalLog2`, `naturalLogBaseWord`, `naturalLogBase`,
`naturalPowMod`, `naturalSizeInBase`, `naturalToFloat`, and
`naturalToDouble`, as they are apparently nowhere used in GHC’s source
code.
- - - - -
424388c2 by Wolfgang Jeltsch at 2025-12-21T16:24:45-05:00
Remove the unused known key and name for `Fingerprint`
This removes the variables for the known key and the name of the
`Fingerprint` data constructor, as they are apparently nowhere used in
GHC’s source code.
- - - - -
a1ed86fe by Wolfgang Jeltsch at 2025-12-21T16:25:26-05:00
Remove the unused known key and name for `failIO`
This removes the variables for the known key and the name of the
`failIO` operation, as they are apparently nowhere used in GHC’s source
code.
- - - - -
b8220daf by Wolfgang Jeltsch at 2025-12-21T16:26:07-05:00
Remove the unused known key and name for `liftM`
This removes the variables for the known key and the name of the `liftM`
operation, as they are apparently nowhere used in GHC’s source code.
- - - - -
eb0628b1 by Wolfgang Jeltsch at 2025-12-21T16:26:47-05:00
Fix the documentation of `hIsClosed`
- - - - -
db1ce858 by sheaf at 2025-12-22T17:11:17-05:00
Do deep subsumption when computing valid hole fits
This commit makes a couple of improvements to the code that
computes "valid hole fits":
1. It uses deep subsumption for data constructors.
This matches up the multiplicities, as per
Note [Typechecking data constructors].
This fixes #26338 (test: LinearHoleFits).
2. It now suggests (non-unidirectional) pattern synonyms as valid
hole fits. This fixes #26339 (test: PatSynHoleFit).
3. It uses 'stableNameCmp', to make the hole fit output deterministic.
-------------------------
Metric Increase:
hard_hole_fits
-------------------------
- - - - -
72ee9100 by sheaf at 2025-12-22T17:11:17-05:00
Speed up hole fits with a quick pre-test
This speeds up the machinery for valid hole fits by doing a small
check to rule out obviously wrong hole fits, such as:
1. A hole fit identifier whose type has a different TyCon at the head,
after looking through foralls and (=>) arrows, e.g.:
hole_ty = Int
cand_ty = Maybe a
or
hole_ty = forall a b. a -> b
cand_ty = forall x y. Either x y
2. A hole fit identifier that is not polymorphic when the hole type
is polymorphic, e.g.
hole_ty = forall a. a -> a
cand_ty = Int -> Int
-------------------------
Metric Decrease:
hard_hole_fits
-------------------------
- - - - -
30e513ba by Cheng Shao at 2025-12-22T17:12:00-05:00
configure: remove unused win32-tarballs.md5sum
This patch removes the unused `win32-tarballs.md5sum` file from the
tree. The current mingw tarball download logic in
`mk/get-win32-tarballs.py` fetches and checks against `SHA256SUM` from
the same location where the tarballs are fetched, and this file has
been unused for a few years.
- - - - -
a2d52b3b by Wolfgang Jeltsch at 2025-12-23T04:47:33-05:00
Add an operation `System.IO.hGetNewlineMode`
This commit also contains some small code and documentation changes for
related operations, for the sake of consistency.
- - - - -
b26d134a by Cheng Shao at 2025-12-23T04:48:15-05:00
rts: opportunistically reclaim slop space in shrinkMutableByteArray#
Previously, `shrinkMutableByteArray#` shrinks a `MutableByteArray#`
in-place by assigning the new size to it, and zeroing the extra slop
space. That slop space is not reclaimed and wasted. But it's often the
case that we allocate a `MutableByteArray#` upfront, then shrink it
shortly after, so the `MutableByteArray#` closure sits right at the
end of a nursery block; this patch identifies such chances, and also
shrink `bd->free` if possible, reducing heap space fragmentation.
Co-authored-by: Codex <codex(a)openai.com>
-------------------------
Metric Decrease:
T10678
-------------------------
- - - - -
c72ddabf by Cheng Shao at 2025-12-23T16:13:23-05:00
hadrian: fix bootstrapping with ghc-9.14
This patch fixes bootstrapping GHC with ghc-9.14, tested locally with
ghc-9.14.1 release as bootstrapping GHC.
- - - - -
0fd6d8e4 by Cheng Shao at 2025-12-23T16:14:05-05:00
hadrian: pass -keep-tmp-files to test ghc when --keep-test-files is enabled
This patch makes hadrian pass `-keep-tmp-files` to test ghc when
`--keep-test-files` is enabled, so you can check the ghc intermediate
files when debugging certain test failures. Closes #26688.
- - - - -
81d10134 by Cheng Shao at 2025-12-24T06:11:52-05:00
configure: remove dead code in configure scripts
This patch removes dead code in our configure scripts, including:
- Variables and auto-detected programs that are not used
- autoconf functions that are not used, or export a variable that's
not used
- `AC_CHECK_HEADERS` invocations that don't have actual corresponding
`HAVE_XXX_H` usage
- Other dead code (e.g. stray `AC_DEFUN()`)
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
fb1381c3 by Wolfgang Jeltsch at 2025-12-24T06:12:34-05:00
Remove unused known keys and names for list operations
This removes the known-key and corresponding name variables for
`concat`, `filter`, `zip`, and `(++)`, as they are apparently nowhere
used in GHC’s source code.
- - - - -
7b9c20f4 by Recursion Ninja at 2025-12-24T10:35:36-05:00
Decoupling Language.Haskell.Syntax.Binds from GHC.Types.Basic
by transferring InlinePragma types between the modules.
* Moved InlinePragma data-types to Language.Haskell.Syntax.Binds.InlinePragma
* Partitioned of Arity type synonyms to GHC.Types.Arity
* InlinePragma is now extensible via Trees That Grow
* Activation is now extensible via Trees That Grow
* Maybe Arity change to more descriptive InlineSaturation data-type
* InlineSaturation information removed from InlinePragma during GHS parsing pass
* Cleaned up the exposed module interfaces of the new modules
- - - - -
a3afae0c by Simon Peyton Jones at 2025-12-25T15:26:36-05:00
Check for rubbish literals in Lint
Addresses #26607.
See new Note [Checking for rubbish literals] in GHC.Core.Lint
- - - - -
8a317b6f by Aaron Allen at 2026-01-01T03:05:15-05:00
[#26183] Associated Type Iface Fix
When determining "extras" for class decl interface entries, axioms for
the associated types need to included so that dependent modules will be
recompiled if those axioms change.
resolves #26183
- - - - -
ae1aeaab by Cheng Shao at 2026-01-01T03:06:32-05:00
testsuite: run numeric tests with optasm when available
This patch adds the `optasm` extra way to nueric tests when NCG is
available. Some numeric bugs only surface with optimization, omitting
this can hide these bugs and even make them slip into release! (e.g. #26711)
- - - - -
6213bb57 by maralorn at 2026-01-02T16:30:32+01:00
GHC.Internal.Exception.Context: Fix comment
on addExceptionAnnotation
- - - - -
b820ff50 by Janis Voigtlaender at 2026-01-05T02:43:18-05:00
GHC.Internal.Control.Monad.replicateM: Fix comment
- - - - -
a8a94aad by Cheng Shao at 2026-01-05T16:24:04-05:00
hadrian: drops unused PE linker script for windows
This patch drops unused PE linker script for windows in the
`MergeObjects` builder of hadrian. The linker script is used for
merging object files into a single `HS*.o` object file and undoing the
effect of split sections, when building the "ghci library" object
file. However, we don't build the ghci library on windows, and this
code path is actually unreachable.
- - - - -
53038ea9 by Cheng Shao at 2026-01-05T16:24:04-05:00
hadrian: drop unused logic for building ghci libraries
This patch drops the unused logic for building ghci libraries in
hadrian:
- The term "ghci library" refers to an optional object file per
library `HS*.o`, which is merged from multiple object files in that
library using the `MergeObjects` builder in hadrian.
- The original rationale of having a ghci library object, in addition
to normal archives, was to speedup ghci loading, since the combined
object is linked with a linker script to undo the effects of
`-fsplit-sections` to reduce section count and make it easier for
the RTS linker to handle.
- However, most GHC builds enable `dynamicGhcPrograms` by default, in
such cases the ghci library would already not be built.
- `dynamicGhcPrograms` is disabled on Windows, but still we don't
build the ghci library due to lack of functioning merge objects
command.
- The only case that we actually build ghci library objects, are
alpine fully static bindists. However, for other reasons, split
sections is already disabled for fully static builds anyway!
- There will not be any regression if the ghci library objects are
absent from a GHC global libdir when `dynamicGhcPrograms` is
disabled. The RTS linker can already load the archives without any
issue.
Hence the removal. We now forcibly disable ghci libraries for all
Cabal components, and rip out all logic related to `MergeObjects` and
ghci libraries in hadrian. This also nicely cleans up some old todos
and fixmes that are no longer relevant.
Note that MergeObjects in hadrian is not the same thing as merge
objects in the GHC driver. The latter is not affected by this patch.
-------------------------
Metric Decrease:
libdir
-------------------------
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
8f209336 by Simon Jakobi at 2026-01-05T16:24:48-05:00
User's guide: Fix link to language extensions
Instead of linking to haddocks, it seemed more useful to link
to the extension overview in the user's guide.
Closes #26614.
- - - - -
0b7df6db by Simon Peyton Jones at 2026-01-06T09:32:23-05:00
Improved fundeps for closed type families
The big payload of this commit is to execute the plan suggested
in #23162, by improving the way that we generate functional
dependencies for closed type families.
It is all described in Note [Exploiting closed type families]
Most of the changes are in GHC.Tc.Solver.FunDeps
Other small changes
* GHC.Tc.Solver.bumpReductionDepth. This function brings together the code that
* Bumps the depth
* Checks for overflow
Previously the two were separated, sometimes quite widely.
* GHC.Core.Unify.niFixSubst: minor improvement, removing an unnecessary
itraetion in the base case.
* GHC.Core.Unify: no need to pass an InScopeSet to
tcUnifyTysForInjectivity. It can calculate one for itself; and it is
never inspected anyway so it's free to do so.
* GHC.Tc.Errors.Ppr: slight impovement to the error message for
reduction-stack overflow, when a constraint (rather than a type) is
involved.
* GHC.Tc.Solver.Monad.wrapUnifier: small change to the API
- - - - -
fde8bd88 by Simon Peyton Jones at 2026-01-06T09:32:23-05:00
Add missing (KK4) to kick-out criteria
There was a missing case in kick-out that meant we could fail
to solve an eminently-solvable constraint.
See the new notes about (KK4)
- - - - -
00082844 by Simon Peyton Jones at 2026-01-06T09:32:23-05:00
Some small refactorings of error reporting in the typechecker
This is just a tidy-up commit.
* Add ei_insoluble to ErrorItem, to cache insolubility.
Small tidy-up.
* Remove `is_ip` and `mkIPErr` from GHC.Tc.Errors; instead enhance mkDictErr
to handle implicit parameters. Small refactor.
- - - - -
fe4cb252 by Simon Peyton Jones at 2026-01-06T09:32:24-05:00
Improve recording of insolubility for fundeps
This commit addresses #22652, by recording when the fundeps for
a constraint are definitely insoluble. That in turn improves the
perspicacity of the pattern-match overlap checker.
See Note [Insoluble fundeps]
- - - - -
df0ffaa5 by Simon Peyton Jones at 2026-01-06T09:32:24-05:00
Fix a buglet in niFixSubst
The MR of which this is part failed an assertion check extendTvSubst
because we extended the TvSubst with a CoVar. Boo.
This tiny patch fixes it, and adds the regression test from #13882
that showed it up.
- - - - -
3d6aba77 by konsumlamm at 2026-01-06T09:33:16-05:00
Fix changelog formatting
- - - - -
69e0ab59 by Cheng Shao at 2026-01-06T19:37:56-05:00
compiler: add targetHasRTSWays function
This commit adds a `targetHasRTSWays` util function in
`GHC.Driver.Session` to query if the target RTS has a given Ways (e.g.
WayThreaded).
- - - - -
25a0ab94 by Cheng Shao at 2026-01-06T19:37:56-05:00
compiler: link on-demand external interpreter with threaded RTS
This commit makes the compiler link the on-demand external interpreter
program with threaded RTS if it is available in the target RTS ways.
This is a better default than the previous single-threaded RTS, and it
enables the external interpreter to benefit from parallelism when
deserializing CreateBCOs messages.
- - - - -
92404a2b by Cheng Shao at 2026-01-06T19:37:56-05:00
hadrian: link iserv with threaded RTS
This commit makes hadrian link iserv with threaded RTS if it's
available in the RTS ways. Also cleans up the iserv main C program
which can be replaced by the `-fkeep-cafs` link-time option.
- - - - -
a20542d2 by Cheng Shao at 2026-01-06T19:38:38-05:00
ghc-internal: remove unused GMP macros
This patch removes unused GMP related macros from `ghc-internal`. The
in-tree GMP version was hard coded and outdated, but it was not used
anywhere anyway.
- - - - -
4079dcd6 by Cheng Shao at 2026-01-06T19:38:38-05:00
hadrian: fix in-tree gmp configure error on newer c compilers
Building in-tree gmp on newer c compilers that default to c23 fails at
configure stage, this patch fixes it, see added comment for
explanation.
- - - - -
414d1fe1 by Cheng Shao at 2026-01-06T19:39:20-05:00
compiler: fix LLVM backend pdep/pext handling for i386 target
This patch fixes LLVM backend's pdep/pext handling for i386 target,
and also removes non-existent 128/256/512 bit hs_pdep/hs_pext callees.
See amended note for more explanation. Fixes #26450.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
c7f6fba3 by Cheng Shao at 2026-01-06T19:39:20-05:00
ci: remove allow_failure flag for i386 alpine job
The LLVM codegen issue for i386 has been fixed, and the i386 alpine
job should pass now. This commit removes the allow_failure flag so
that other i386 regressions in the future are signaled more timely.
- - - - -
52d00c05 by Simon Peyton Jones at 2026-01-07T10:24:21-05:00
Add missing InVar->OutVar lookup in SetLevels
As #26681 showed, the SetLevels pass was failing to map an InVar to
an OutVar. Very silly! I'm amazed it hasn't broken before now.
I have improved the type singatures (to mention InVar and OutVar)
so it's more obvious what needs to happen.
- - - - -
ab0a5594 by Cheng Shao at 2026-01-07T10:25:04-05:00
hadrian: drop deprecated pkgHashSplitObjs code path
This patch drops deprecated `pkgHashSplitObjs` code path from hadrian,
since GHC itself has removed split objs support many versions ago and
this code path is unused.
- - - - -
bb3a2ba1 by Cheng Shao at 2026-01-07T10:25:44-05:00
hadrian: remove linting/assertion in quick-validate flavour
The `quick-validate` flavour is meant for testing ghc and passing the
testsuite locally with similar settings to `validate` but faster. This
patch removes the linting/assertion overhead in `quick-validate` to
improve developer experience. I also took the chance to simplify
redundant logic of rts/library way definition in `validate` flavour.
- - - - -
7971f5dd by Cheng Shao at 2026-01-07T10:26:26-05:00
deriveConstants: clean up unused constants
This patch cleans up unused constants from `deriveConstants`, they are
not used by C/Cmm code in the RTS, nor compiler-generated code.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
4df96993 by Cheng Shao at 2026-01-07T10:27:08-05:00
hadrian: pass -fno-omit-frame-pointer with +debug_info
This patch adds `-fno-omit-frame-pointer` as C/C++ compilation flag
when compiling with `+debug_info` flavour transformer. It's a sane
default when you care about debugging and reliable backtraces, and
makes debugging/profiling with bpf easier.
- - - - -
8a3900a3 by Aaron Allen at 2026-01-07T10:27:57-05:00
[26705] Include TyCl instances in data fam iface entry
Ensures dependent modules are recompiled when the class instances for a
data family instance change.
resolves #26705
- - - - -
a0b980af by Cheng Shao at 2026-01-07T10:28:38-05:00
hadrian: remove unused Hp2Ps/Hpc builders
This patch removes the Hp2Ps/Hpc builders from hadrian, they are
unused in the build system. Note that the hp2ps/hpc programs are still
built and not affected.
- - - - -
50a58757 by Cheng Shao at 2026-01-07T10:29:20-05:00
hadrian: only install js files to libdir for wasm/js targets
There are certain js files required for wasm/js targets to work, and
previously hadrian would install those js files to libdir
unconditionally on other targets as well. This could be a minor
annoyance for packagers especially when the unused js files contain
shebangs that interfere with the packaging process. This patch makes
hadrian only selectively install the right js files for the right
targets.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
da40e553 by Simon Peyton Jones at 2026-01-07T10:30:00-05:00
Add flavour transformer assertions_stage1
This allows us to enable -DDEBUG assertions in the stage1 compiler
- - - - -
ec3cf767 by Cheng Shao at 2026-01-08T06:24:31-05:00
make: remove unused Makefiles from legacy make build system
This patch removes unused Makefiles from legacy make build system; now
they are never used by hadrian in any way, and they already include
common boilerplate mk files that are long gone in the make build
system removal, hence the housecleaning.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
04ea3f83 by Cheng Shao at 2026-01-08T06:25:13-05:00
compiler: use -O3 as LLVM optimization level for ghc -O2
The GHC driver clamps LLVM optimization level to `-O2` due to LLVM
crashes, but those were historical issues many years ago that are no
longer relevant for LLVM versions we support today. This patch changes
the driver to use `-O3` as LLVM optimization level when compiling with
`-O2`, which is a better default when we're willing to trade
compilation time for faster generated code.
- - - - -
472df471 by Peter Trommler at 2026-01-08T13:28:54-05:00
Use half-word literals in info tables
With this commit info tables are mapped to the same assembler code
on big-endian and little-endian platforms.
Fixes #26579.
- - - - -
393f9c51 by Simon Peyton Jones at 2026-01-08T13:29:35-05:00
Refactor srutOkForBinderSwap
This MR does a small refactor:
* Moves `scrutOkForBinderSwap` and `BinderSwapDecision`
to GHC.Core.Utils
* Inverts the sense of the coercion it returns, which makes
more sense
No effect on behaviour
- - - - -
ad76fb0f by Simon Peyton Jones at 2026-01-08T13:29:36-05:00
Improve case merging
This small MR makes case merging happen a bit more often than
it otherwise could, by getting join points out of the way.
See #26709 and GHC.Core.Utils
Note [Floating join points out of DEFAULT alternatives]
- - - - -
4c9395f5 by Cheng Shao at 2026-01-08T13:30:16-05:00
hadrian: remove broken hsc2hs flag when cross compiling to windows
This patch removes the `--via-asm` hsc2hs flag when cross compiling to
windows. With recent llvm-mingw toolchain, it would fail with:
```
x86_64-w64-mingw32-hsc2hs: Cannot combine instructions: [Quad 8,Long 4,Long 241,Ref ".Ltmp1-.Ltmp0"]
```
The hsc2hs default `--cross-compile` logic is slower but works.
- - - - -
71fdef55 by Simon Peyton Jones at 2026-01-08T13:30:57-05:00
Try harder to keep the substitution empty
Avoid unnecessary cloning of variables in the Simplifier.
Addresses #26724,
See Note [Keeping the substitution empty]
We get some big wins in compile time
Metrics: compile_time/bytes allocated
-------------------------------------
Baseline
Test Metric value New value Change
----------------------------------------------------------------------------
CoOpt_Singletons(normal) ghc/alloc 721,544,088 692,174,216 -4.1% GOOD
LargeRecord(normal) ghc/alloc 1,268,031,157 1,265,168,448 -0.2%
T14766(normal) ghc/alloc 918,218,533 688,432,296 -25.0% GOOD
T15703(normal) ghc/alloc 318,103,629 306,638,016 -3.6% GOOD
T17836(normal) ghc/alloc 419,174,584 418,400,824 -0.2%
T18478(normal) ghc/alloc 471,042,976 470,261,376 -0.2%
T20261(normal) ghc/alloc 573,387,162 563,663,336 -1.7%
T24984(normal) ghc/alloc 87,832,666 87,636,168 -0.2%
T25196(optasm) ghc/alloc 1,103,284,040 1,101,376,992 -0.2%
hard_hole_fits(normal) ghc/alloc 224,981,413 224,608,208 -0.2%
geo. mean -0.3%
minimum -25.0%
maximum +0.1%
Metric Decrease:
CoOpt_Singletons
T14766
T15703
- - - - -
30341168 by Simon Peyton Jones at 2026-01-08T13:31:38-05:00
Add regression test for #24867
- - - - -
1ac1a541 by Julian Ospald at 2026-01-09T02:48:53-05:00
Support statically linking executables properly
Fixes #26434
In detail, this does a number of things:
* Makes GHC aware of 'extra-libraries-static' (this changes the package
database format).
* Adds a switch '-static-external' that will honour 'extra-libraries-static'
to link external system dependencies statically.
* Adds a new field to settings/targets: "ld supports verbatim namespace".
This field is used by '-static-external' to conditionally use '-l:foo.a'
syntax during linking, which is more robust than trying to find the
absolute path to an archive on our own.
* Adds a switch '-fully-static' that is meant as a high-level interface
for e.g. cabal. This also honours 'extra-libraries-static'.
This also attempts to clean up the confusion around library search directories.
At the moment, we have 3 types of directories in the package database
format:
* library-dirs
* library-dirs-static
* dynamic-library-dirs
However, we only have two types of linking: dynamic or static. Given the
existing logic in 'mungeDynLibFields', this patch assumes that
'library-dirs' is really just nothing but a fallback and always
prefers the more specific variants if they exist and are non-empty.
Conceptually, we should be ok with even just one search dirs variant.
Haskell libraries are named differently depending on whether they're
static or dynamic, so GHC can conveniently pick the right one depending
on the linking needs. That means we don't really need to play tricks
with search paths to convince the compiler to do linking as we want it.
For system C libraries, the convention has been anyway to place static and
dynamic libs next to each other, so we need to deal with that issue
anyway and it is outside of our control. But this is out of the scope
of this patch.
This patch is backwards compatible with cabal. Cabal should however
be patched to use the new '-fully-static' switch.
- - - - -
ad3c808d by Julian Ospald at 2026-01-09T02:48:53-05:00
Warn when "-dynamic" is mixed with "-staticlib"
- - - - -
322dd672 by Matthew Pickering at 2026-01-09T02:49:35-05:00
rts: Use INFO_TABLE_CONSTR for stg_dummy_ret_closure
Since the closure type is CONSTR_NOCAF, we need to use INFO_TABLE_CONSTR
to populate the constructor description field (this crashes ghc-debug
when decoding AP_STACK frames sometimes)
Fixes #26745
- - - - -
039bac4c by Ben Gamari at 2026-01-09T20:22:16-05:00
ghc-internal: Move STM utilities out of GHC.Internal.Conc.Sync
This is necessary to avoid an import cycle on Windows when importing
`GHC.Internal.Exception.Context` in `GHC.Internal.Conc.Sync`.
On the road to address #25365.
- - - - -
8c389e8c by Ben Gamari at 2026-01-09T20:22:16-05:00
base: Capture backtrace from throwSTM
Implements core-libraries-committee#297.
Fixes #25365.
- - - - -
e1ce1fc3 by Ben Gamari at 2026-01-09T20:22:16-05:00
base: Annotate rethrown exceptions in catchSTM with WhileHandling
Implements core-libraries-committee#298
- - - - -
c4ebdbdf by Cheng Shao at 2026-01-09T20:23:06-05:00
compiler: make getPrim eagerly evaluate its result
This commit makes `GHC.Utils.Binary.getPrim` eagerly evaluate its
result, to avoid accidental laziness when future patches build other
binary parsers using `getPrim`.
- - - - -
66a0c4f7 by Cheng Shao at 2026-01-09T20:23:06-05:00
compiler: implement fast get/put for Word16/Word32/Word64
Previously, `GHC.Utils.Binary` contains `get`/`put` functions for
`Word16`/`Word32`/`Word64` which always loads and stores them as
big-endian words at a potentially unaligned address. The previous
implementation is based on loads/stores of individual bytes and
concatenating bytes with bitwise operations, which currently cannot be
fused to a single load/store operation by GHC.
This patch implements fast `get`/`put` functions for
`Word16`/`Word32`/`Word64` based on a single memory load/store, with
an additional `byteSwap` operation on little-endian hosts. It is based
on unaligned load/store primops added since GHC 9.10, and we already
require booting with at least 9.10, so it's about time to switch to
this faster path.
- - - - -
641ec3f0 by Simon Peyton Jones at 2026-01-09T20:23:55-05:00
Fix scoping errors in specialisation
Using -fspecialise-aggressively in #26682 showed up a couple of
subtle errors in the type-class specialiser.
* dumpBindUDs failed to call `deleteCallsMentioning`, resulting in a
call that mentioned a dictionary that was not in scope. This call
has been missing since 2009!
commit c43c981705ec33da92a9ce91eb90f2ecf00be9fe
Author: Simon Peyton Jones <simonpj(a)microsoft.com>
Date: Fri Oct 23 16:15:51 2009 +0000
Fixed by re-combining `dumpBindUDs` and `dumpUDs`.
* I think there was another bug involving the quantified type
variables in polymorphic specialisation. In any case I refactored
`specHeader` and `spec_call` so that the former looks for the
extra quantified type variables rather than the latter. This
is quite a worthwhile simplification: less code, easier to grok.
Test case in simplCore/should_compile/T26682,
brilliantly minimised by @sheaf.
- - - - -
2433e91d by Cheng Shao at 2026-01-09T20:24:43-05:00
compiler: change sectionProtection to take SectionType argument
This commit changes `sectionProtection` to only take `SectionType`
argument instead of whole `Section`, since it doesn't need the Cmm
section content anyway, and it can then be called in parts of NCG
where we only have a `SectionType` in scope.
- - - - -
e5926fbe by Cheng Shao at 2026-01-09T20:24:43-05:00
compiler: change isInitOrFiniSection to take SectionType argument
This commit changes `isInitOrFiniSection` to only take `SectionType`
argument instead of whole `Section`, since it doesn't need the Cmm
section content anyway, and it can then be called in parts of NCG
where we only have a `SectionType` in scope. Also marks it as
exported.
- - - - -
244d57d7 by Cheng Shao at 2026-01-09T20:24:43-05:00
compiler: fix split sections on windows
This patch fixes split sections on windows by emitting the right
COMDAT section header in NCG, see added comment for more explanation.
Fix #26696 #26494.
-------------------------
Metric Decrease:
LargeRecord
T9675
size_hello_artifact
size_hello_artifact_gzip
size_hello_unicode
size_hello_unicode_gzip
Metric Increase:
T13035
-------------------------
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
182f3d0f by Cheng Shao at 2026-01-09T20:25:28-05:00
iserv: add comment about -fkeep-cafs
- - - - -
49675b69 by Matthew Craven at 2026-01-09T20:26:14-05:00
Account for "stupid theta" in demand sig for DataCon wrappers
Fixes #26748.
- - - - -
f3c18890 by Samuel Thibault at 2026-01-10T15:48:22+01:00
hurd: Fix getExecutablePath build
3939a8bf93e27 ("GNU/Hurd: Add getExecutablePath support") added using
/proc/self/exe for GNU/Hurd but missed adding the required imports for
the corresponding code.
- - - - -
7f15bd15 by Samuel Thibault at 2026-01-12T07:16:25-05:00
Fix the OS string encoding for GNU/Hurd
Following https://github.com/haskell/cabal/pull/9434/files , and as seen
in the various gnu_HOST_OS usages in the source code, it is expected that
GNU/Hurd is advertised as "gnu", like the autotools do.
- - - - -
1db2f240 by Andrew Lelechenko at 2026-01-12T07:17:06-05:00
Add since annotation for Data.Bifoldable1
Fixes #26432
- - - - -
e038a383 by Sven Tennie at 2026-01-12T07:17:49-05:00
Ignore Windows CI tool directories in Git
Otherwise, we see thousands of changes in `git status` which is very
confusing to work with.
- - - - -
22e0a9e5 by Apoorv Ingle at 2026-01-12T14:44:59-06:00
This commit:
- Streamlines implementations of `tcExpr` and `tcXExpr` to work on `XExpr`
Calls `setInGeneratedCode` everytime the typechecker goes over an `XExpr`
- Kills `VACtxt` (and its associated VAExpansion and VACall) datatype, it is subsumed by simply a SrcSpan.
- Kills the function `addHeadCtxt` as it is now mearly setting a location
- The function `tcValArgs` does its own argument number management
- Makes `splitHsApps` not look through `XExpr`
- `tcExprSigma` is called if the head of the expression after calling `splitHsApps` turns out to be an `XExpr`
- Removes location information from `OrigPat` payload
- Removes special case of tcBody from `tcLambdaMatches`
- Removes special case of `dsExpr` for `ExpandedThingTc`
- Moves `setQLInstLevel` inside `tcInstFun`
- Rename `HsThingRn` to `SrcCodeCtxt`
- Kills `tcl_in_gen_code` and `tcl_err_ctxt`. It is subsumed by `ErrCtxtStack`
- Kills `ExpectedFunTyOrig`. It is subsumed by `CtOrigin`
- Fixes `CtOrigin` for `HsProjection` case in `exprCtOrigin`. It was previously assigned to be `SectionOrigin`. It is now just the expression
- Adds a new `CtOrigin.ExpansionOrigin` for storing the original syntax
- Adds a new `CtOrigin.ExpectedTySyntax` as a replacement for `ExpectedTySyntaxOp`. Cannot kill the former yet because of `ApplicativeDo`
- Renames `tcMonoExpr` -> `tcMonoLExpr`, `tcMonoExprNC` -> `tcMonoLExpr`
- Renames `EValArg`, `EValArgQL` fields: `ea_ctxt` -> `ea_loc_span` and `eaql_ctx` -> `eaql_loc_span`
Notes added [Error Context Stack]
Notes updated Note [Expanding HsDo with XXExprGhcRn]
-------------------------
Metric Decrease:
T9020
-------------------------
- - - - -
1e38adc0 by Apoorv Ingle at 2026-01-12T14:45:33-06:00
- kill PopErrCtxt
- Pass in the location of the head of the application chain to `addArgCtxt` to print better error messages.
Make `addArgCtxt` print in the nth argument if the head of the application chain is user located.
- match context with record updates dont get added in error context
- Do not use HsPar in Last statement
- simplify addArgCtxt and push setSrcSpan inside addLExprCtxt. Make sure addExprCtxt is not called by itself
- fun_orig in tcApp depends on the SrcSpan of the head of the application chain (similar to addArgCtxt)
- rename fun_ctxt to fun_lspan, fun_orig passed in tcInstFun to default to app chain head if its user located, fall back to srcCodeOrigin if it's a generated location
- fix quickLookArg function to blame the correct application chain head. The arguments application chain head should be blamed, not the original head when we quick look arg
- Make sure only expression wrapped around generated src span are ignored while adding them to the error context stack
- In `addArgCtxt` the nth argument's err ctxt adds a generated error ctxt if the argument is XExpr
- - - - -
45cfc57f by Apoorv Ingle at 2026-01-12T14:45:33-06:00
- make sure landmark error contexts are always printed. accept some testcases
- fix overloaded list error message. Expanded Expressions head `listFromN` should be wrapped in a generated source span
(Wrinkle) This may make some HIE tests to fail, but HIE should fix the behaviour there.
- Fix notes
- fix for MonadFailErrors test case. OrigPat now also stores the statement to make the error message resonable
- - - - -
5959815f by Apoorv Ingle at 2026-01-12T14:45:33-06:00
- `getDeepSubsumptionFlag_DataConHead` performs a non-trivial traversal if the expression passed to it is complex.
This traversal is necessary if the head of the function is an `XExpr` and `splitHsApps` does not look through them
- The deepsubsumption flag is stored in EVAlArgQL to reduce the need to call `getDeepSubsumptionFlag_DataConHead`
- `getDeepSubsumptionFlag_DataConHead` is called in `tcExprSigma` and `tcInferAppHead` to reduce AST traversals
- refactor building CtOrigin before instantiations as a function. It does state lookup only if needed.
- In tcDoStmts, we lose the location of the first statement. It is needed for getting the pattern match check right
Further, do not call addErrCtxt on it, the tcMonoLExpr will do it for us.
- during QL arg's function head instantiation use more a more accurate location for arg when the application chain is null
- - - - -
3336103c by Apoorv Ingle at 2026-01-12T14:45:33-06:00
do not add error context in tcExprSigma for XExpr and do not setQLInstLevel before tcInstFun
- - - - -
52d80ac5 by Apoorv Ingle at 2026-01-12T14:45:33-06:00
wrap expanded records in an XExpr. Accept test cases
- - - - -
f6d8c2bd by Apoorv Ingle at 2026-01-12T14:45:33-06:00
in QuicklookArg, wrap the inferAppHead_maybe with an optional error context update. If the head is a XExpr, we need to flip the state to generated
- - - - -
8f51b641 by Apoorv Ingle at 2026-01-12T14:45:33-06:00
ignore patterns wrapped around generated src span while type checking patterns
- - - - -
60682cd6 by Apoorv Ingle at 2026-01-12T14:45:34-06:00
fixing some more error messages
- - - - -
45a109c6 by Apoorv Ingle at 2026-01-12T14:45:34-06:00
wrap fromListN with a generated src span
- - - - -
7791d4b5 by Apoorv Ingle at 2026-01-12T14:45:34-06:00
some minor things
- - - - -
4284da7c by Apoorv Ingle at 2026-01-12T14:45:34-06:00
enable NB for custom, user written HasField constraint errors
- - - - -
384 changed files:
- .gitattributes
- .gitignore
- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/PrimOps/Ids.hs
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/Info.hs
- compiler/GHC/Cmm/InitFini.hs
- compiler/GHC/Cmm/Utils.hs
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
- compiler/GHC/CmmToAsm/Ppr.hs
- compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/CmmToC.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/CmmToLlvm/Data.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/CSE.hs
- compiler/GHC/Core/Opt/CprAnal.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/Pipeline/Types.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/Core/Ppr.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/Subst.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Core/Unfold/Make.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/Driver/Config/Core/Lint/Interactive.hs
- compiler/GHC/Driver/Config/Core/Opt/Simplify.hs
- compiler/GHC/Driver/Config/Interpreter.hs
- compiler/GHC/Driver/Downsweep.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Foreign/C.hs
- compiler/GHC/HsToCore/Foreign/JavaScript.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/Make.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Linker/Dynamic.hs
- compiler/GHC/Linker/Executable.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Linker/Unit.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Runtime/Interpreter/C.hs
- compiler/GHC/Runtime/Interpreter/Init.hs
- compiler/GHC/Settings.hs
- compiler/GHC/Settings/IO.hs
- compiler/GHC/StgToJS/Linker/Utils.hs
- compiler/GHC/Tc/Deriv/Generics.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Hole.hs
- compiler/GHC/Tc/Errors/Hole/FitTypes.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- + compiler/GHC/Tc/Gen/App.hs-boot
- compiler/GHC/Tc/Gen/Arrow.hs
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Expr.hs-boot
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Match.hs
- 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/Typeable.hs
- compiler/GHC/Tc/Solver.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/FunDeps.hs
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Rewrite.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/CtLoc.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/ThToHs.hs
- + compiler/GHC/Types/Arity.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Id/Make.hs
- + compiler/GHC/Types/InlinePragma.hs
- compiler/GHC/Types/TyThing.hs
- compiler/GHC/Unit/Info.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/Language/Haskell/Syntax/Binds.hs
- + compiler/Language/Haskell/Syntax/Binds/InlinePragma.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- configure.ac
- distrib/configure.ac.in
- − docs/Makefile
- − docs/storage-mgt/Makefile
- docs/users_guide/9.16.1-notes.rst
- − docs/users_guide/Makefile
- docs/users_guide/exts/pragmas.rst
- docs/users_guide/exts/table.rst
- docs/users_guide/phases.rst
- − driver/Makefile
- − driver/ghc/Makefile
- − driver/ghci/Makefile
- − driver/haddock/Makefile
- − driver/utils/merge_sections.ld
- − driver/utils/merge_sections_pe.ld
- ghc/Main.hs
- − ghc/Makefile
- hadrian/cabal.project
- hadrian/cfg/default.host.target.in
- hadrian/cfg/default.target.in
- hadrian/doc/flavours.md
- hadrian/hadrian.cabal
- hadrian/src/Base.hs
- hadrian/src/Builder.hs
- hadrian/src/Context.hs
- hadrian/src/Flavour.hs
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Hadrian/Haskell/Cabal/Type.hs
- hadrian/src/Hadrian/Haskell/Hash.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Packages.hs
- hadrian/src/Rules.hs
- hadrian/src/Rules/Gmp.hs
- hadrian/src/Rules/Library.hs
- hadrian/src/Rules/Register.hs
- hadrian/src/Settings/Builders/Cabal.hs
- hadrian/src/Settings/Builders/Hsc2Hs.hs
- − hadrian/src/Settings/Builders/MergeObjects.hs
- hadrian/src/Settings/Builders/RunTest.hs
- hadrian/src/Settings/Builders/SplitSections.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Flavours/Validate.hs
- hadrian/src/Settings/Packages.hs
- − libraries/Makefile
- libraries/base/changelog.md
- libraries/base/src/Data/Bifoldable1.hs
- libraries/base/src/GHC/Conc.hs
- libraries/base/src/GHC/Conc/Sync.hs
- libraries/base/src/System/IO.hs
- − libraries/doc/Makefile
- libraries/ghc-boot/GHC/Unit/Database.hs
- libraries/ghc-internal/configure.ac
- libraries/ghc-internal/ghc-internal.buildinfo.in
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/include/HsIntegerGmp.h.in
- libraries/ghc-internal/src/GHC/Internal/Conc/IO.hs
- libraries/ghc-internal/src/GHC/Internal/Conc/POSIX.hs
- libraries/ghc-internal/src/GHC/Internal/Conc/Sync.hs
- libraries/ghc-internal/src/GHC/Internal/Conc/Sync.hs-boot
- libraries/ghc-internal/src/GHC/Internal/Conc/Windows.hs
- libraries/ghc-internal/src/GHC/Internal/Control/Monad.hs
- libraries/ghc-internal/src/GHC/Internal/Event/Thread.hs
- libraries/ghc-internal/src/GHC/Internal/Event/Windows/Thread.hs
- libraries/ghc-internal/src/GHC/Internal/Exception/Context.hs
- libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs
- + libraries/ghc-internal/src/GHC/Internal/STM.hs
- libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
- libraries/ghc-internal/src/GHC/Internal/System/IO.hs
- libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
- linters/lint-codes/LintCodes/Static.hs
- − linters/lint-codes/Makefile
- − linters/lint-notes/Makefile
- llvm-passes
- − m4/find_ghc_bootstrap_prog.m4
- − m4/fp_copy_shellvar.m4
- + m4/fp_linker_supports_verbatim.m4
- − m4/fp_prog_ld_flag.m4
- − m4/fp_prog_sort.m4
- m4/prep_target_file.m4
- mk/system-cxx-std-lib-1.0.conf.in
- − mk/win32-tarballs.md5sum
- − rts/Makefile
- rts/PrimOps.cmm
- rts/StgMiscClosures.cmm
- rts/configure.ac
- − rts/include/Makefile
- rts/rts.buildinfo.in
- rts/rts.cabal
- + testsuite/driver/_elffile.py
- testsuite/driver/testglobals.py
- testsuite/driver/testlib.py
- testsuite/ghc-config/ghc-config.hs
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- + testsuite/tests/dmdanal/should_run/T26748.hs
- + testsuite/tests/dmdanal/should_run/T26748.stdout
- testsuite/tests/dmdanal/should_run/all.T
- + testsuite/tests/driver/fully-static/Hello.hs
- + testsuite/tests/driver/fully-static/Makefile
- + testsuite/tests/driver/fully-static/all.T
- + testsuite/tests/driver/fully-static/fully-static.stdout
- + testsuite/tests/driver/fully-static/test/Test.hs
- + testsuite/tests/driver/fully-static/test/test.pkg
- + testsuite/tests/driver/mostly-static/Hello.hs
- + testsuite/tests/driver/mostly-static/Makefile
- + testsuite/tests/driver/mostly-static/all.T
- + testsuite/tests/driver/mostly-static/mostly-static.stdout
- + testsuite/tests/driver/mostly-static/test/test.c
- + testsuite/tests/driver/mostly-static/test/test.h
- + testsuite/tests/driver/mostly-static/test/test.pkg
- + testsuite/tests/driver/recomp26183/M.hs
- + testsuite/tests/driver/recomp26183/M2A.hs
- + testsuite/tests/driver/recomp26183/M2B.hs
- + testsuite/tests/driver/recomp26183/Makefile
- + testsuite/tests/driver/recomp26183/all.T
- + testsuite/tests/driver/recomp26183/recomp26183.stderr
- + testsuite/tests/driver/recomp26705/M.hs
- + testsuite/tests/driver/recomp26705/M2A.hs
- + testsuite/tests/driver/recomp26705/M2B.hs
- + testsuite/tests/driver/recomp26705/Makefile
- + testsuite/tests/driver/recomp26705/all.T
- + testsuite/tests/driver/recomp26705/recomp26705.stderr
- testsuite/tests/ghci/scripts/T8353.stderr
- testsuite/tests/indexed-types/should_compile/CEqCanOccursCheck.hs
- testsuite/tests/indexed-types/should_fail/T12522a.hs
- testsuite/tests/indexed-types/should_fail/T26176.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/numeric/should_run/all.T
- testsuite/tests/overloadedrecflds/should_fail/DRFHoleFits.stderr
- testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- testsuite/tests/parser/should_fail/T20654a.stderr
- testsuite/tests/perf/compiler/hard_hole_fits.stderr
- testsuite/tests/plugins/test-defaulting-plugin.stderr
- testsuite/tests/plugins/test-hole-plugin.stderr
- testsuite/tests/pmcheck/should_compile/T15753c.hs
- + testsuite/tests/pmcheck/should_compile/T15753c.stderr
- testsuite/tests/pmcheck/should_compile/T15753d.hs
- + testsuite/tests/pmcheck/should_compile/T15753d.stderr
- + testsuite/tests/pmcheck/should_compile/T22652.hs
- + testsuite/tests/pmcheck/should_compile/T22652a.hs
- + testsuite/tests/pmcheck/should_compile/T24867.hs
- + testsuite/tests/pmcheck/should_compile/T24867.stderr
- testsuite/tests/pmcheck/should_compile/all.T
- + testsuite/tests/polykinds/T13882.hs
- testsuite/tests/polykinds/all.T
- testsuite/tests/printer/T17697.stderr
- testsuite/tests/quantified-constraints/T15316A.stderr
- testsuite/tests/quantified-constraints/T17267.stderr
- testsuite/tests/quantified-constraints/T17267a.stderr
- testsuite/tests/quantified-constraints/T17267b.stderr
- testsuite/tests/quantified-constraints/T17267c.stderr
- testsuite/tests/quantified-constraints/T17267e.stderr
- testsuite/tests/quantified-constraints/T17458.stderr
- testsuite/tests/rebindable/rebindable6.stderr
- testsuite/tests/rep-poly/RepPolyDoBind.stderr
- testsuite/tests/rep-poly/RepPolyDoBody1.stderr
- testsuite/tests/rep-poly/RepPolyDoBody2.stderr
- testsuite/tests/rep-poly/RepPolyRecordUpdate.stderr
- + testsuite/tests/simplCore/should_compile/T26681.hs
- + testsuite/tests/simplCore/should_compile/T26682.hs
- + testsuite/tests/simplCore/should_compile/T26682a.hs
- + testsuite/tests/simplCore/should_compile/T26709.hs
- + testsuite/tests/simplCore/should_compile/T26709.stderr
- testsuite/tests/simplCore/should_compile/all.T
- testsuite/tests/th/T15321.stderr
- + testsuite/tests/typecheck/should_compile/ExpansionQLIm.hs
- testsuite/tests/typecheck/should_compile/T13050.stderr
- testsuite/tests/typecheck/should_compile/T14273.stderr
- testsuite/tests/typecheck/should_compile/T14590.stderr
- testsuite/tests/typecheck/should_compile/T16188.hs
- testsuite/tests/typecheck/should_compile/T25180.stderr
- testsuite/tests/typecheck/should_compile/abstract_refinement_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_compile/constraint_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/free_monad_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/hole_constraints.stderr
- testsuite/tests/typecheck/should_compile/holes.stderr
- testsuite/tests/typecheck/should_compile/holes2.stderr
- testsuite/tests/typecheck/should_compile/holes3.stderr
- testsuite/tests/typecheck/should_compile/refinement_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/type_in_type_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
- testsuite/tests/typecheck/should_compile/valid_hole_fits_interactions.stderr
- testsuite/tests/typecheck/should_fail/ContextStack1.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion1.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
- testsuite/tests/typecheck/should_fail/FD3.stderr
- testsuite/tests/typecheck/should_fail/FDsFromGivens2.stderr
- testsuite/tests/typecheck/should_fail/FunDepOrigin1b.stderr
- testsuite/tests/typecheck/should_fail/T10971d.stderr
- testsuite/tests/typecheck/should_fail/T13311.stderr
- testsuite/tests/typecheck/should_fail/T13506.stderr
- testsuite/tests/typecheck/should_fail/T14884.stderr
- testsuite/tests/typecheck/should_fail/T15767.stderr
- testsuite/tests/typecheck/should_fail/T19415.stderr
- testsuite/tests/typecheck/should_fail/T19415b.stderr
- testsuite/tests/typecheck/should_fail/T22924b.stderr
- + testsuite/tests/typecheck/should_fail/T23162b.hs
- + testsuite/tests/typecheck/should_fail/T23162b.stderr
- + testsuite/tests/typecheck/should_fail/T23162c.hs
- + testsuite/tests/typecheck/should_fail/T23162d.hs
- testsuite/tests/typecheck/should_fail/T25325.stderr
- testsuite/tests/typecheck/should_fail/T3323.stderr
- testsuite/tests/typecheck/should_fail/T3613.stderr
- testsuite/tests/typecheck/should_fail/T5236.stderr
- testsuite/tests/typecheck/should_fail/T5246.stderr
- testsuite/tests/typecheck/should_fail/T5978.stderr
- testsuite/tests/typecheck/should_fail/T6069.stderr
- testsuite/tests/typecheck/should_fail/T7851.stderr
- testsuite/tests/typecheck/should_fail/T7857.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/TcCoercibleFail.stderr
- testsuite/tests/typecheck/should_fail/all.T
- 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/tcfail143.stderr
- testsuite/tests/typecheck/should_fail/tcfail181.stderr
- utils/check-exact/ExactPrint.hs
- utils/deriveConstants/Main.hs
- utils/ghc-pkg/Main.hs
- utils/ghc-toolchain/exe/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- − utils/iserv/cbits/iservmain.c
- utils/iserv/iserv.cabal.in
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2a4c6ed571842a9fef2c486e675ab7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2a4c6ed571842a9fef2c486e675ab7…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-apporv-Oct24] enable NB for custom, user written HasField constraint errors
by Apoorv Ingle (@ani) 13 Jan '26
by Apoorv Ingle (@ani) 13 Jan '26
13 Jan '26
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
2a4c6ed5 by Apoorv Ingle at 2026-01-12T14:39:20-06:00
enable NB for custom, user written HasField constraint errors
- - - - -
5 changed files:
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Utils/Monad.hs
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
Changes:
=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -81,6 +81,8 @@ import qualified GHC.Data.Strict as Strict
import Language.Haskell.Syntax.Basic (FieldLabelString(..))
+import Language.Haskell.Syntax (HsExpr (RecordUpd, HsGetField, HsProjection))
+import GHC.Hs.Expr (SrcCodeOrigin(..))
import Control.Monad ( unless, when, foldM, forM_ )
import Data.Bifunctor ( bimap )
@@ -2685,6 +2687,10 @@ isHasFieldOrigin = \case
RecordUpdOrigin {} -> True
RecordFieldProjectionOrigin {} -> True
GetFieldOrigin {} -> True
+ ExpansionOrigin (OrigExpr e)
+ | HsGetField{} <- e -> True
+ | RecordUpd{} <- e -> True
+ | HsProjection{} <- e -> True
_ -> False
-----------------------
=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -1079,7 +1079,7 @@ setSrcSpan :: SrcSpan -> TcRn a -> TcRn a
setSrcSpan (RealSrcSpan loc _) thing_inside
= updLclCtxt (\env -> env { tcl_loc = loc }) thing_inside
-setSrcSpan loc thing_inside
+setSrcSpan _ thing_inside
= thing_inside
getSrcCodeOrigin :: TcRn (Maybe SrcCodeOrigin)
=====================================
testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
=====================================
@@ -1,9 +1,15 @@
RecordDotSyntaxFail10.hs:40:11: error: [GHC-39999]
• No instance for ‘HasField "quux" Quux String’
+ arising from a record update
NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class.
• In the second argument of ‘($)’, namely ‘a {foo.bar.baz.quux}’
- In a stmt of a 'do' block: print $ a {foo.bar.baz.quux}
In the expression:
- do let a = Foo {foo = ...}
- let quux = "Expecto patronum!"
- print $ a {foo.bar.baz.quux}
+ do let a = Foo {foo = ...}
+ let quux = "Expecto patronum!"
+ print $ a {foo.bar.baz.quux}
+ In an equation for ‘main’:
+ main
+ = do let a = ...
+ let quux = "Expecto patronum!"
+ print $ a {foo.bar.baz.quux}
+
=====================================
testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr
=====================================
@@ -3,8 +3,11 @@ RecordDotSyntaxFail13.hs:26:11: error: [GHC-39999]
arising from a record update
NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class.
• In the second argument of ‘($)’, namely ‘a {foo}’
- In a stmt of a 'do' block: print $ a {foo}
In the expression:
do let a = Foo {foo = 12}
print $ a {foo}
+ In an equation for ‘main’:
+ main
+ = do let a = ...
+ print $ a {foo}
=====================================
testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
=====================================
@@ -3,7 +3,6 @@ RecordDotSyntaxFail8.hs:47:17: error: [GHC-39999]
arising from selecting the field ‘quux1’
NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class.
• In the second argument of ‘($)’, namely ‘....bar.baz.quux1’
- In a stmt of a 'do' block: print @Quux $ ....baz.quux1
In the expression:
do let a = Foo {foo = ...}
print @Quux $ ....quux1
@@ -11,13 +10,19 @@ RecordDotSyntaxFail8.hs:47:17: error: [GHC-39999]
print @Quux $ b.quux2
let c = Foo {foo = ...}
...
+ In an equation for ‘main’:
+ main
+ = do let a = ...
+ print @Quux $ ....quux1
+ let b = myQuux
+ print @Quux $ b.quux2
+ ...
RecordDotSyntaxFail8.hs:50:17: error: [GHC-39999]
• No instance for ‘HasField "quux2" Quux Quux’
arising from selecting the field ‘quux2’
NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class.
• In the second argument of ‘($)’, namely ‘b.quux2’
- In a stmt of a 'do' block: print @Quux $ b.quux2
In the expression:
do let a = Foo {foo = ...}
print @Quux $ ....quux1
@@ -25,12 +30,31 @@ RecordDotSyntaxFail8.hs:50:17: error: [GHC-39999]
print @Quux $ b.quux2
let c = Foo {foo = ...}
...
+ In an equation for ‘main’:
+ main
+ = do let a = ...
+ print @Quux $ ....quux1
+ let b = myQuux
+ print @Quux $ b.quux2
+ ...
RecordDotSyntaxFail8.hs:53:17: error: [GHC-39999]
- • No instance for ‘HasField "quux3" Quux r0’
+ • No instance for ‘HasField "quux3" Quux a0’
arising from selecting the field ‘quux3’
NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class.
• In the expression: ....bar.baz.quux3
- In the second argument of ‘($)’, namely ‘....baz.quux3.wob’
- In a stmt of a 'do' block: print @Bool $ ....quux3.wob
+ In the expression:
+ do let a = Foo {foo = ...}
+ print @Quux $ ....quux1
+ let b = myQuux
+ print @Quux $ b.quux2
+ let c = Foo {foo = ...}
+ ...
+ In an equation for ‘main’:
+ main
+ = do let a = ...
+ print @Quux $ ....quux1
+ let b = myQuux
+ print @Quux $ b.quux2
+ ...
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2a4c6ed571842a9fef2c486e675ab7e…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2a4c6ed571842a9fef2c486e675ab7e…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/mtl-2.3.2] 5 commits: hurd: Fix getExecutablePath build
by Bodigrim (@Bodigrim) 13 Jan '26
by Bodigrim (@Bodigrim) 13 Jan '26
13 Jan '26
Bodigrim pushed to branch wip/mtl-2.3.2 at Glasgow Haskell Compiler / GHC
Commits:
f3c18890 by Samuel Thibault at 2026-01-10T15:48:22+01:00
hurd: Fix getExecutablePath build
3939a8bf93e27 ("GNU/Hurd: Add getExecutablePath support") added using
/proc/self/exe for GNU/Hurd but missed adding the required imports for
the corresponding code.
- - - - -
7f15bd15 by Samuel Thibault at 2026-01-12T07:16:25-05:00
Fix the OS string encoding for GNU/Hurd
Following https://github.com/haskell/cabal/pull/9434/files , and as seen
in the various gnu_HOST_OS usages in the source code, it is expected that
GNU/Hurd is advertised as "gnu", like the autotools do.
- - - - -
1db2f240 by Andrew Lelechenko at 2026-01-12T07:17:06-05:00
Add since annotation for Data.Bifoldable1
Fixes #26432
- - - - -
e038a383 by Sven Tennie at 2026-01-12T07:17:49-05:00
Ignore Windows CI tool directories in Git
Otherwise, we see thousands of changes in `git status` which is very
confusing to work with.
- - - - -
0e93a79b by Andrew Lelechenko at 2026-01-12T19:39:07+00:00
Upgrade mtl submodule to 2.3.2
Fixes #26656
- - - - -
5 changed files:
- .gitignore
- libraries/base/src/Data/Bifoldable1.hs
- libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
- libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
- libraries/mtl
Changes:
=====================================
.gitignore
=====================================
@@ -256,3 +256,12 @@ ghc.nix/
# clangd
.clangd
dist-newstyle/
+
+# -----------------------------------------------------------------------------
+# CI
+
+# Windows CI
+toolchain/
+ghc-*/
+inplace/
+tmp/
=====================================
libraries/base/src/Data/Bifoldable1.hs
=====================================
@@ -2,6 +2,7 @@
-- Copyright: Edward Kmett, Oleg Grenrus
-- License: BSD-3-Clause
--
+-- @since 4.18.0.0
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Safe #-}
=====================================
libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
=====================================
@@ -51,7 +51,7 @@ import GHC.Internal.Foreign.Ptr
import GHC.Internal.Foreign.Storable
import GHC.Internal.System.IO.Error (isDoesNotExistError)
import GHC.Internal.System.Posix.Internals
-#elif defined(linux_HOST_OS)
+#elif defined(linux_HOST_OS) || defined(gnu_HOST_OS)
import GHC.Internal.Data.Functor
import GHC.Internal.Data.List (isSuffixOf)
import GHC.Internal.Foreign.C.Types
=====================================
libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
=====================================
@@ -156,7 +156,7 @@ stringEncodeOS = \case
OSHaiku -> "haiku"
OSQNXNTO -> "nto-qnx"
OSAIX -> "aix"
- OSHurd -> "hurd"
+ OSHurd -> "gnu"
OSWasi -> "wasi"
OSGhcjs -> "ghcjs"
=====================================
libraries/mtl
=====================================
@@ -1 +1 @@
-Subproject commit 37cbd924cb71eba591a2e2b6b131767f632d22c9
+Subproject commit 4b5080f43cbc372a437d5fecb144c7b75aadd86b
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8cc00bf8aa64b29550acbeee93592d…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8cc00bf8aa64b29550acbeee93592d…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Fix the OS string encoding for GNU/Hurd
by Marge Bot (@marge-bot) 13 Jan '26
by Marge Bot (@marge-bot) 13 Jan '26
13 Jan '26
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
7f15bd15 by Samuel Thibault at 2026-01-12T07:16:25-05:00
Fix the OS string encoding for GNU/Hurd
Following https://github.com/haskell/cabal/pull/9434/files , and as seen
in the various gnu_HOST_OS usages in the source code, it is expected that
GNU/Hurd is advertised as "gnu", like the autotools do.
- - - - -
1db2f240 by Andrew Lelechenko at 2026-01-12T07:17:06-05:00
Add since annotation for Data.Bifoldable1
Fixes #26432
- - - - -
e038a383 by Sven Tennie at 2026-01-12T07:17:49-05:00
Ignore Windows CI tool directories in Git
Otherwise, we see thousands of changes in `git status` which is very
confusing to work with.
- - - - -
be3829a4 by sheaf at 2026-01-12T12:56:25-05:00
Don't re-use stack slots for growing registers
This commit avoids re-using a stack slot for a register that has grown
but already had a stack slot.
For example, suppose we have stack slot assigments
%v1 :: FF64 |-> StackSlot 0
%v2 :: FF64 |-> StackSlot 1
Later, we start using %v1 at a larger format (e.g. F64x2) and we need
to spill it again. Then we **must not** use StackSlot 0, as a spill
at format F64x2 would clobber the data in StackSlot 1.
This can cause some fragmentation of the `StackMap`, but that's probably
OK.
Fixes #26668
- - - - -
9f61ac3b by fendor at 2026-01-12T12:56:25-05:00
Remove `traceId` from ghc-pkg executable
- - - - -
6 changed files:
- .gitignore
- compiler/GHC/CmmToAsm/Reg/Linear.hs
- compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs
- libraries/base/src/Data/Bifoldable1.hs
- libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
- utils/ghc-pkg/Main.hs
Changes:
=====================================
.gitignore
=====================================
@@ -256,3 +256,12 @@ ghc.nix/
# clangd
.clangd
dist-newstyle/
+
+# -----------------------------------------------------------------------------
+# CI
+
+# Windows CI
+toolchain/
+ghc-*/
+inplace/
+tmp/
=====================================
compiler/GHC/CmmToAsm/Reg/Linear.hs
=====================================
@@ -406,7 +406,7 @@ linearRA block_live block_id = go [] []
-- | Do allocation for a single instruction.
raInsn
:: OutputableRegConstraint freeRegs instr
- => BlockMap Regs -- ^ map of what vregs are love on entry to each block.
+ => BlockMap Regs -- ^ map of what vregs are live on entry to each block.
-> [instr] -- ^ accumulator for instructions already processed.
-> BlockId -- ^ the id of the current block, for debugging
-> LiveInstr instr -- ^ the instr to have its regs allocated, with liveness info.
=====================================
compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs
=====================================
@@ -37,7 +37,11 @@ data StackMap
-- See Note [UniqFM and the register allocator]
-- | Assignment of vregs to stack slots.
- , stackMapAssignment :: UniqFM Unique StackSlot }
+ --
+ -- We record not just the slot, but also how many stack slots the vreg
+ -- takes up, in order to avoid re-using a stack slot for a register
+ -- that has grown but already had a stack slot (#26668).
+ , stackMapAssignment :: UniqFM Unique (StackSlot, Int) }
-- | An empty stack map, with all slots available.
@@ -50,14 +54,19 @@ emptyStackMap = StackMap 0 emptyUFM
--
getStackSlotFor :: StackMap -> Format -> Unique -> (StackMap, Int)
-getStackSlotFor fs@(StackMap _ reserved) _fmt regUnique
- | Just slot <- lookupUFM reserved regUnique = (fs, slot)
-
-getStackSlotFor (StackMap freeSlot reserved) fmt regUnique =
- let
- nbSlots = (formatInBytes fmt + 7) `div` 8
- in
- (StackMap (freeSlot+nbSlots) (addToUFM reserved regUnique freeSlot), freeSlot)
+getStackSlotFor fs@(StackMap freeSlot reserved) fmt regUnique
+ -- The register already has a stack slot; try to re-use it.
+ | Just (slot, nbSlots) <- lookupUFM reserved regUnique
+ -- Make sure the slot is big enough for this format, in case the register
+ -- has grown (#26668).
+ , nbNeededSlots <= nbSlots
+ = (fs, slot)
+ | otherwise
+ = (StackMap (freeSlot+nbNeededSlots) (addToUFM reserved regUnique (freeSlot, nbNeededSlots)), freeSlot)
+ -- NB: this can create fragmentation if a register keeps growing.
+ -- That's probably OK, as this is only happens very rarely.
+ where
+ !nbNeededSlots = (formatInBytes fmt + 7) `div` 8
-- | Return the number of stack slots that were allocated
getStackUse :: StackMap -> Int
=====================================
libraries/base/src/Data/Bifoldable1.hs
=====================================
@@ -2,6 +2,7 @@
-- Copyright: Edward Kmett, Oleg Grenrus
-- License: BSD-3-Clause
--
+-- @since 4.18.0.0
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Safe #-}
=====================================
libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
=====================================
@@ -156,7 +156,7 @@ stringEncodeOS = \case
OSHaiku -> "haiku"
OSQNXNTO -> "nto-qnx"
OSAIX -> "aix"
- OSHurd -> "hurd"
+ OSHurd -> "gnu"
OSWasi -> "wasi"
OSGhcjs -> "ghcjs"
=====================================
utils/ghc-pkg/Main.hs
=====================================
@@ -23,7 +23,6 @@
module Main (main) where
-import Debug.Trace
import qualified GHC.Unit.Database as GhcPkg
import GHC.Unit.Database hiding (mkMungePathUrl)
import GHC.HandleEncoding
@@ -1634,7 +1633,7 @@ listPackages verbosity my_flags mPackageName mModuleName = do
simplePackageList :: [Flag] -> [InstalledPackageInfo] -> IO ()
simplePackageList my_flags pkgs = do
let showPkg :: InstalledPackageInfo -> String
- showPkg | FlagShowUnitIds `elem` my_flags = traceId . display . installedUnitId
+ showPkg | FlagShowUnitIds `elem` my_flags = display . installedUnitId
| FlagNamesOnly `elem` my_flags = display . mungedName . mungedId
| otherwise = display . mungedId
strs = map showPkg pkgs
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f55a0d72cf10e8115729368e0bdef…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f55a0d72cf10e8115729368e0bdef…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-try-opt-coercion] Comments -- almost all just about core invariants [skip ci]
by Simon Peyton Jones (@simonpj) 13 Jan '26
by Simon Peyton Jones (@simonpj) 13 Jan '26
13 Jan '26
Simon Peyton Jones pushed to branch wip/spj-try-opt-coercion at Glasgow Haskell Compiler / GHC
Commits:
2b2ee165 by Simon Peyton Jones at 2026-01-12T17:31:42+00:00
Comments -- almost all just about core invariants [skip ci]
- - - - -
18 changed files:
- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion/Opt.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/CSE.hs
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Opt/FloatIn.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Stg/Lint.hs
Changes:
=====================================
compiler/GHC/Builtin/PrimOps.hs
=====================================
@@ -435,12 +435,12 @@ follows, in decreasing order of permissiveness:
NoEffect, we may float such an invalid call out of a dead branch
and speculatively evaluate it.
- In particular, we cannot safely rewrite such an invalid call to a
- runtime error; we must emit code that produces a valid Word32#.
- (If we're lucky, Core Lint may complain that the result of such a
- rewrite violates the let-can-float invariant (#16742), but the
- rewrite is always wrong!) See also Note [Guarding against silly shifts]
- in GHC.Core.Opt.ConstantFold.
+ In particular, we cannot safely rewrite such an invalid call to a runtime
+ error; we must emit code that produces a valid Word32#. (If we're lucky,
+ Core Lint may complain that the result of such a rewrite violates
+ Note [Core binding invariants: nested non-rec] (#16742), but the rewrite
+ is always wrong!) See also Note [Guarding against silly shifts] in
+ GHC.Core.Opt.ConstantFold.
Marking uncheckedShiftLWord32# as CanFail instead of NoEffect
would give us the freedom to rewrite such invalid calls to runtime
@@ -578,12 +578,12 @@ Several predicates on primops test this flag:
where it is guarded by exprOkToDiscard, which in turn checks
primOpOkToDiscard.
- * The "no-float-out" thing is achieved by ensuring that we never
- let-bind a saturated primop application unless it has NoEffect.
- The RHS of a let-binding (which can float in and out freely)
- satisfies exprOkForSpeculation; this is the let-can-float
- invariant. And exprOkForSpeculation is false of a saturated
- primop application unless it has NoEffect.
+ * The "no-float-out" thing is achieved by ensuring that we never let-bind a
+ saturated primop application unless it has NoEffect. The RHS of a
+ let-binding (which can float in and out freely) satisfies
+ exprOkForSpeculation; this is Note [Core binding invariants: nested non-rec].
+ And exprOkForSpeculation is false of a saturated primop application unless it
+ has NoEffect.
* So primops that aren't NoEffect will appear only as the
scrutinees of cases, and that's why the FloatIn pass is capable
=====================================
compiler/GHC/Core.hs
=====================================
@@ -188,8 +188,7 @@ These data types are the heart of the compiler
-- this corresponds to allocating a thunk for the things
-- bound and then executing the sub-expression.
--
--- See Note [Core letrec invariant]
--- See Note [Core let-can-float invariant]
+-- See Note [Core binding invariants]
-- See Note [Representation polymorphism invariants]
-- See Note [Core type and coercion invariant]
--
@@ -393,25 +392,37 @@ extremely difficult to GUARANTEE it:
* See Note [Shadowing in SpecConstr] in GHC.Core.Opt.SpecContr
-Note [Core letrec invariant]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The Core letrec invariant:
+Note [Core binding invariants]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+A core binding, `CoreBind`, obeys these invariants:
- The right hand sides of all /top-level/ or /recursive/
- bindings must be of lifted type
+* For /top level/ or /recursive/ bindings,
+ see Note [Top-level binding invariants]
-See "Type#type_classification" in GHC.Core.Type
-for the meaning of "lifted" vs. "unlifted".
+* For /nested/ (not top-level) /non-recursive/ bindings,
+ see Note [Nested binding invariants]
+
+Note [Top-level binding invariants]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+A /top-level/ or /recursive/ binding must
-For the non-top-level, non-recursive case see
-Note [Core let-can-float invariant].
+ * be of lifted type
+OR
+ * have a RHS that is a primitive string literal
+ (see Note [Core top-level string literals], or
+OR
+ * have a rhs that is (Coercion co)
+OR
+ * be a worker or wrapper for an unlifted non-newtype data constructor; see (TL1).
-At top level, however, there are two exceptions to this rule:
+For the non-top-level, non-recursive case see Note [Nested binding invariants].
+(NB: this Note applies to recursive as well as top-level bindings, but I wanted
+a short title!)
-(TL1) A top-level binding is allowed to bind primitive string literal,
- (which is unlifted). See Note [Core top-level string literals].
+See "Type#type_classification" in GHC.Core.Type
+for the meaning of "lifted" vs. "unlifted".
-(TL2) In Core, we generate a top-level binding for every non-newtype data
+(TL1) In Core, we generate a top-level binding for every non-newtype data
constructor worker or wrapper
e.g. data T = MkT Int
we generate
@@ -428,16 +439,17 @@ constructor worker or wrapper
S1 = S1
We allow this top-level unlifted binding to exist.
-Note [Core let-can-float invariant]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The let-can-float invariant:
-
- The right hand side of a /non-top-level/, /non-recursive/ binding
- may be of unlifted type, but only if
- the expression is ok-for-speculation
- or the 'Let' is for a join point.
+Note [Nested binding invariants]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+A /non-top-level/, /non-recursive/ binding must
+ * Be a join point; see Note [Invariants on join points]
+OR
+ * Be of lifted type
+OR
+ * Have a RHS that is ok-for-speculation
- (For top-level or recursive lets see Note [Core letrec invariant].)
+NB: this only applies to /non-recursive/ bindings. For recursive
+(or top-level) bindings see Note [Top-level binding invariants].
This means that the let can be floated around
without difficulty. For example, this is OK:
@@ -454,14 +466,14 @@ In this situation you should use @case@ rather than a @let@. The function
alternatively use 'GHC.Core.Make.mkCoreLet' rather than this constructor directly,
which will generate a @case@ if necessary
-The let-can-float invariant is initially enforced by mkCoreLet in GHC.Core.Make.
+The Core binding invariants are initially enforced by mkCoreLet in GHC.Core.Make.
Historical Note [The let/app invariant]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Before 2022 GHC used the "let/app invariant", which applied the let-can-float rules
-to the argument of an application, as well as to the RHS of a let. This made some
-kind of sense, because 'let' can always be encoded as application:
- let x=rhs in b = (\x.b) rhs
+Before 2022 GHC used the "let/app invariant", which applied
+Note [Nested binding invariants] to the argument of an application,
+as well as to the RHS of a let. This made some kind of sense, because 'let' can
+always be encoded as application: let x=rhs in b = (\x.b) rhs
But the let/app invariant got in the way of RULES; see #19313. For example
up :: Int# -> Int#
@@ -472,7 +484,7 @@ Indeed RULES is a big reason that GHC doesn't use ANF, where the argument of an
application is always a variable or a constant. To allow RULES to work nicely
we need to allow lots of things in the arguments of a call.
-TL;DR: we relaxed the let/app invariant to become the let-can-float invariant.
+TL;DR: we relaxed the let/app invariant to focus just on /bindings/.
Note [Core top-level string literals]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -631,13 +643,33 @@ checked by Core Lint.
Note [Core type and coercion invariant]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-We allow a /non-recursive/, /non-top-level/ let to bind type and
-coercion variables. These can be very convenient for postponing type
-substitutions until the next run of the simplifier.
+We allow `let` to bind type and coercion variables.
+
+* A type or coercion binding is always /non-recursive/
+
+* A type binding cannot be top level (yet) but a coercion binding
+ can be top-level.
* A type variable binding must have a RHS of (Type ty)
* A coercion variable binding must have a RHS of (Coercion co)
+ See Note [Coercion bindings]
+
+
+Note [Coercion bindings]
+~~~~~~~~~~~~~~~~~~~~~~~~
+We allow non-recursive let-bindings for coercion variables, CoVars,
+of type (t1 ~r# t2).
+
+The /main motivation/ is to support sharing:
+ let g::T a ~# b
+ g = Coercion <some big coercion?
+ in ...g..g..g...
+If we simply duplicate `g` at every occurrence site, we can bloat the
+size of the program, increasing both compile time and .hi-file sizes.
+
+* A coercion binding always has a RHS of (Coercion co).
+ See Note [Core type and coercion invariants].
It is possible to have terms that return a coercion, but we use
case-binding for those; e.g.
@@ -650,6 +682,15 @@ substitutions until the next run of the simplifier.
Note [Equality superclasses in quantified constraints]
in GHC.Tc.Solver.Dict
+* Coercion bindings can be top level. And a top-level coercion binding can be
+ exported, and hence must:
+ * Have a GlobalId.
+ * Appear as a declaration in an interface file
+ That means that a coercion might mention a CoVar that is an imported GlobalId.
+ Just as for Core expressions, the free variable finder for Coercions can
+ ignore GlobalIds.
+
+
Note [Representation polymorphism invariants]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GHC allows us to abstract over calling conventions using **representation polymorphism**.
@@ -846,7 +887,7 @@ Join points must follow these invariants:
However, join points have simpler invariants in other ways
5. A join point can have an unboxed type without the RHS being
- ok-for-speculation (i.e. drop the let-can-float invariant)
+ ok-for-speculation; see
e.g. let j :: Int# = factorial x in ...
6. The RHS of join point is not required to have a fixed runtime representation,
@@ -2053,8 +2094,8 @@ mkDoubleLitDouble :: Double -> Expr b
mkDoubleLit d = Lit (mkLitDouble d)
mkDoubleLitDouble d = Lit (mkLitDouble (toRational d))
--- | Bind all supplied binding groups over an expression in a nested let expression. Assumes
--- that the rhs satisfies the let-can-float invariant. Prefer to use
+-- | Bind all supplied binding groups over an expression in a nested let expression.
+-- Assumes that the rhs satisfies Note [Nested binding invariants]. Prefer to use
-- 'GHC.Core.Make.mkCoreLets' if possible, which does guarantee the invariant
mkLets :: [Bind b] -> Expr b -> Expr b
-- | Bind all supplied binders over an expression in a nested lambda expression. Prefer to
=====================================
compiler/GHC/Core/Coercion/Opt.hs
=====================================
@@ -46,7 +46,7 @@ Note [Coercion optimisation]
This module does coercion optimisation. The purpose is to reduce the size
of the coercions that the compiler carries around -- they are just proofs,
and serve no runtime need. So the purpose of coercion optimisation is simply
-to shrink coercions and thereby reduce compile time.
+to shrink coercions and thereby reduce compile time and .hi file sizes.
See the paper
Evidence normalization in Systtem FV (RTA'13)
@@ -57,7 +57,7 @@ However, although powerful and occasionally very effective, coercion
optimisation can itself be very expensive (#26679). So we apply it sparingly:
* In the Simplifier, function `rebuild_go`, we use `isReflexiveCo` (which
- computes the type of the coercion) to eliminate reflexive coercion, just
+ computes the type of the coercion) to eliminate reflexive coercions, just
before we build a cast (e |> co).
(More precisely, we use `isReflexiveCoIgnoringMultiplicity;
@@ -196,6 +196,10 @@ We use the following invariants:
%********************************************************************* -}
optCoProgram :: CoreProgram -> CoreProgram
+-- Apply optCoercion to all coercions in /expressions/
+-- There may also be coercions in /types/ but we `optCoProgram` doesn't
+-- look at them; they are typically fewer and smaller, and it doesn't seem
+-- worth the cost of traversing and rebuilding all the types in the program.
optCoProgram binds
= map go binds
where
@@ -237,7 +241,24 @@ optCoAlt is (Alt k bs e)
%* *
%********************************************************************* -}
+{- Note [optCoRefl]
+~~~~~~~~~~~~~~~~~~~~
+`optCoRefl` is an experimental cheap-and-cheerful version of `optCoercion`.
+
+* It focuses entirely on chains of TransCo, thus
+ co1 ; co2 ; co3 ; ... ; con
+
+* It looks for sub-sequences in this chain that are Refl, based on their
+ types. The clever business is all in `gobble`, which springs into action
+ when we find a `TransCo`.
+
+* It can sometimes do a bit more than `optCoercion`. It'll eliminate /any/
+ subsequence of co1..con that is reflexive, whereas `optCoercion` just works
+ left-to-right, and won't spot (co1 ; co2 ; sym co2)
+-}
+
optCoRefl :: Coercion -> Coercion
+-- See Note [optCoRefl]
optCoRefl in_co
#ifdef DEBUG
-- Debug check that optCoRefl doesn't change the type
=====================================
compiler/GHC/Core/Lint.hs
=====================================
@@ -586,8 +586,7 @@ lintLetBind top_lvl rec_flag binder rhs rhs_ty
; checkL (not (isCoVar binder) || isCoArg rhs)
(mkLetErr binder rhs)
- -- Check the let-can-float invariant
- -- See Note [Core let-can-float invariant] in GHC.Core
+ -- Check Note [Core binding invariants] in GHC.Core
; checkL (bindingIsOk top_lvl rec_flag binder binder_ty rhs) $
mkLetErr binder rhs
@@ -647,6 +646,7 @@ lintLetBind top_lvl rec_flag binder rhs rhs_ty
-- the unfolding is a SimplifiableCoreExpr. Give up for now.
bindingIsOk :: TopLevelFlag -> RecFlag -> OutId -> OutType -> CoreExpr -> Bool
+-- Checks the invariants of Note [Core binding invariants] in GHC.Core
bindingIsOk top_lvl rec_flag binder binder_ty rhs
| isCoVar binder
= isCoArg rhs
=====================================
compiler/GHC/Core/Make.hs
=====================================
@@ -112,8 +112,9 @@ sortQuantVars vs = sorted_tcvs ++ ids
-- | Bind a binding group over an expression, using a @let@ or @case@ as
-- appropriate (see "GHC.Core#let_can_float_invariant")
mkCoreLet :: HasDebugCallStack => CoreBind -> CoreExpr -> CoreExpr
-mkCoreLet (NonRec bndr rhs) body -- See Note [Core let-can-float invariant]
- = bindNonRec bndr rhs body
+mkCoreLet (NonRec bndr rhs) body
+ = -- See Note [Core binding invariants: nested non-rec]
+ bindNonRec bndr rhs body
mkCoreLet bind body
= Let bind body
=====================================
compiler/GHC/Core/Opt/CSE.hs
=====================================
@@ -288,8 +288,8 @@ all trivial expressions. Consider
case x |> co of (y::Array# Int) { ... }
We do not want to extend the substitution with (y -> x |> co); since y
-is of unlifted type, this would destroy the let-can-float invariant if
-(x |> co) was not ok-for-speculation.
+is of unlifted type, this would destroy Note [Nested binding invariants]
+if (x |> co) was not ok-for-speculation.
But surely (x |> co) is ok-for-speculation, because it's a trivial
expression, and x's type is also unlifted, presumably. Well, maybe
=====================================
compiler/GHC/Core/Opt/ConstantFold.hs
=====================================
@@ -1606,11 +1606,11 @@ as follows:
let x = I# (error "invalid shift")
in ...
-This was originally done in the fix to #16449 but this breaks the
-let-can-float invariant (see Note [Core let-can-float invariant] in
-GHC.Core) as noted in #16742. For the reasons discussed under
-"NoEffect" in Note [Classifying primop effects] (in GHC.Builtin.PrimOps)
-there is no safe way to rewrite the argument of I# such that it bottoms.
+This was originally done in the fix to #16449 but this breaks
+Note [Nested binding invariants] in GHC.Core, as noted in #16742. For the
+reasons discussed under "NoEffect" in Note [Classifying primop effects] (in
+GHC.Builtin.PrimOps) there is no safe way to rewrite the argument of I# such
+that it bottoms.
Consequently we instead take advantage of the fact that the result of a
large shift is unspecified (see associated documentation in primops.txt.pp)
@@ -2177,15 +2177,15 @@ BigNat). These rules implement the same kind of constant folding as we have for
Int#/Word#/etc. primops. See builtinBignumRules.
These rules are built-in because they can't be expressed as regular rules for
-now. The reason is that due to the let-can-float invariant (see Note [Core
-let-can-float invariant] in GHC.Core), GHC is too conservative with some bignum
-operations and they don't match rules. For example:
+now. The reason is that due to Note [Nested binding invariants] in GHC.Core,
+GHC is too conservative with some bignum operations and they don't match rules.
+For example:
case integerAdd 1 x of r { _ -> integerAdd 1 r }
doesn't constant-fold into `integerAdd 2 x` with a regular rule. That's because
GHC never floats in `integerAdd 1 x` to form `integerAdd 1 (integerAdd 1 x)`
-because of the let-can-float invariant (it doesn't know if `integerAdd`
+because of Note [Nested binding invariants] (it doesn't know if `integerAdd`
terminates).
In the built-in rule for `integerAdd` we can access the unfolding of `r` and we
=====================================
compiler/GHC/Core/Opt/FloatIn.hs
=====================================
@@ -665,7 +665,8 @@ noFloatIntoRhs is_rec bndr rhs
= isRec is_rec -- Joins are one-shot iff non-recursive
| definitelyUnliftedType (idType bndr)
- = True -- Preserve let-can-float invariant, see Note [noFloatInto considerations]
+ = True -- Preserve Note [Nested binding invariants],
+ -- see Note [noFloatInto considerations]
| otherwise
= noFloatIntoArg rhs
@@ -690,7 +691,7 @@ When do we want to float bindings into
- noFloatIntoArg: the argument of a function application
Definitely don't float into RHS if it has unlifted type;
-that would destroy the let-can-float invariant.
+that would destroy Note [Nested binding invariants].
* Wrinkle 1: do not float in if
(a) any non-one-shot value lambdas
=====================================
compiler/GHC/Core/Opt/SetLevels.hs
=====================================
@@ -1003,12 +1003,11 @@ Why? Because it's important /not/ to transform
let x = a /# 3
to
let x = case bx of I# a -> a /# 3
-because the let binding no
-longer obeys the let-can-float invariant. But (a /# 3) is ok-for-spec
-due to a special hack that says division operators can't fail
-when the denominator is definitely non-zero. And yet that
-same expression says False to exprIsCheap. Simplest way to
-guarantee the let-can-float invariant is to use the same function!
+because the let binding no longer obeys Note [Nested binding invariants].
+But (a /# 3) is ok-for-spec due to a special hack that says division operators
+can't fail when the denominator is definitely non-zero. And yet that same
+expression says False to exprIsCheap. Simplest way to guarantee
+Note [Nested binding invariants] is to use the same function!
If an expression is okay for speculation, we could also float it out
*without* boxing and unboxing, since evaluating it early is okay.
=====================================
compiler/GHC/Core/Opt/Simplify/Env.hs
=====================================
@@ -749,8 +749,8 @@ Examples
NonRec x# (y +# 3) FltOkSpec -- Unboxed, but ok-for-spec'n
NonRec x* (f y) FltCareful -- Strict binding; might fail or diverge
- NonRec x# (a /# b) FltCareful -- Might fail; does not satisfy let-can-float invariant
- NonRec x# (f y) FltCareful -- Might diverge; does not satisfy let-can-float invariant
+ NonRec x# (a /# b) FltCareful -- Might fail; does not satisfy Note [Nested binding invariants]
+ NonRec x# (f y) FltCareful -- Might diverge; does not satisfy Note [Nested binding invariants]
-}
data LetFloats = LetFloats (OrdList OutBind) FloatFlag
@@ -763,7 +763,7 @@ data FloatFlag
= FltLifted -- All bindings are lifted and lazy *or*
-- consist of a single primitive string literal
-- Hence ok to float to top level, or recursive
- -- NB: consequence: all bindings satisfy let-can-float invariant
+ -- NB: consequence: all bindings satisfy Note [Nested binding invariants]
| FltOkSpec -- All bindings are FltLifted *or*
-- strict (perhaps because unlifted,
@@ -772,12 +772,12 @@ data FloatFlag
-- Hence ok to float out of the RHS
-- of a lazy non-recursive let binding
-- (but not to top level, or into a rec group)
- -- NB: consequence: all bindings satisfy let-can-float invariant
+ -- NB: consequence: all bindings satisfy Note [Nested binding invariants]
| FltCareful -- At least one binding is strict (or unlifted)
-- and not guaranteed cheap
-- Do not float these bindings out of a lazy let!
- -- NB: some bindings may not satisfy let-can-float
+ -- NB: some bindings may not satisfy Note [Nested binding invariants]
instance Outputable LetFloats where
ppr (LetFloats binds ff) = ppr ff $$ ppr (fromOL binds)
@@ -962,8 +962,8 @@ wrapFloats (SimplFloats { sfLetFloats = LetFloats bs flag
-- Note: Always safe to put the joins on the inside
-- since the values can't refer to them
where
- mk_let | FltCareful <- flag = mkCoreLet -- need to enforce let-can-float-invariant
- | otherwise = Let -- let-can-float invariant hold
+ mk_let | FltCareful <- flag = mkCoreLet -- Need to enforce Note [Nested binding invariants]
+ | otherwise = Let -- Note [Nested binding invariants] holds
wrapJoinFloatsX :: SimplFloats -> OutExpr -> (SimplFloats, OutExpr)
-- Wrap the sfJoinFloats of the env around the expression,
=====================================
compiler/GHC/Core/Opt/Simplify/Iteration.hs
=====================================
@@ -315,7 +315,7 @@ simplLazyBind :: TopLevelFlag -> RecFlag
-> (InExpr, SimplEnv) -- The RHS and its static environment
-> SimplM (SimplFloats, SimplEnv)
-- Precondition: Ids only, no TyVars; not a JoinId
--- Precondition: rhs obeys the let-can-float invariant
+-- Precondition: rhs obeys Note [Nested binding invariants]
simplLazyBind top_lvl is_rec (bndr,unf_se) (bndr1,env) (rhs,rhs_se)
= assert (isId bndr )
assertPpr (not (isJoinId bndr)) (ppr bndr) $
@@ -397,7 +397,7 @@ simplAuxBind :: String
-- The binder comes from a case expression (case binder or alternative)
-- and so does not have rules, unfolding, inline pragmas etc.
--
--- Precondition: rhs satisfies the let-can-float invariant
+-- Precondition: rhs satisfies Note [Nested binding invariants]
simplAuxBind _str env bndr new_rhs
| assertPpr (isId bndr && not (isJoinId bndr)) (ppr bndr) $
@@ -950,7 +950,7 @@ completeBind :: BindContext
-- * or by adding to the floats in the envt
--
-- Binder /can/ be a JoinId
--- Precondition: rhs obeys the let-can-float invariant
+-- Precondition: rhs obeys Note [Nested binding invariants]
completeBind bind_cxt (old_bndr, unf_se) (new_bndr, new_rhs, env)
| isCoVar old_bndr
= case new_rhs of
@@ -1290,7 +1290,7 @@ simplExprF1 env (Let (NonRec bndr rhs) body) cont
; simplExprF (extendTvSubst env bndr ty') body cont }
| Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs env
- -- Because of the let-can-float invariant, it's ok to
+ -- Because of Note [Nested binding invariants], it's ok to
-- inline freely, or to drop the binding if it is dead.
= do { simplTrace "SimplBindr:inline-uncond2" (ppr bndr <+> ppr rhs) $
tick (PreInlineUnconditionally bndr)
@@ -1594,13 +1594,13 @@ rebuild_go env expr cont
completeBindX :: SimplEnv
-> FromWhat
-> InId -> OutExpr -- Non-recursively bind this Id to this (simplified) expression
- -- (the let-can-float invariant may not be satisfied)
+ -- (Note [Nested binding invariants] may not be satisfied)
-> InExpr -- In this body
-> SimplCont -- Consumed by this continuation
-> SimplM (SimplFloats, OutExpr)
completeBindX env from_what bndr rhs body cont
| FromBeta arg_levity <- from_what
- , needsCaseBindingL arg_levity rhs -- Enforcing the let-can-float-invariant
+ , needsCaseBindingL arg_levity rhs -- Enforcing Note [Nested binding invariants]
= do { (env1, bndr1) <- simplNonRecBndr env bndr -- Lambda binders don't have rules
; (floats, expr') <- simplNonRecBody env1 from_what body cont
-- Do not float floats past the Case binder below
@@ -1887,7 +1887,7 @@ simplNonRecE :: HasDebugCallStack
-- It deals with strict bindings, via the StrictBind continuation,
-- which may abort the whole process.
--
--- from_what=FromLet => the RHS satisfies the let-can-float invariant
+-- from_what=FromLet => the RHS satisfies Note [Nested binding invariants]
-- Otherwise it may or may not satisfy it.
simplNonRecE env from_what bndr (rhs, rhs_se) body cont
@@ -1910,7 +1910,7 @@ simplNonRecE env from_what bndr (rhs, rhs_se) body cont
is_strict_bind = case from_what of
FromBeta Unlifted -> True
-- If we are coming from a beta-reduction (FromBeta) we must
- -- establish the let-can-float invariant, so go via StrictBind
+ -- establish Note [Nested binding invariants], so go via StrictBind
-- If not, the invariant holds already, and it's optional.
-- (FromBeta Lifted) or FromLet: look at the demand info
@@ -2857,7 +2857,7 @@ this transformation:
We treat the unlifted and lifted cases separately:
* Unlifted case: 'e' satisfies exprOkForSpeculation
- (ok-for-spec is needed to satisfy the let-can-float invariant).
+ (ok-for-spec is needed to satisfy Note [Nested binding invariants].
This turns case a +# b of r -> ...r...
into let r = a +# b in ...r...
and thence .....(a +# b)....
@@ -3112,7 +3112,7 @@ rebuildCase env scrut case_bndr alts cont
assert (null bs) $
do { (floats1, env') <- simplAuxBind "rebuildCase" env case_bndr case_bndr_rhs
-- scrut is a constructor application,
- -- hence satisfies let-can-float invariant
+ -- hence satisfies Note [Nested binding invariants]
; (floats2, expr') <- simplExprF env' rhs cont
; case wfloats of
[] -> return (floats1 `addFloats` floats2, expr')
@@ -3624,11 +3624,11 @@ We pin on a (OtherCon []) unfolding to the case-binder of a Case,
even though it'll be over-ridden in every case alternative with a more
informative unfolding. Why? Because suppose a later, less clever, pass
simply replaces all occurrences of the case binder with the binder itself;
-then Lint may complain about the let-can-float invariant. Example
+then Lint may complain about failing Note [Nested binding invariants]. Example
case e of b { DEFAULT -> let v = reallyUnsafePtrEquality# b y in ....
; K -> blah }
-The let-can-float invariant requires that y is evaluated in the call to
+Note [Nested binding invariants] requires that y is evaluated in the call to
reallyUnsafePtrEquality#, which it is. But we still want that to be true if we
propagate binders to occurrences.
@@ -3732,7 +3732,8 @@ knownCon env scrut dc_floats dc dc_ty_args dc_args bndr bs rhs cont
-- occur in the RHS; and simplAuxBind may therefore discard it.
-- Nevertheless we must keep it if the case-binder is alive,
-- because it may be used in the con_app. See Note [knownCon occ info]
- ; (floats1, env2) <- simplAuxBind "knownCon" env' b' arg -- arg satisfies let-can-float invariant
+ -- NB: arg satisfies Note [Nested binding invariants]
+ ; (floats1, env2) <- simplAuxBind "knownCon" env' b' arg
; (floats2, env3) <- bind_args env2 bs' args
; return (floats1 `addFloats` floats2, env3) }
=====================================
compiler/GHC/Core/Opt/Simplify/Utils.hs
=====================================
@@ -1491,8 +1491,8 @@ preInlineUnconditionally
:: SimplEnv -> TopLevelFlag -> InId
-> InExpr -> StaticEnv -- These two go together
-> Maybe SimplEnv -- Returned env has extended substitution
--- Precondition: rhs satisfies the let-can-float invariant
--- See Note [Core let-can-float invariant] in GHC.Core
+-- Precondition: rhs satisfies Note [Nested binding invariants]
+-- See Note [Nested binding invariants] in GHC.Core
-- Reason: we don't want to inline single uses, or discard dead bindings,
-- for unlifted, side-effect-ful bindings
preInlineUnconditionally env top_lvl bndr rhs rhs_env
@@ -1638,8 +1638,7 @@ postInlineUnconditionally
-> InId -> OutId -- The binder (*not* a CoVar), including its unfolding
-> OutExpr
-> Bool
--- Precondition: rhs satisfies the let-can-float invariant
--- See Note [Core let-can-float invariant] in GHC.Core
+-- Precondition: rhs satisfies Note [Nested binding invariants] in GHC.Core
-- Reason: we don't want to inline single uses, or discard dead bindings,
-- for unlifted, side-effect-ful bindings
postInlineUnconditionally env bind_cxt old_bndr bndr rhs
=====================================
compiler/GHC/Core/Opt/Specialise.hs
=====================================
@@ -1944,7 +1944,7 @@ case) do not float the binding itself unless it satisfies exprIsTopLevelBindable
This is conservative: maybe the RHS of `x` has a free var that would stop it
floating to top level anyway; but that is hard to spot (since we don't know what
the non-top-level in-scope binders are) and rare (since the binding must satisfy
-Note [Core let-can-float invariant] in GHC.Core).
+Note [Nested binding invariants] in GHC.Core).
Note [Specialising Calls]
=====================================
compiler/GHC/Core/SimpleOpt.hs
=====================================
@@ -381,7 +381,7 @@ simple_app env e0@(Lam {}) as0@(_:_)
-- See Note [Dark corner with representation polymorphism]
needsCaseBinding (idType b') (snd a)
-- This arg must not be inlined (side-effects) and cannot be let-bound,
- -- due to the let-can-float invariant. So simply case-bind it here.
+ -- due to Note [Nested binding invariants]. So simply case-bind it here.
, let a' = simple_opt_clo (soeInScope env) a
= mkDefaultCase a' b' $ do_beta env' body as
=====================================
compiler/GHC/Core/TyCo/FVs.hs
=====================================
@@ -350,7 +350,8 @@ deepTcvFolder = TyCoFolder { tcf_view = noView -- See Note [Free vars and synon
where
do_tcv is v = EndoOS do_it
where
- do_it acc | not (isLocalVar v) = acc
+ do_it acc | not (isLocalVar v) = acc -- A CoVar can be a GlobalId
+ -- See Note [Coercion bindings] in GHC.Core
| v `elemVarSet` is = acc
| v `elemVarSet` acc = acc
| otherwise = appEndoOS (deep_ty (varType v)) $
=====================================
compiler/GHC/Core/TyCo/Subst.hs
=====================================
@@ -1040,7 +1040,7 @@ substTyCoBndr subst (Named (Bndr tv vis)) = (subst', Named (Bndr tv' vis))
{- Note [Keeping the substitution empty]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A very common situation is where we run over a term doing no cloning,
-no substitution, nothing. In that case the TCvSubst till be empty, and
+no substitution, nothing. In that case the TCvSubst will be empty, and
it is /very/ valuable to /keep/ it empty:
* It's wasted effort to build up an identity substitution mapping
=====================================
compiler/GHC/Core/Utils.hs
=====================================
@@ -1813,13 +1813,11 @@ exprIsUnaryClassFun _ = False
-- See also Note [Classifying primop effects] in "GHC.Builtin.PrimOps"
-- and Note [Transformations affected by primop effects].
--
--- 'exprOkForSpeculation' is used to define Core's let-can-float
--- invariant. (See Note [Core let-can-float invariant] in
--- "GHC.Core".) It is therefore frequently called on arguments of
--- unlifted type, especially via 'needsCaseBinding'. But it is
--- sometimes called on expressions of lifted type as well. For
--- example, see Note [Speculative evaluation] in "GHC.CoreToStg.Prep".
-
+-- 'exprOkForSpeculation' is used in the definition of Note [Nested binding
+-- invariants]in GHC.Core. It is therefore frequently called on arguments of
+-- unlifted type, especially via 'needsCaseBinding'. But it is sometimes
+-- called on expressions of lifted type as well. For example, see
+-- Note [Speculative evaluation] in "GHC.CoreToStg.Prep".
exprOkForSpeculation, exprOkToDiscard :: CoreExpr -> Bool
exprOkForSpeculation = expr_ok fun_always_ok primOpOkForSpeculation
@@ -2044,12 +2042,14 @@ But we restrict it sharply:
; False -> e2 }
in ...) ...
- Does the RHS of v satisfy the let-can-float invariant? Previously we said
- yes, on the grounds that y is evaluated. But the binder-swap done
- by GHC.Core.Opt.SetLevels would transform the inner alternative to
+ Does the RHS of v satisfy Note [Nested binding invariants]?
+ Previously we said yes, on the grounds that y is evaluated. But the
+ binder-swap done by GHC.Core.Opt.SetLevels would transform the inner
+ alternative to
+
DEFAULT -> ... (let v::Int# = case x of { ... }
in ...) ....
- which does /not/ satisfy the let-can-float invariant, because x is
+ which does /not/ satisfy Note [Nested bindings invariants], because x is
not evaluated. See Note [Binder-swap during float-out]
in GHC.Core.Opt.SetLevels. To avoid this awkwardness it seems simpler
to stick to unlifted scrutinees where the issue does not
@@ -2134,7 +2134,7 @@ extremely useful for float-out, changes these expressions to
And now the expression does not obey the let-can-float invariant! Yikes!
Moreover we really might float (dataToTagLarge# x) outside the case,
-and then it really, really doesn't obey the let-can-float invariant.
+and then it really, really doesn't obey Note [Nested binding invariants].
The solution is simple: exprOkForSpeculation does not try to take
advantage of the evaluated-ness of (lifted) variables. And it returns
@@ -2144,7 +2144,8 @@ by marking the relevant primops as "ThrowsException" or
GHC.Builtin.PrimOps.
Note that exprIsHNF /can/ and does take advantage of evaluated-ness;
-it doesn't have the trickiness of the let-can-float invariant to worry about.
+it doesn't have the trickiness of Note [Nested binding invariants]
+to worry about.
************************************************************************
* *
=====================================
compiler/GHC/Stg/Lint.hs
=====================================
@@ -5,9 +5,8 @@ A lint pass to check basic STG invariants:
- Variables should be defined before used.
-- Let bindings should not have unboxed types (unboxed bindings should only
- appear in case), except when they're join points (see Note [Core let-can-float
- invariant] and #14117).
+- Let bindings: see Note [Core binding invariants] in GHC.Core.
+ (See #14117).
- If linting after unarisation, invariants listed in Note [Post-unarisation
invariants].
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b2ee16577b5bb5146bb48ab7156b84…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b2ee16577b5bb5146bb48ab7156b84…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Cheng Shao pushed new branch wip/remove-iserv at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/remove-iserv
You're receiving this email because of your account on gitlab.haskell.org.
1
0