-
9e7739ab
by Simon Jakobi at 2026-09-03T13:45:43-04:00
Add -Wimplicit-field-strictness (#16836)
This opt-in warning fires when a data constructor field lacks an
explicit strictness annotation (`!` or `~`). It complements the
LazyFieldAnnotations extension (4762a8bf30f) from GHC proposal 752,
which makes `~` annotations available for this purpose.
Deciding which fields to report requires their levity, so the check
runs after typechecking. To keep the noise down, the diagnostic is
emitted once per data declaration, grouped by constructor.
Closes #16836.
Assisted-by: Claude Fable 5
-
6a44d591
by mangoiv at 2026-09-03T13:46:22-04:00
simplifier: remove a bogus `assert` in `rebuild_app'` in `GHC.CoreToStg.Prep.cpeApp`.
Prior to this commit
commit 08bc245be70d95801bc1138804ed1de9474fbdc0
Author: sheaf <sam.derbyshire@gmail.com>
Date: Sat Feb 28 16:30:43 2026 +0100
Clean up join points, casts & ticks
This commit shores up the logic dealing with casts and ticks occurring
in between a join point binding and a jump
any `PlaceRuntime` ticks we observed were profiling ticks, even though that
isn't necessary.
The more liberal rules in the above commit allow e.g. breakpoint ticks
(which are valid PlaceRuntime ticks) to legitimately appear in an argument
position.
Fixes #27556
-
eaa95a6f
by Andrei Borzenkov at 2026-09-04T08:08:40-04:00
Parentheses in prefix GADT constructors (#27423)
Updated `splitLHsGadtTy` to allow looking
through the parentheses for inner binders. General example
of a code pattern that's allowed now:
data S a where
MkS :: (forall a. S a)
That should work now with any combination of nested
foralls and parentheses.
We don't perform parenthesis unwrapping for record
GADT constructors in accordance with GHC Proposal #402.
To this end `con_inner_bndrs` no longer stores plain forall
telescopes: `[HsForAllTelescope pass]` is replaced with
`[LHsGadtTelescope pass]`, a new `HsArg`-style type whose
`HsGadtForAll` holds an inner telescope and whose `HsGadtPar`
holds a pair of parentheses. The parentheses carry no meaning
for renaming or type checking; the only reason to record them
is exact-printing.
Updated `pprConDecl` to improve the `parse == parse . ppr . parse`
property of GADT pretty-printing.
The pretty printer can now output code that's similar to this:
data T a where
MkT1 :: (forall a. T a)
MkT2 :: forall . forall a. T a
These are special cases of inner forall binders
for prefix GADT constructors, when we have either
implicit or zero explicit outer binders.
-
639456a8
by Evgeny Malyshev at 2026-09-04T08:09:25-04:00
HsPat: Add spacing to unary tuple patterns
Use hsep when printing unary boxed TuplePat applications so that the
MkSolo constructor is separated from its argument. The old hcat rendered
wildcard and parenthesized arguments as MkSolo_ and MkSolo().
Add T27034 to exercise the HsPat splice-dump path with wildcard and
variable arguments, and update existing affected golden output.
Fixes #27034
Assisted-By: OpenAI Codex
-
2908ab36
by Simon Jakobi at 2026-09-05T07:22:17-04:00
X86 NCG: use btr/bts/btc for single-bit operations
Previously the Cmm patterns
x & ~(1 << i)
x | (1 << i)
x ^ (1 << i)
compiled to mov/shl/not/and-style sequences of 3-4 instructions. Now
they compile to a single btr, bts or btc, matching what C compilers
produce.
When the bit index is a literal, constant folding has already collapsed
these patterns into ones with a literal mask, such as
x & 0xfffffeffffffffff for x & ~(1 << 40). Such masks are now also
compiled to a bit-test instruction when they don't fit in an imm32 and
would otherwise have to be loaded into a register first.
For a variable bit index, this applies only when the shift is unchecked
(uncheckedShiftL#, Data.Bits.unsafeShiftL): the bounds-checked shiftL
used by e.g. the default clearBit/setBit/complementBit implementations
wraps the shift in a bounds mask that this optimisation does not see
through. With a literal index, the bounds mask is constant-folded away,
so the checked operations benefit too.
See Note [Bit-test instructions] in GHC.CmmToAsm.X86.CodeGen.
Fixes #25233.
Assisted-by: Claude Fable 5
-
c673ecf0
by Simon Peyton Jones at 2026-09-05T07:22:59-04:00
Move HsStatic free-var test to typechecker
A `static` form should have no free *term* variables, but it
can have free *type* variables. Alas, the renamer does not really know what
is a term variable and what is a type variable, because of required type
arguments. This patch moves the test to the typechecker, which does know.
Addresses #27664
-
5939ceaf
by sheaf at 2026-09-05T22:06:18-04:00
Windows: enforce path convention in ./configure
As detailed in Note [MSYS paths] in Hadrian.Utilities, the standing
convention (using Windows-style paths with forward slashes) is now
enforced in ./configure instead of within Hadrian, removing the need for
'cygpath' calls within Hadrian.
Fixes #26683
-
a6061455
by sheaf at 2026-09-05T22:06:18-04:00
Hadrian: introduce ExeSpawnPath
Specific details about the filepath used to specify the executable to
spawn with CreateProcess matters on Windows: whether we use forward or
backward slashes, a leading ./, or an absolute path changes how the
executable is found.
This commit introduces 'ExeSpawnPath' which is a path that is guaranteed
to be found when spawning a process. All command invocations now go
through this type to ensure the path has been properly sanitised.
See Note [NeedCurrentDirectoryForExePath] in Hadrian.Utilities.
The same treatment is applied to hsc2hs. Updates hsc2hs submodule.
-
e28313e3
by sheaf at 2026-09-05T22:07:06-04:00
Preserve tick ordering in 'tickTickedExpr'
'GHC.Core.Utils.tickTickedExpr' tries to combine a tick 't1' into an
existing stack of ticks 't2s'. There are two situations:
1. 't1' is subsumed by a tick in 't2s': drop it.
2. A tick in 't2s' is subsumed by 't1', say 't2'.
This commit ensures that in case (2) we keep 't1' on the outside instead
of replacing 't2' at its position in the stack. This avoids re-ordering
source notes (which was the cause of #27749).
This fixes a regression introduced in 2dadf3b0d05.
Fixes #27749
-
3172f557
by sheaf at 2026-09-05T22:07:06-04:00
Consistently prefer local source note ticks
GHC.Cmm.DebugBlock.cmmDebugGen (DWARF annotations) and
GHC.Stg.Debug.quickSourcePos (-finfo-table-map) both contained logic to
prioritise source note ticks from the current module.
This commit commons up this logic and propagates it to a third consumer:
IPE stack frames, in GHC.Driver.GenerateCgIPEStub.
See the new function GHC.Types.Tickish.bestSourceNote.
-
f45a3d8e
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA Fix HsCmdDo exact print with comments
Exact printing of HsCmdDo was ignoring the location for the do
statements, and this is an annotation that can have comments in it.
Update it so we print the statements as a unit, including any
comments.
Also add the result of auditing that we capture comments in all needed
places, noting that the remaining Anno SrcSpan instances are benign.
-
76142384
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Remove ListBanana / ListParens from AnnListBrackets
-
adebb4c3
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Tidy up mkHsDoPv, take AnnList directly
And some extra stuff by accident.
The main goal is to slim down AnnListBrackets to just have braces or
none.
This makes it clear that it serves only for lists which may have layout,
and opens the route to use EpLayout instead of AnnListBrackets
-
6dfeb43b
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Add specific layout field to AnnList
-
89e099d9
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Use EpaLocation in EpVirtualBraces
reword:
EPA Use vocurly as basis for AnnListLayout
For the existing cases that populate AnnList.
This also shows up AnnList usages that can never capture layout.
-
3ff885dc
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Use vocurly as basis for AnnListLayout
For the existing cases that populate AnnList.
This also shows up AnnList usages that can never capture layout.
-
af60528c
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: AnnList clean up patch for empty where clause
-
5f719dda
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Add TTG fields to FamilyInfo
This commit is a simple add, with unused extension fields.
It lays the groundwork for using them for exact print annotations
-
7ff7f999
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
WIP annclassdecl
-
f93cb716
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Update AnnClsInstDecl to contain AnnList
It was already separately tracking the '{', '}' and leading ';' values.
This aligns it with layout-introducing parser productions ('vocurly'),
so the layout processing can be handled uniformly
-
e7ea8380
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Tidy up markAnnListA'
It takes an action which can modify the AnnList, but this
is never used. So remove it.
-
80f59a7a
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Use AnnList for GADT declarations
-
6e3c72a1
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Use AnnList in AnnClassDecl
-
b29db705
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
MOVE EPA: Plan for Fixing AnnList Layout Properly
-
2daa0530
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make local binds located
Use LHsLocalBinds instead of HsLocalBinds
This reverses an earlier change, and brings processing of local binds
into alignement with the exact printing principle that the LocatedA
contents provide the location and extent of the enclosed item,
together with any comments or context-specific trailing items like
commas or semi colons.
The internal TTG extension points only carry exact print annotations
related to printing the item within its bounds.
This change brings back the problem of EmptyLocalBinds, which by
definition cannot have a location. These get a noSrcSpan location,
which is ignored in the exact printing process.
-
2c546f04
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Use AnnList in HsMultiIf
It introduces layout, capture it
-
ab087fa8
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Use AnnList in DecBrl
-
dc872134
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Replace AnnListLayout / AnnListBrackets with EpLayout
-
d550dc6a
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
WIP: setLayoutBoth inside markAnnListA
Current problem is it is a global one-shot, and MG has one too
Check: is it needed?
if so, honouring EpLayout may be needed
-
bbc67403
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA some tests for layout. WIP
-
67537721
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
Exactprint layout scope plan. Do not commit
-
c0946828
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: tidy up a bit. Combine somewhere else
-
a35b92dc
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Introduce LayoutFrame stacks in ExactPrint state
-
45c275a6
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
Align with ghc-exactprint
-
1f28d3a4
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Fix AnnList leading semis when layout
When there is layout, anything printed triggers it, including leading
semis.
Add some test case examples too
-
c61c324c
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
Exactprint: tidy up layout capturing
-
c94fdd03
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: add makeDelta test for Test20297
The original #20297 related to comment placement for exact printing
after running ExactPrint.makeDelta on ParsedSource. Add an additional
test that explicitly tests this.
-
74810f98
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make ValBinds LocatedA in HsLocalBindsLR
If we have items with an AnnList Annotation, as part of another, which
has different content, it must be LocatedA. This is a technical requirement
due to the way comment allocation happens during the makeDelta processing.
Comments are queued for printing, and as soon as any non-comment is to
be printed, the pending comments before that position are printed, and
in makeDelta processing these attached as preceding comments to the thing
just printed.
The means they end up captured inside the layout region of the AnnList item.
So for
foo = x
where -- comment
x = 3
the comment ends up as a preceding comment of `x = 3`, inside the
layout, and prints as
foo = x
where
-- comment
x = 3
-
6aca187e
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make IPBinds LocatedA
-
0cbbc55e
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make ClsInstDecl decls LocatedA
-
6ce472a8
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make ClassDecls decls LocatedA
-
7adca850
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make ClosedTypeFamily equations Located
For FamilyDecl/ClosedTypeFamily
-
e2c9d054
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make dd_cons located
-
f8eb7e54
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make HsMultiIf options located
-
cdb8319b
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Make DecBrl contents LocatedA
-
e6b5c2d1
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Located do statements
-
b566eb65
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: Print RecStmt located
-
217582a8
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
EPA: HsCmdDo Located
-
8b59e4bc
by Alan Zimmerman at 2026-09-06T09:49:56+01:00
Extend Test20297 for additional occurrences
-
90b31287
by Alan Zimmerman at 2026-09-06T09:49:57+01:00
Plan update DO NOT COMMIT
-
a2e7d9ca
by Alan Zimmerman at 2026-09-06T09:49:57+01:00
EPA: First pass implementation of HsList, for ClassDecls
Just as a straight list replacement to start with, no payload.
This shows the scope and invasiveness of the initial change
-
e03b1abb
by Alan Zimmerman at 2026-09-06T09:49:57+01:00
EPA: HsList attempt WIP
-
336f202c
by Alan Zimmerman at 2026-09-06T09:49:57+01:00
Enable ppr test for Haddock1. It currently fails
-
dae5b367
by Alan Zimmerman at 2026-09-06T09:49:57+01:00
WIP on removing NoEpAnn. Likely abandon
-
0e809028
by Alan Zimmerman at 2026-09-06T09:49:57+01:00
EPA: Add an overview doc for exact printing
-
3f02194b
by Simon Peyton Jones at 2026-09-06T09:49:57+01:00
Added an intro section