25 Jun '26
Andreas Klebinger pushed new branch wip/andreask/arm-ffi at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/arm-ffi
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/sol/reexported-error-message-refactor] Refactoring: De-obfuscate `GHC.Unit.State.ModuleOrigin.fromOrigUnit`
by Simon Hengel (@sol) 25 Jun '26
by Simon Hengel (@sol) 25 Jun '26
25 Jun '26
Simon Hengel pushed to branch wip/sol/reexported-error-message-refactor at Glasgow Haskell Compiler / GHC
Commits:
20f99256 by Simon Hengel at 2026-06-25T14:38:06+07:00
Refactoring: De-obfuscate `GHC.Unit.State.ModuleOrigin.fromOrigUnit`
(by using a proper data type instead of `Maybe Bool`)
(see #27417)
- - - - -
3 changed files:
- compiler/GHC/Iface/Errors/Ppr.hs
- compiler/GHC/Unit/State.hs
- utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
Changes:
=====================================
compiler/GHC/Iface/Errors/Ppr.hs
=====================================
@@ -205,7 +205,7 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
provenance (ModOrigin{ fromOrigUnit = e,
fromExposedReexport = res,
fromPackageFlag = f })
- | Just True <- e
+ | AvailableFromExposedPackage <- e
= parens (text "from" <+> ppr (moduleUnit mod))
| f && moduleName mod == m
= parens (text "from" <+> ppr (moduleUnit mod))
@@ -221,7 +221,7 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
provenance (ModUnusable _) = empty
provenance (ModOrigin{ fromOrigUnit = e,
fromHiddenReexport = rhs })
- | Just False <- e
+ | AvailableFromHiddenPackage <- e
= parens (text "needs flag -package-id"
<+> ppr (moduleUnit mod))
| (pkg:_) <- rhs
@@ -240,7 +240,7 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
-> vcat (map pprMod mods)
where
unambiguousPackages = foldl' unambiguousPackage (Just []) mods
- unambiguousPackage (Just xs) (m, ModOrigin (Just _) _ _ _)
+ unambiguousPackage (Just xs) (m, ModOrigin ((/= Renamed) -> True) _ _ _)
= Just (moduleUnit m : xs)
unambiguousPackage _ _ = Nothing
GenericMissing pkg_hiddens mod_hiddens unusables files ->
@@ -254,7 +254,7 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
pprOrigin _ ModHidden = panic "cantFindErr: bound by mod hidden"
pprOrigin _ (ModUnusable _) = panic "cantFindErr: bound by mod unusable"
pprOrigin m (ModOrigin e res _ f) = sep $ punctuate comma (
- if e == Just True
+ if e == AvailableFromExposedPackage
then [text "package" <+> ppr (moduleUnit m)]
else [] ++
map ((text "a reexport in package" <+>)
=====================================
compiler/GHC/Unit/State.hs
=====================================
@@ -38,6 +38,7 @@ module GHC.Unit.State (
LookupResult(..),
ModuleSuggestion(..),
ModuleOrigin(..),
+ AvailableFromOriginalUnit(..),
UnusableUnit(..),
UnusableUnitReason(..),
pprReason,
@@ -178,11 +179,7 @@ data ModuleOrigin =
-- | Module is public, and could have come from some places.
| ModOrigin {
- -- | @Just False@ means that this module is in
- -- someone's @exported-modules@ list, but that package is hidden;
- -- @Just True@ means that it is available; @Nothing@ means neither
- -- applies.
- fromOrigUnit :: Maybe Bool
+ fromOrigUnit :: AvailableFromOriginalUnit
-- | Is the module available from a reexport of an exposed package?
-- There could be multiple.
, fromExposedReexport :: [UnitInfo]
@@ -193,6 +190,15 @@ data ModuleOrigin =
, fromPackageFlag :: Bool
}
+data AvailableFromOriginalUnit =
+ -- | the canonical module name is different from the requested name
+ Renamed
+ -- | the module is in someone's @exposed-modules@ list, but that package is hidden
+ | AvailableFromHiddenPackage
+ -- | the module is available from the original unit under the requested name
+ | AvailableFromExposedPackage
+ deriving (Eq, Show)
+
-- | A unusable unit module origin
data UnusableUnit = UnusableUnit
{ uuUnit :: !Unit -- ^ Unusable unit
@@ -205,9 +211,9 @@ instance Outputable ModuleOrigin where
ppr (ModUnusable _) = text "unusable module"
ppr (ModOrigin e res rhs f) = sep (punctuate comma (
(case e of
- Nothing -> []
- Just False -> [text "hidden package"]
- Just True -> [text "exposed package"]) ++
+ Renamed -> []
+ AvailableFromHiddenPackage -> [text "hidden package"]
+ AvailableFromExposedPackage -> [text "exposed package"]) ++
(if null res
then []
else [text "reexport by" <+>
@@ -222,34 +228,36 @@ instance Outputable ModuleOrigin where
-- | Smart constructor for a module which is in @exposed-modules@. Takes
-- as an argument whether or not the defining package is exposed.
fromExposedModules :: Bool -> ModuleOrigin
-fromExposedModules e = ModOrigin (Just e) [] [] False
+fromExposedModules True = ModOrigin AvailableFromExposedPackage [] [] False
+fromExposedModules False = ModOrigin AvailableFromHiddenPackage [] [] False
-- | Smart constructor for a module which is in @reexported-modules@. Takes
-- as an argument whether or not the reexporting package is exposed, and
-- also its 'UnitInfo'.
fromReexportedModules :: Bool -> UnitInfo -> ModuleOrigin
-fromReexportedModules True pkg = ModOrigin Nothing [pkg] [] False
-fromReexportedModules False pkg = ModOrigin Nothing [] [pkg] False
+fromReexportedModules True pkg = ModOrigin Renamed [pkg] [] False
+fromReexportedModules False pkg = ModOrigin Renamed [] [pkg] False
-- | Smart constructor for a module which was bound by a package flag.
fromFlag :: ModuleOrigin
-fromFlag = ModOrigin Nothing [] [] True
+fromFlag = ModOrigin Renamed [] [] True
instance Semigroup ModuleOrigin where
x@(ModOrigin e res rhs f) <> y@(ModOrigin e' res' rhs' f') =
ModOrigin (g e e') (res ++ res') (rhs ++ rhs') (f || f')
- where g (Just b) (Just b')
- | b == b' = Just b
- | otherwise = pprPanic "ModOrigin: package both exposed/hidden" $
+ where
+ g AvailableFromHiddenPackage AvailableFromHiddenPackage = AvailableFromHiddenPackage
+ g AvailableFromExposedPackage AvailableFromExposedPackage = AvailableFromExposedPackage
+ g Renamed x = x
+ g x Renamed = x
+ g _ _ = pprPanic "ModOrigin: package both exposed/hidden" $
text "x: " <> ppr x $$ text "y: " <> ppr y
- g Nothing x = x
- g x Nothing = x
x <> y = pprPanic "ModOrigin: module origin mismatch" $
text "x: " <> ppr x $$ text "y: " <> ppr y
instance Monoid ModuleOrigin where
- mempty = ModOrigin Nothing [] [] False
+ mempty = ModOrigin Renamed [] [] False
mappend = (Semigroup.<>)
-- | Is the name from the import actually visible? (i.e. does it cause
@@ -257,12 +265,12 @@ instance Monoid ModuleOrigin where
originVisible :: ModuleOrigin -> Bool
originVisible ModHidden = False
originVisible (ModUnusable _) = False
-originVisible (ModOrigin b res _ f) = b == Just True || not (null res) || f
+originVisible (ModOrigin b res _ f) = b == AvailableFromExposedPackage || not (null res) || f
-- | Are there actually no providers for this module? This will never occur
-- except when we're filtering based on package imports.
originEmpty :: ModuleOrigin -> Bool
-originEmpty (ModOrigin Nothing [] [] False) = True
+originEmpty (ModOrigin Renamed [] [] False) = True
originEmpty _ = False
-- | 'UniqFM' map from 'Unit' to a 'UnitVisibility'.
@@ -586,7 +594,7 @@ resolvePackageImport unit_st mn pn = do
to_uid (mod, ModOrigin mo re_exps _ _) =
case mo of
-- Available directly, but also potentially from re-exports
- Just True -> (toUnitId (moduleUnit mod)) : map unitId re_exps
+ AvailableFromExposedPackage -> (toUnitId (moduleUnit mod)) : map unitId re_exps
-- Just available from these re-exports
_ -> map unitId re_exps
to_uid _ = []
@@ -1932,8 +1940,7 @@ lookupModulePackage pkgs mn mfs =
case origin of
ModOrigin {fromOrigUnit, fromExposedReexport} ->
case fromOrigUnit of
- -- Just True means, the import is available from its original location
- Just True ->
+ AvailableFromExposedPackage ->
pure [orig_unit]
-- Otherwise, it must be available from a reexport
_ -> pure fromExposedReexport
@@ -1974,19 +1981,21 @@ lookupModuleWithSuggestions' pkgs mod_map name mb_pn
-> (hidden_pkg, x:hidden_mod, unusable, exposed)
ModUnusable _
-> (hidden_pkg, hidden_mod, x:unusable, exposed)
- ModOrigin { fromOrigUnit = origAvailableUnderSameName, fromHiddenReexport }
+ ModOrigin { fromOrigUnit, fromHiddenReexport }
| originEmpty origin
-> (hidden_pkg, hidden_mod, unusable, exposed)
| originVisible origin
-> (hidden_pkg, hidden_mod, unusable, x:exposed)
| otherwise
- -> (reexports ++ maybe id (:) origUnit hidden_pkg, hidden_mod, unusable, exposed)
+ -> (reexports ++ maybe id (:) hiddenOrigUnit hidden_pkg, hidden_mod, unusable, exposed)
where
reexports :: [UnitInfo]
reexports = sortOn unitId fromHiddenReexport
- origUnit :: Maybe UnitInfo
- origUnit = origAvailableUnderSameName >> lookupUnit pkgs (moduleUnit m)
+ hiddenOrigUnit :: Maybe UnitInfo
+ hiddenOrigUnit = case fromOrigUnit of
+ AvailableFromHiddenPackage -> lookupUnit pkgs (moduleUnit m)
+ _ -> Nothing
unit_lookup p = lookupUnit pkgs p `orElse` pprPanic "lookupModuleWithSuggestions" (ppr p <+> ppr name)
mod_unit = unit_lookup . moduleUnit
@@ -2012,7 +2021,7 @@ lookupModuleWithSuggestions' pkgs mod_map name mb_pn
ModOrigin { fromOrigUnit = e, fromExposedReexport = res,
fromHiddenReexport = rhs }
-> ModOrigin
- { fromOrigUnit = if match_pkg pkg then e else Nothing
+ { fromOrigUnit = if match_pkg pkg then e else Renamed
, fromExposedReexport = filter match_pkg res
, fromHiddenReexport = filter match_pkg rhs
, fromPackageFlag = False -- always excluded
=====================================
utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
=====================================
@@ -85,7 +85,7 @@ attachInstances expInfo ifaces instIfaceMap isOneShot = do
}
) <-
nonDetUniqMapToList mod_map
- , fromOrig == Just True || not (null reExp)
+ , fromOrig == AvailableFromExposedPackage || not (null reExp)
]
mods_to_load = moduleSetElts mods
-- We need to ensure orphans in modules outside of this package are included.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20f992561f19abb824b52ccd7ec02cf…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20f992561f19abb824b52ccd7ec02cf…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/sol/reexported-error-message-refactor] Refactoring: De-obfuscate `GHC.Unit.State.ModuleOrigin.fromOrigUnit`
by Simon Hengel (@sol) 25 Jun '26
by Simon Hengel (@sol) 25 Jun '26
25 Jun '26
Simon Hengel pushed to branch wip/sol/reexported-error-message-refactor at Glasgow Haskell Compiler / GHC
Commits:
3bf644b8 by Simon Hengel at 2026-06-25T14:27:28+07:00
Refactoring: De-obfuscate `GHC.Unit.State.ModuleOrigin.fromOrigUnit`
(by using a proper data type instead of `Maybe Bool`)
(see #27417)
- - - - -
3 changed files:
- compiler/GHC/Iface/Errors/Ppr.hs
- compiler/GHC/Unit/State.hs
- utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
Changes:
=====================================
compiler/GHC/Iface/Errors/Ppr.hs
=====================================
@@ -205,7 +205,7 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
provenance (ModOrigin{ fromOrigUnit = e,
fromExposedReexport = res,
fromPackageFlag = f })
- | Just True <- e
+ | AvailableFromExposedUnit <- e
= parens (text "from" <+> ppr (moduleUnit mod))
| f && moduleName mod == m
= parens (text "from" <+> ppr (moduleUnit mod))
@@ -221,7 +221,7 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
provenance (ModUnusable _) = empty
provenance (ModOrigin{ fromOrigUnit = e,
fromHiddenReexport = rhs })
- | Just False <- e
+ | AvailableFromHiddenUnit <- e
= parens (text "needs flag -package-id"
<+> ppr (moduleUnit mod))
| (pkg:_) <- rhs
@@ -240,7 +240,7 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
-> vcat (map pprMod mods)
where
unambiguousPackages = foldl' unambiguousPackage (Just []) mods
- unambiguousPackage (Just xs) (m, ModOrigin (Just _) _ _ _)
+ unambiguousPackage (Just xs) (m, ModOrigin ((/= Renamed) -> True) _ _ _)
= Just (moduleUnit m : xs)
unambiguousPackage _ _ = Nothing
GenericMissing pkg_hiddens mod_hiddens unusables files ->
@@ -254,7 +254,7 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
pprOrigin _ ModHidden = panic "cantFindErr: bound by mod hidden"
pprOrigin _ (ModUnusable _) = panic "cantFindErr: bound by mod unusable"
pprOrigin m (ModOrigin e res _ f) = sep $ punctuate comma (
- if e == Just True
+ if e == AvailableFromExposedUnit
then [text "package" <+> ppr (moduleUnit m)]
else [] ++
map ((text "a reexport in package" <+>)
=====================================
compiler/GHC/Unit/State.hs
=====================================
@@ -38,6 +38,7 @@ module GHC.Unit.State (
LookupResult(..),
ModuleSuggestion(..),
ModuleOrigin(..),
+ AvailableFromOriginalUnit(..),
UnusableUnit(..),
UnusableUnitReason(..),
pprReason,
@@ -178,21 +179,26 @@ data ModuleOrigin =
-- | Module is public, and could have come from some places.
| ModOrigin {
- -- | @Just False@ means that this module is in
- -- someone's @exported-modules@ list, but that package is hidden;
- -- @Just True@ means that it is available; @Nothing@ means neither
- -- applies.
- fromOrigUnit :: Maybe Bool
+ fromOrigUnit :: AvailableFromOriginalUnit
-- | Is the module available from a reexport of an exposed package?
-- There could be multiple.
, fromExposedReexport :: [UnitInfo]
- -- | Is the module available from a reexport of a hidden package?
+ -- | Is the module available from a reexport of a hidden unit?
, fromHiddenReexport :: [UnitInfo]
-- | Did the module export come from a package flag? (ToDo: track
-- more information.
, fromPackageFlag :: Bool
}
+data AvailableFromOriginalUnit =
+ -- | the canonical module name is different from the requested name
+ Renamed
+ -- | the module is in someone's @exposed-modules@ list, but that unit is hidden
+ | AvailableFromHiddenUnit
+ -- | the module is available from the original unit under the requested name
+ | AvailableFromExposedUnit
+ deriving (Eq, Show)
+
-- | A unusable unit module origin
data UnusableUnit = UnusableUnit
{ uuUnit :: !Unit -- ^ Unusable unit
@@ -205,9 +211,9 @@ instance Outputable ModuleOrigin where
ppr (ModUnusable _) = text "unusable module"
ppr (ModOrigin e res rhs f) = sep (punctuate comma (
(case e of
- Nothing -> []
- Just False -> [text "hidden package"]
- Just True -> [text "exposed package"]) ++
+ Renamed -> []
+ AvailableFromHiddenUnit -> [text "hidden package"]
+ AvailableFromExposedUnit -> [text "exposed package"]) ++
(if null res
then []
else [text "reexport by" <+>
@@ -222,34 +228,36 @@ instance Outputable ModuleOrigin where
-- | Smart constructor for a module which is in @exposed-modules@. Takes
-- as an argument whether or not the defining package is exposed.
fromExposedModules :: Bool -> ModuleOrigin
-fromExposedModules e = ModOrigin (Just e) [] [] False
+fromExposedModules True = ModOrigin AvailableFromExposedUnit [] [] False
+fromExposedModules False = ModOrigin AvailableFromHiddenUnit [] [] False
-- | Smart constructor for a module which is in @reexported-modules@. Takes
-- as an argument whether or not the reexporting package is exposed, and
-- also its 'UnitInfo'.
fromReexportedModules :: Bool -> UnitInfo -> ModuleOrigin
-fromReexportedModules True pkg = ModOrigin Nothing [pkg] [] False
-fromReexportedModules False pkg = ModOrigin Nothing [] [pkg] False
+fromReexportedModules True pkg = ModOrigin Renamed [pkg] [] False
+fromReexportedModules False pkg = ModOrigin Renamed [] [pkg] False
-- | Smart constructor for a module which was bound by a package flag.
fromFlag :: ModuleOrigin
-fromFlag = ModOrigin Nothing [] [] True
+fromFlag = ModOrigin Renamed [] [] True
instance Semigroup ModuleOrigin where
x@(ModOrigin e res rhs f) <> y@(ModOrigin e' res' rhs' f') =
ModOrigin (g e e') (res ++ res') (rhs ++ rhs') (f || f')
- where g (Just b) (Just b')
- | b == b' = Just b
- | otherwise = pprPanic "ModOrigin: package both exposed/hidden" $
+ where
+ g AvailableFromHiddenUnit AvailableFromHiddenUnit = AvailableFromHiddenUnit
+ g AvailableFromExposedUnit AvailableFromExposedUnit = AvailableFromExposedUnit
+ g Renamed x = x
+ g x Renamed = x
+ g _ _ = pprPanic "ModOrigin: package both exposed/hidden" $
text "x: " <> ppr x $$ text "y: " <> ppr y
- g Nothing x = x
- g x Nothing = x
x <> y = pprPanic "ModOrigin: module origin mismatch" $
text "x: " <> ppr x $$ text "y: " <> ppr y
instance Monoid ModuleOrigin where
- mempty = ModOrigin Nothing [] [] False
+ mempty = ModOrigin Renamed [] [] False
mappend = (Semigroup.<>)
-- | Is the name from the import actually visible? (i.e. does it cause
@@ -257,12 +265,12 @@ instance Monoid ModuleOrigin where
originVisible :: ModuleOrigin -> Bool
originVisible ModHidden = False
originVisible (ModUnusable _) = False
-originVisible (ModOrigin b res _ f) = b == Just True || not (null res) || f
+originVisible (ModOrigin b res _ f) = b == AvailableFromExposedUnit || not (null res) || f
-- | Are there actually no providers for this module? This will never occur
-- except when we're filtering based on package imports.
originEmpty :: ModuleOrigin -> Bool
-originEmpty (ModOrigin Nothing [] [] False) = True
+originEmpty (ModOrigin Renamed [] [] False) = True
originEmpty _ = False
-- | 'UniqFM' map from 'Unit' to a 'UnitVisibility'.
@@ -586,7 +594,7 @@ resolvePackageImport unit_st mn pn = do
to_uid (mod, ModOrigin mo re_exps _ _) =
case mo of
-- Available directly, but also potentially from re-exports
- Just True -> (toUnitId (moduleUnit mod)) : map unitId re_exps
+ AvailableFromExposedUnit -> (toUnitId (moduleUnit mod)) : map unitId re_exps
-- Just available from these re-exports
_ -> map unitId re_exps
to_uid _ = []
@@ -1932,8 +1940,7 @@ lookupModulePackage pkgs mn mfs =
case origin of
ModOrigin {fromOrigUnit, fromExposedReexport} ->
case fromOrigUnit of
- -- Just True means, the import is available from its original location
- Just True ->
+ AvailableFromExposedUnit ->
pure [orig_unit]
-- Otherwise, it must be available from a reexport
_ -> pure fromExposedReexport
@@ -1974,19 +1981,21 @@ lookupModuleWithSuggestions' pkgs mod_map name mb_pn
-> (hidden_pkg, x:hidden_mod, unusable, exposed)
ModUnusable _
-> (hidden_pkg, hidden_mod, x:unusable, exposed)
- ModOrigin { fromOrigUnit = origAvailableUnderSameName, fromHiddenReexport }
+ ModOrigin { fromOrigUnit, fromHiddenReexport }
| originEmpty origin
-> (hidden_pkg, hidden_mod, unusable, exposed)
| originVisible origin
-> (hidden_pkg, hidden_mod, unusable, x:exposed)
| otherwise
- -> (reexports ++ maybe id (:) origUnit hidden_pkg, hidden_mod, unusable, exposed)
+ -> (reexports ++ maybe id (:) hiddenOrigUnit hidden_pkg, hidden_mod, unusable, exposed)
where
reexports :: [UnitInfo]
reexports = sortOn unitId fromHiddenReexport
- origUnit :: Maybe UnitInfo
- origUnit = origAvailableUnderSameName >> lookupUnit pkgs (moduleUnit m)
+ hiddenOrigUnit :: Maybe UnitInfo
+ hiddenOrigUnit = case fromOrigUnit of
+ AvailableFromHiddenUnit -> lookupUnit pkgs (moduleUnit m)
+ _ -> Nothing
unit_lookup p = lookupUnit pkgs p `orElse` pprPanic "lookupModuleWithSuggestions" (ppr p <+> ppr name)
mod_unit = unit_lookup . moduleUnit
@@ -2012,7 +2021,7 @@ lookupModuleWithSuggestions' pkgs mod_map name mb_pn
ModOrigin { fromOrigUnit = e, fromExposedReexport = res,
fromHiddenReexport = rhs }
-> ModOrigin
- { fromOrigUnit = if match_pkg pkg then e else Nothing
+ { fromOrigUnit = if match_pkg pkg then e else Renamed
, fromExposedReexport = filter match_pkg res
, fromHiddenReexport = filter match_pkg rhs
, fromPackageFlag = False -- always excluded
=====================================
utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
=====================================
@@ -85,7 +85,7 @@ attachInstances expInfo ifaces instIfaceMap isOneShot = do
}
) <-
nonDetUniqMapToList mod_map
- , fromOrig == Just True || not (null reExp)
+ , fromOrig == AvailableFromExposedPackage || not (null reExp)
]
mods_to_load = moduleSetElts mods
-- We need to ensure orphans in modules outside of this package are included.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3bf644b86455e182d31f1c5770975e4…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3bf644b86455e182d31f1c5770975e4…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/sol/remove-ddump-json] 27 commits: Add missing req_interp modifier to T18441fail3 and T18441fail19
by Simon Hengel (@sol) 25 Jun '26
by Simon Hengel (@sol) 25 Jun '26
25 Jun '26
Simon Hengel pushed to branch wip/sol/remove-ddump-json at Glasgow Haskell Compiler / GHC
Commits:
09326ca6 by Matthew Pickering at 2026-06-20T23:41:12+02:00
Add missing req_interp modifier to T18441fail3 and T18441fail19
These tests require the interpreter but they were failing in a different
way with the javascript backend because the interpreter was disabled and
stderr is ignored by the test.
- - - - -
521e55bf by Matthew Pickering at 2026-06-20T23:41:13+02:00
hadrian: Fill in more of the default.host toolchain file
When you are building a cross compiler this file will be used to build
stage1 and it's libraries, so we need enough information here to work
accurately. There is still more work to be done (see for example, word
size is still fixed).
- - - - -
23c9b6c3 by Matthew Pickering at 2026-06-20T23:42:52+02:00
hadrian: Build stage 2 cross compilers
* Most of hadrian is abstracted over the stage in order to remove the
assumption that the target of all stages is the same platform. This
allows the RTS to be built for two different targets for example.
* Abstracts the bindist creation logic to allow building either normal
or cross bindists. Normal bindists use stage 1 libraries and a stage 2
compiler. Cross bindists use stage 2 libararies and a stage 2
compiler.
* hadrian: Make binary-dist-dir the default build target. This allows us
to have the logic in one place about which libraries/stages to build
with cross compilers. Fixes #24192
New hadrian target:
* `binary-dist-dir-cross`: Build a cross compiler bindist (compiler =
stage 1, libraries = stage 2)
This commit also contains various changes to make stage2 compilers
feasible.
-------------------------
Metric Decrease:
LinkableUsage02
ManyAlternatives
ManyConstructors
MultiComponentModulesRecomp
MultiLayerModulesRecomp
RecordUpdPerf
T10421
T12150
T12227
T12425
T12707
T13035
T13379
T13820
T15703
T16577
T18140
T18282
T18698a
T18698b
T18923
T1969
T20049
T21839c
T3294
T4801
T5030
T5321FD
T5321Fun
T5631
T5642
T6048
T783
T9020
T9198
T9233
T9630
T9872d
T9961
parsing001
T3064
Metric Increase:
T26989
hard_hole_fits
-------------------------
Co-authored-by: Sven Tennie <sven.tennie(a)gmail.com>
- - - - -
26fed8ab by Matthew Pickering at 2026-06-20T23:42:52+02:00
ci: Test cross bindists
We remove the special logic for testing in-tree cross
compilers and instead test cross compiler bindists, like we do for all
other platforms.
- - - - -
80c8910e by Matthew Pickering at 2026-06-20T23:42:52+02:00
ci: Introduce CROSS_STAGE variable
In preparation for building and testing stage3 bindists we introduce the
CROSS_STAGE variable which is used by a CI job to determine what kind of
bindist the CI job should produce.
At the moment we are only using CROSS_STAGE=2 but in the future we will
have some jobs which set CROSS_STAGE=3 to produce native bindists for a
target, but produced by a cross compiler, which can be tested on by
another CI job on the native platform.
CROSS_STAGE=2: Build a normal cross compiler bindist
CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target
- - - - -
8215573d by Sven Tennie at 2026-06-20T23:42:52+02:00
ci: Increase timeout for emulators
Test runs with emulators naturally take longer than on native machines.
Generate jobs.yml
- - - - -
5acb7dbc by Matthew Pickering at 2026-06-20T23:42:52+02:00
ci: Javascript don't set CROSS_EMULATOR
There is no CROSS_EMULATOR needed to run javascript binaries, so we
don't set the CROSS_EMULATOR to some dummy value.
- - - - -
48345343 by Sven Tennie at 2026-06-20T23:42:52+02:00
Javascript skip T23697
See #22355 about how HSC2HS and the Javascript target don't play well
together.
- - - - -
5e44fd05 by Sven Tennie at 2026-06-20T23:42:52+02:00
Mark T24602 as fragile
It was skipped before (due to CROSS_EMULATOR being set, which changed
for JS), so we don't make things worse by marking it as fragile.
- - - - -
ab349ec2 by Sven Tennie at 2026-06-20T23:42:52+02:00
Fix T22744 for GHCJS
In fact, this test needs Template Haskell, not necessarily an
interpreter.
- - - - -
c73352d8 by Sven Tennie at 2026-06-20T23:42:52+02:00
haddock-test: fix GHCJS haddock test failures
Add --ghc-pkg-path flag support so haddock test runner can find
cross-prefixed ghc-pkg (e.g. javascript-unknown-ghcjs-ghc-pkg) which
is not on $PATH in cross install directories.
Skip haddockHtmlTest on GHCJS: Threaded.hs uses forkOS in a TH splice,
which GHCJS RTS doesn't support. Mark with js_skip in all.T.
- - - - -
5e814e76 by Andreas Klebinger at 2026-06-22T23:00:24-04:00
compiler: Deduplicate hscTidy
This function was accidentally duplicated during a refactor.
Fixes #27351
- - - - -
473b97eb by sheaf at 2026-06-22T23:01:22-04:00
Avoid mkTick in Core Prep breaking ANF (part II)
Hotfix for 2f9579765f55b3920ceb2e04995ff41a9d0e2d4e fixing a small
oversight in the call to tickTickedExpr from mkTick, in which we
improperly recursively called mkTick without passing on the preserve_anf
flag.
Fixes #27386
- - - - -
9284a1f7 by Simon Hengel at 2026-06-23T05:55:33-04:00
Don't use global variables to address concurrency bugs! (fixes #27234)
This was originally introduce with
88f38b03025386f0f1e8f5861eed67d80495168a to address #17922.
In this specific case a better fix would have been to synchronize on
stderr:
withHandle_ "stderrSupportsAnsiColors" stderr $ \ _ -> do
...
But apparently the dependency on `terminfo` was removed in
32ab07bf3d6ce45e8ea5b55e8095174a6b42a7f0, preventing #17922 in the first
place.
- - - - -
44309cd3 by Alan Zimmerman at 2026-06-23T05:56:20-04:00
EPA: remove LocatedL / SrcSpanAnnL and LocatedLI / SrcSpanAnnLI
This is part of a refactor towards only having LocatedA / SrcSpanAnnA
It removes the stated items, but has to add back one for BooleanFormula,
LocatedBF / SrcSpanAnnBF
This commit also use the HsConDetails RecCon extension point to
capture the braces in a record constructor
- - - - -
2f6a5534 by Simon Jakobi at 2026-06-23T15:46:20+02:00
Add -dstable-core-dump-order for stable Core dump ordering (#27296)
The order of top-level bindings in Core dumps (-ddump-simpl etc.) is the
compiler's Unique-sensitive internal processing order, so an unrelated
upstream change can reorder them and defeat a textual diff of two dumps.
This adds an opt-in flag -dstable-core-dump-order that reorders the
top-level bindings of dumps routed through dumpPassResult into a stable,
Unique-independent order, so two dumps line up across rebuilds. See
Note [Stable Core dump order] in GHC.Core.Ppr for the sort key and its
rationale.
Adds tests T27296 (binders GHC emits in non-source order by default,
asserted to come out stably ordered under the flag) and T27296b (an
untidied -ddump-float-out dump pinning the ordering of the anonymous lvl
floats by literal value).
Co-Authored-By: Claude Opus 4.8 <noreply(a)anthropic.com>
- - - - -
141986e3 by mangoiv at 2026-06-24T15:51:14-04:00
compiler: refactor error reporting code for ExplicitLevelImports
Refactors error reporting code for ExplicitLevelImports to pass in a
RdrName and a GlobalReaderElt to be able to report errors that are
faithful to the source and to more precisely distinguish between names
that are in scope from different qualifications.
Fixes #27385 and #26616
- - - - -
aa7df6b6 by Simon Hengel at 2026-06-24T15:52:18-04:00
Set GHC_VERSION when calling custom pre-processors (see #25952)
(so that pre-processors can emit backwards compatible code)
- - - - -
a9e494f2 by Simon Hengel at 2026-06-24T15:54:08-04:00
Add a flag to control GHCi specific error hints (close #27409)
- - - - -
a805b2a2 by Simon Hengel at 2026-06-24T15:55:20-04:00
Reference correct package in error messages for reexported modules
(fixes #27417)
- - - - -
1a615970 by Simon Hengel at 2026-06-25T12:56:30+07:00
Rename `MCDiagnostic` to `InternalMCDiagnostic`
`MCDiagnostic` is meant to be used for compiler diagnostics.
Any code that creates `MCDiagnostic` directly, without going through
`GHC.Driver.Errors.printMessage`, sidesteps `-fdiagnostics-as-json` (see
e.g. !14616, !14475, !14492 !14548).
To avoid this in the future, this change more narrowly controls who
creates `MCDiagnostic` (see #24113).
- - - - -
f97de206 by Simon Hengel at 2026-06-25T13:32:22+07:00
Remove -ddump-json (fixes #24113)
- - - - -
683c9e11 by Simon Hengel at 2026-06-25T13:37:07+07:00
Add SrcSpan to MCDiagnostic
- - - - -
25702e16 by Simon Hengel at 2026-06-25T13:41:14+07:00
Get rid of mkLocMessage
- - - - -
2b8e99fc by Simon Hengel at 2026-06-25T13:41:19+07:00
Add Message data type
- - - - -
cd12158f by Simon Hengel at 2026-06-25T13:48:27+07:00
Get rid of MessageClass
- - - - -
f8c5b274 by Simon Hengel at 2026-06-25T13:53:44+07:00
Remove JSON logging
- - - - -
261 changed files:
- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- + changelog.d/26616
- + changelog.d/T27386
- + changelog.d/interactive-error-hints
- + changelog.d/pp-set-ghc-version
- + changelog.d/reexported-module-errors
- + changelog.d/stable-core-dump-order-27296
- + changelog.d/stage2-cross-compilers
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/Monad.hs
- compiler/GHC/Core/Ppr.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Data/BooleanFormula.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Errors.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main/Interactive.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Main/Passes.hs-boot
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/Monad.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/Driver/Pipeline/LogQueue.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Stats.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Errors.hs
- compiler/GHC/Iface/Errors/Ppr.hs
- compiler/GHC/Iface/Errors/Types.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Linker/Deps.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Splice.hs-boot
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Runtime/Debugger.hs
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/SysTools/Tasks.hs
- compiler/GHC/SysTools/Terminal.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Utils/Backpack.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Error.hs
- − compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/SourceError.hs
- compiler/GHC/Unit/Finder.hs
- compiler/GHC/Unit/Finder/Types.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Utils/Error.hs
- compiler/GHC/Utils/Logger.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/Language/Haskell/Syntax.hs
- compiler/Language/Haskell/Syntax/ImpExp.hs
- configure.ac
- distrib/configure.ac.in
- docs/users_guide/debugging.rst
- docs/users_guide/ghci.rst
- docs/users_guide/phases.rst
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Exception.hs
- ghc/Main.hs
- hadrian/README.md
- hadrian/bindist/config.mk.in
- hadrian/cfg/default.host.target.in
- + hadrian/cfg/system.config.host.in
- hadrian/cfg/system.config.in
- + hadrian/cfg/system.config.target.in
- hadrian/hadrian.cabal
- hadrian/src/Base.hs
- + hadrian/src/BindistConfig.hs
- hadrian/src/Builder.hs
- hadrian/src/Context.hs
- hadrian/src/Expression.hs
- hadrian/src/Flavour.hs
- hadrian/src/Flavour/Type.hs
- hadrian/src/Hadrian/Builder.hs
- hadrian/src/Hadrian/Haskell/Hash.hs
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Main.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Oracles/Flavour.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Oracles/TestSettings.hs
- hadrian/src/Packages.hs
- hadrian/src/Rules.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/CabalReinstall.hs
- hadrian/src/Rules/Changelog.hs
- hadrian/src/Rules/Compile.hs
- hadrian/src/Rules/Documentation.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Gmp.hs
- hadrian/src/Rules/Library.hs
- hadrian/src/Rules/Program.hs
- hadrian/src/Rules/Register.hs
- hadrian/src/Rules/Rts.hs
- hadrian/src/Rules/Test.hs
- hadrian/src/Settings.hs
- hadrian/src/Settings/Builders/Cabal.hs
- hadrian/src/Settings/Builders/Common.hs
- hadrian/src/Settings/Builders/Configure.hs
- hadrian/src/Settings/Builders/DeriveConstants.hs
- hadrian/src/Settings/Builders/Ghc.hs
- hadrian/src/Settings/Builders/Hsc2Hs.hs
- hadrian/src/Settings/Builders/RunTest.hs
- hadrian/src/Settings/Builders/SplitSections.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Flavours/GhcInGhci.hs
- hadrian/src/Settings/Flavours/Performance.hs
- hadrian/src/Settings/Flavours/QuickCross.hs
- hadrian/src/Settings/Packages.hs
- hadrian/src/Settings/Program.hs
- hadrian/src/Settings/Warnings.hs
- libraries/base/tests/all.T
- m4/fp_find_nm.m4
- m4/prep_target_file.m4
- testsuite/ghc-config/ghc-config.hs
- testsuite/tests/annotations/should_fail/annfail03.stderr
- testsuite/tests/annotations/should_fail/annfail04.stderr
- testsuite/tests/annotations/should_fail/annfail06.stderr
- testsuite/tests/annotations/should_fail/annfail09.stderr
- testsuite/tests/driver/T16167.stderr
- − testsuite/tests/driver/T16167.stdout
- testsuite/tests/driver/all.T
- testsuite/tests/driver/json2.stderr
- − testsuite/tests/driver/json_dump.hs
- − testsuite/tests/driver/json_dump.stderr
- testsuite/tests/ghc-api/T7478/T7478.hs
- testsuite/tests/ghc-api/exactprint/T22919.stderr
- testsuite/tests/ghc-api/exactprint/Test20239.stderr
- testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.stderr
- testsuite/tests/ghc-e/should_fail/all.T
- testsuite/tests/ghci/prog-mhu002/prog-mhu002c.stdout
- testsuite/tests/ghci/scripts/ghci024.stdout
- testsuite/tests/ghci/scripts/ghci024.stdout-mingw32
- testsuite/tests/haddock/haddock_testsuite/Makefile
- testsuite/tests/haddock/haddock_testsuite/all.T
- testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T24221.stderr
- testsuite/tests/javascript/closure/all.T
- testsuite/tests/module/mod185.stderr
- + testsuite/tests/package/ImportReexport.hs
- + testsuite/tests/package/ImportReexport.stderr
- testsuite/tests/package/all.T
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/DumpSemis.stderr
- testsuite/tests/parser/should_compile/KindSigs.stderr
- testsuite/tests/parser/should_compile/T14189.stderr
- testsuite/tests/parser/should_compile/T15323.stderr
- testsuite/tests/parser/should_compile/T20452.stderr
- testsuite/tests/parser/should_compile/T20718.stderr
- testsuite/tests/parser/should_compile/T20718b.stderr
- testsuite/tests/parser/should_compile/T20846.stderr
- testsuite/tests/parser/should_compile/T23315/T23315.stderr
- testsuite/tests/perf/compiler/all.T
- testsuite/tests/plugins/hooks-plugin/Hooks/LogPlugin.hs
- testsuite/tests/printer/AnnotationNoListTuplePuns.stdout
- testsuite/tests/printer/T18791.stderr
- testsuite/tests/printer/Test10309.hs
- testsuite/tests/printer/Test20297.stdout
- testsuite/tests/printer/Test24533.stdout
- + testsuite/tests/profiling/should_compile/T27386.hs
- testsuite/tests/profiling/should_compile/all.T
- testsuite/tests/quasiquotation/qq001/qq001.stderr
- testsuite/tests/quasiquotation/qq002/qq002.stderr
- testsuite/tests/quasiquotation/qq003/qq003.stderr
- testsuite/tests/quasiquotation/qq004/qq004.stderr
- testsuite/tests/quotes/LiftErrMsg.stderr
- testsuite/tests/quotes/LiftErrMsgDefer.stderr
- testsuite/tests/quotes/LiftErrMsgTyped.stderr
- testsuite/tests/quotes/T10384.stderr
- testsuite/tests/quotes/T5721.stderr
- testsuite/tests/quotes/TH_localname.stderr
- testsuite/tests/simplCore/should_compile/Makefile
- + testsuite/tests/simplCore/should_compile/T27296.hs
- + testsuite/tests/simplCore/should_compile/T27296.stdout
- + testsuite/tests/simplCore/should_compile/T27296b.hs
- + testsuite/tests/simplCore/should_compile/T27296b.stdout
- testsuite/tests/simplCore/should_compile/all.T
- testsuite/tests/splice-imports/SI03.stderr
- testsuite/tests/splice-imports/SI05.stderr
- testsuite/tests/splice-imports/SI08.stderr
- testsuite/tests/splice-imports/SI08_oneshot.stderr
- testsuite/tests/splice-imports/SI16.stderr
- testsuite/tests/splice-imports/SI18.stderr
- testsuite/tests/splice-imports/SI20.stderr
- testsuite/tests/splice-imports/SI25.stderr
- testsuite/tests/splice-imports/SI28.stderr
- testsuite/tests/splice-imports/SI29.stderr
- testsuite/tests/splice-imports/SI31.stderr
- testsuite/tests/splice-imports/SI36.stderr
- testsuite/tests/splice-imports/T26088.stderr
- testsuite/tests/splice-imports/T26090.stderr
- + testsuite/tests/splice-imports/T26616.hs
- + testsuite/tests/splice-imports/T26616.stderr
- testsuite/tests/splice-imports/all.T
- testsuite/tests/th/T16976z.stderr
- testsuite/tests/th/T17820a.stderr
- testsuite/tests/th/T17820b.stderr
- testsuite/tests/th/T17820c.stderr
- testsuite/tests/th/T17820d.stderr
- testsuite/tests/th/T17820e.stderr
- testsuite/tests/th/T21547.stderr
- testsuite/tests/th/T23829_hasty.stderr
- testsuite/tests/th/T23829_hasty_b.stderr
- testsuite/tests/th/T23829_tardy.ghc.stderr
- testsuite/tests/th/T26098_local.stderr
- testsuite/tests/th/T26098_quote.stderr
- testsuite/tests/th/T26098_splice.stderr
- testsuite/tests/th/T26099.stderr
- testsuite/tests/th/T26568.stderr
- testsuite/tests/th/T5795.stderr
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Main.hs
- utils/check-exact/Preprocess.hs
- utils/check-exact/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/haddock/haddock-test/src/Test/Haddock/Config.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8ac68f320d9e640218a25a2d2fe247…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8ac68f320d9e640218a25a2d2fe247…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/sol/rename-mc-diagnostics] Rename `MCDiagnostic` to `InternalMCDiagnostic`
by Simon Hengel (@sol) 25 Jun '26
by Simon Hengel (@sol) 25 Jun '26
25 Jun '26
Simon Hengel pushed to branch wip/sol/rename-mc-diagnostics at Glasgow Haskell Compiler / GHC
Commits:
1a615970 by Simon Hengel at 2026-06-25T12:56:30+07:00
Rename `MCDiagnostic` to `InternalMCDiagnostic`
`MCDiagnostic` is meant to be used for compiler diagnostics.
Any code that creates `MCDiagnostic` directly, without going through
`GHC.Driver.Errors.printMessage`, sidesteps `-fdiagnostics-as-json` (see
e.g. !14616, !14475, !14492 !14548).
To avoid this in the future, this change more narrowly controls who
creates `MCDiagnostic` (see #24113).
- - - - -
15 changed files:
- compiler/GHC/Driver/Errors.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Types/Error.hs
- − compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/SourceError.hs
- compiler/GHC/Utils/Error.hs
- ghc/GHCi/UI/Exception.hs
- utils/check-exact/Main.hs
- utils/check-exact/Preprocess.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
Changes:
=====================================
compiler/GHC/Driver/Errors.hs
=====================================
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
module GHC.Driver.Errors (
reportError
, reportDiagnostic
@@ -66,7 +67,7 @@ printMessage logger msg_opts opts message
doc = updSDocContext (\_ -> ctx) (messageWithHints diagnostic)
messageClass :: MessageClass
- messageClass = MCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
+ messageClass = InternalMCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
style :: PprStyle
style = mkErrStyle (errMsgContext message)
=====================================
compiler/GHC/Driver/Main/Passes.hs
=====================================
@@ -2,6 +2,7 @@
{-# LANGUAGE MultiWayIf #-}
{-# OPTIONS_GHC -fprof-auto-top #-}
+{-# OPTIONS_GHC -Wwarn=x-internalPprMessages #-}
-------------------------------------------------------------------------------
-- | Aspects of GHC.Driver.Main dealing with running particular passes.
@@ -1401,9 +1402,15 @@ markUnsafeInfer tcg_env whyUnsafe = do
whyUnsafe' df = vcat [ quotes pprMod <+> text "has been inferred as unsafe!"
, text "Reason:"
, nest 4 $ (vcat $ badFlags df) $+$
- -- MP: Using defaultDiagnosticOpts here is not right but it's also not right to handle these
- -- unsafety error messages in an unstructured manner.
- (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @e) (getMessages whyUnsafe)) $+$
+
+ -- FIXME: `GHC.Utils.Error.internalPprMessages` is an
+ -- internal function!
+ --
+ -- Use `GHC.Driver.Errors.printMessages` to report the
+ -- diagnostics here and remove `internalPprMessages`
+ -- from the export list of "GHC.Utils.Error".
+ (vcat $ internalPprMessages (getMessages whyUnsafe)) $+$
+
(vcat $ badInsts $ tcg_insts tcg_env)
]
badFlags df = concatMap (badFlag df) unsafeFlagsForInfer
=====================================
compiler/GHC/Driver/Pipeline.hs
=====================================
@@ -101,7 +101,7 @@ import GHC.Iface.Recomp
import GHC.Runtime.Loader ( initializePlugins )
import GHC.Types.Basic ( SuccessFlag(..), ForeignSrcLang(..) )
-import GHC.Types.Error ( singleMessage, getMessages, mkSimpleUnknownDiagnostic, defaultDiagnosticOpts )
+import GHC.Types.Error ( singleMessage, getMessages, mkSimpleUnknownDiagnostic )
import GHC.Types.ForeignStubs ( ForeignStubs (NoStubs) )
import GHC.Types.Target
import GHC.Types.SrcLoc
@@ -169,9 +169,7 @@ preprocess hsc_env input_fn mb_input_buf mb_phase =
to_driver_messages :: Messages GhcMessage -> Messages DriverMessage
to_driver_messages msgs = case traverse to_driver_message msgs of
- Nothing -> pprPanic "non-driver message in preprocess"
- -- MP: Default config is fine here as it's just in a panic.
- (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @GhcMessage) (getMessages msgs))
+ Nothing -> panicMessage "non-driver message in preprocess" (getMessages msgs)
Just msgs' -> msgs'
to_driver_message = \case
=====================================
compiler/GHC/HsToCore/Monad.hs
=====================================
@@ -404,7 +404,7 @@ initTcDsForSolver thing_inside
thing_inside
; case mb_ret of
Just ret -> pure ret
- Nothing -> pprPanic "initTcDsForSolver" (vcat $ pprMsgEnvelopeBagWithLocDefault (getErrorMessages msgs)) }
+ Nothing -> panicMessage "initTcDsForSolver" (getErrorMessages msgs) }
mkDsEnvs :: UnitEnv -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv
-> TcMPluginsRun
=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -71,7 +71,7 @@ import GHC.Core.TyCo.FVs
import GHC.Core.InstEnv
import GHC.Core.TyCon
-import GHC.Utils.Error (diagReasonSeverity, pprLocMsgEnvelope )
+import GHC.Utils.Error (diagReasonSeverity, deferredTypeErrorMessage )
import GHC.Utils.Misc
import GHC.Utils.Outputable as O
import GHC.Utils.Panic
@@ -1395,9 +1395,8 @@ mkErrorTerm ct_loc ty ctxt msg supp hints
hints
-- This will be reported at runtime, so we always want "error:" in the report, never "warning:"
; dflags <- getDynFlags
- ; let err_msg = pprLocMsgEnvelope (initTcMessageOpts dflags) msg
- err_str = showSDoc dflags $
- err_msg $$ text "(deferred type error)"
+ ; let err_msg = deferredTypeErrorMessage (initTcMessageOpts dflags) msg
+ err_str = showSDoc dflags err_msg
; return $ evDelayedError ty err_str }
=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -Wno-x-internalDebugPpr #-}
{-
(c) The University of Glasgow 2006
@@ -1432,7 +1433,7 @@ reportDiagnostics = mapM_ reportDiagnostic
reportDiagnostic :: MsgEnvelope TcRnMessage -> TcRn ()
reportDiagnostic msg
- = do { traceTc "Adding diagnostic:" (pprLocMsgEnvelopeDefault msg) ;
+ = do { traceTc "Adding diagnostic:" (internalDebugPpr msg) ;
errs_var <- getErrsVar ;
msgs <- readTcRef errs_var ;
writeTcRef errs_var (msg `addMessage` msgs) }
=====================================
compiler/GHC/Types/Error.hs
=====================================
@@ -18,7 +18,7 @@ module GHC.Types.Error
-- * Classifying Messages
- , MessageClass (..)
+ , MessageClass (MCDiagnostic, ..)
, Severity (..)
, Diagnostic (..)
, UnknownDiagnostic (..)
@@ -482,7 +482,7 @@ data MessageClass
-- ^ Log messages intended for end users.
-- No file\/line\/column stuff.
- | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
+ | InternalMCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
-- ^ Diagnostics from the compiler. This constructor is very powerful as
-- it allows the construction of a 'MessageClass' with a completely
-- arbitrary permutation of 'Severity' and 'DiagnosticReason'. As such,
@@ -492,10 +492,19 @@ data MessageClass
-- 'GHC.Utils.Error'. In all the other circumstances, /especially/ when
-- emitting compiler diagnostics, use higher level primitives.
--
+ -- For deconstruction use `MCDiagnostic`.
+ --
-- The @Maybe 'DiagnosticCode'@ field carries a code (if available) for
-- this diagnostic. If you are creating a message not tied to any
-- error-message type, then use Nothing. In the long run, this really
-- should always have a 'DiagnosticCode'. See Note [Diagnostic codes].
+ --
+{-# WARNING in "x-InternalMCDiagnostic" InternalMCDiagnostic
+ "This is an internal constructor. Use `MCDiagnostic` or `GHC.Driver.Errors.printMessages` instead." #-}
+
+{-# COMPLETE MCOutput, MCFatal, MCInteractive, MCDump, MCInfo, MCDiagnostic #-}
+pattern MCDiagnostic :: Severity -> ResolvedDiagnosticReason -> Maybe DiagnosticCode -> MessageClass
+pattern MCDiagnostic severity reason code <- InternalMCDiagnostic severity reason code
{-
Note [Suppressing Messages]
=====================================
compiler/GHC/Types/Error.hs-boot deleted
=====================================
@@ -1,24 +0,0 @@
-module GHC.Types.Error where
-
-import GHC.Prelude (Maybe, Bool, IO)
-import GHC.Utils.Outputable (SDoc)
-import GHC.Types.SrcLoc (SrcSpan)
-
-data MessageClass
- = MCOutput
- | MCFatal
- | MCInteractive
- | MCDump
- | MCInfo
- | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
-
-data Severity
- = SevIgnore
- | SevWarning
- | SevError
-
-data DiagnosticCode
-data ResolvedDiagnosticReason
-
-mkLocMessageWarningGroups :: Bool -> MessageClass -> SrcSpan -> SDoc -> SDoc
-getCaretDiagnostic :: MessageClass -> SrcSpan -> IO SDoc
=====================================
compiler/GHC/Types/SourceError.hs
=====================================
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -Wno-x-internalDebugShow #-}
-- | Source errors
module GHC.Types.SourceError
( SourceError (..)
@@ -16,8 +17,7 @@ import GHC.Types.Error
import GHC.Utils.Monad
import GHC.Utils.Panic
import GHC.Utils.Exception
-import GHC.Utils.Error (pprMsgEnvelopeBagWithLocDefault, DiagOpts, diag_ppr_ctx)
-import GHC.Utils.Outputable
+import GHC.Utils.Error (internalDebugShow, DiagOpts)
import GHC.Driver.Config.Diagnostic (initDiagOpts, initPrintConfig)
import GHC.Driver.DynFlags (DynFlags, HasDynFlags (getDynFlags))
@@ -73,15 +73,12 @@ initSourceErrorContext dflags =
in SEC diag_opts print_config
instance Show SourceError where
- -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
- -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
+ -- We implement 'Show' because it's required by the 'Exception' instance, but
+ -- diagnostics must not be shown via 'Show', but instead reported via
+ -- `GHC.Driver.Errors.printMessages`.
+ --
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
- show (SourceError (SEC diag_opts _) msgs) =
- renderWithContext (diag_ppr_ctx diag_opts)
- . vcat
- . pprMsgEnvelopeBagWithLocDefault
- . getMessages
- $ msgs
+ show (SourceError _ msgs) = internalDebugShow msgs
instance Exception SourceError
=====================================
compiler/GHC/Utils/Error.hs
=====================================
@@ -1,5 +1,7 @@
{-# LANGUAGE ViewPatterns #-}
+{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
+
{-
(c) The AQUA Project, Glasgow University, 1994-1998
@@ -22,10 +24,11 @@ module GHC.Utils.Error (
errorsFound, isEmptyMessages,
-- ** Formatting
- pprMessageBag, pprMsgEnvelopeBagWithLoc, pprMsgEnvelopeBagWithLocDefault,
- pprMessages,
- pprLocMsgEnvelope, pprLocMsgEnvelopeDefault,
- formatBulleted,
+ pprMessageBag, formatBulleted,
+ deferredTypeErrorMessage,
+ panicMessage, internalDebugShow, internalDebugPpr,
+
+ internalPprMessages, -- FIXME: remove this export
-- ** Construction
DiagOpts (..), emptyDiagOpts, diag_wopt, diag_fatal_wopt,
@@ -265,29 +268,40 @@ formatBulleted (unDecorated -> docs)
msgs ctx = filter (not . Outputable.isEmpty ctx) docs
starred = (bullet<+>)
-pprMessages :: Diagnostic e => DiagnosticOpts e -> Messages e -> SDoc
-pprMessages e = vcat . pprMsgEnvelopeBagWithLoc e . getMessages
-
-pprMsgEnvelopeBagWithLoc :: Diagnostic e => DiagnosticOpts e -> Bag (MsgEnvelope e) -> [SDoc]
-pprMsgEnvelopeBagWithLoc e bag = [ pprLocMsgEnvelope e item | item <- sortMsgBag Nothing bag ]
-
--- | Print the messages with the suitable default configuration, usually not what you want but sometimes you don't really
--- care about what the configuration is (for example, if the message is in a panic).
-pprMsgEnvelopeBagWithLocDefault :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
-pprMsgEnvelopeBagWithLocDefault bag = [ pprLocMsgEnvelopeDefault item | item <- sortMsgBag Nothing bag ]
-
-pprLocMsgEnvelopeDefault :: forall e . Diagnostic e => MsgEnvelope e -> SDoc
-pprLocMsgEnvelopeDefault = pprLocMsgEnvelope (defaultDiagnosticOpts @e)
-
-pprLocMsgEnvelope :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
-pprLocMsgEnvelope opts (MsgEnvelope { errMsgSpan = s
+deferredTypeErrorMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+deferredTypeErrorMessage opts msg = internalPprMessage opts msg $$ text "(deferred type error)"
+
+panicMessage :: Diagnostic e => String -> Bag (MsgEnvelope e) -> a
+panicMessage name msgs = pprPanic name (vcat $ internalPprMessages msgs)
+
+{-# WARNING in "x-internalDebugShow" internalDebugShow
+ "Don't use this function for reporting diagnostics! Use `GHC.Driver.Errors.printMessages` instead." #-}
+internalDebugShow :: Diagnostic e => Messages e -> String
+internalDebugShow =
+ renderWithContext defaultSDocContext
+ . vcat
+ . internalPprMessages
+ . getMessages
+
+{-# WARNING in "x-internalDebugPpr" internalDebugPpr
+ "Don't use this function for reporting diagnostics! Use `GHC.Driver.Errors.printMessage` instead." #-}
+internalDebugPpr :: forall e. Diagnostic e => MsgEnvelope e -> SDoc
+internalDebugPpr = internalPprMessage (defaultDiagnosticOpts @e)
+
+{-# WARNING in "x-internalPprMessages" internalPprMessages
+ "Don't use this function for new code! It sidesteps the structured error machinery. Use `GHC.Driver.Errors.printMessages` instead." #-}
+internalPprMessages :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
+internalPprMessages = map (internalPprMessage (defaultDiagnosticOpts @e)) . sortMsgBag Nothing
+
+internalPprMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+internalPprMessage opts (MsgEnvelope { errMsgSpan = s
, errMsgDiagnostic = e
, errMsgSeverity = sev
, errMsgContext = name_ppr_ctx
, errMsgReason = reason })
= withErrStyle name_ppr_ctx $
mkLocMessage
- (MCDiagnostic sev reason (diagnosticCode e))
+ (InternalMCDiagnostic sev reason (diagnosticCode e))
s
(formatBulleted $ diagnosticMessage opts e)
=====================================
ghc/GHCi/UI/Exception.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -Wno-x-internalDebugShow #-}
module GHCi.UI.Exception
( GhciCommandError(..)
, throwGhciCommandError
@@ -51,15 +52,12 @@ newtype GhciCommandError = GhciCommandError (Messages GhciMessage)
instance Exception GhciCommandError
instance Show GhciCommandError where
- -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
- -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
+ -- We implement 'Show' because it's required by the 'Exception' instance, but
+ -- diagnostics must not be shown via 'Show', but instead reported via
+ -- `GHC.Driver.Errors.printMessages`.
+ --
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
- show (GhciCommandError msgs) =
- renderWithContext defaultSDocContext
- . vcat
- . pprMsgEnvelopeBagWithLocDefault
- . getMessages
- $ msgs
+ show (GhciCommandError msgs) = internalDebugShow msgs
-- | Perform the given action and call the exception handler if the action
-- throws a 'GhciCommandError'. See 'GhciCommandError' for more information.
=====================================
utils/check-exact/Main.hs
=====================================
@@ -3,6 +3,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE BangPatterns #-}
+{-# OPTIONS_GHC -Wno-x-internalDebugShow #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
@@ -11,14 +12,11 @@
import Data.Data
import Data.List (intercalate)
import GHC hiding (moduleName)
-import GHC.Driver.Errors.Types
import GHC.Driver.Ppr
import GHC.Hs.Dump
-import GHC.Types.Error
import GHC.Types.Name.Occurrence
import GHC.Types.Name.Reader
import GHC.Utils.Error
-import GHC.Utils.Outputable
import System.Environment( getArgs )
import System.Exit
import System.FilePath
@@ -369,19 +367,11 @@ parseOneFile :: FilePath -> FilePath -> IO (ParsedSource, [Located Token])
parseOneFile libdir fileName = do
res <- parseModuleEpAnnsWithCpp libdir defaultCppOptions fileName
case res of
- Left m -> error (showErrorMessages m)
+ Left m -> error (internalDebugShow m)
Right (injectedComments, _dflags, pmod) -> do
let !pmodWithComments = insertCppComments pmod injectedComments
return (pmodWithComments, [])
-showErrorMessages :: Messages GhcMessage -> String
-showErrorMessages msgs =
- renderWithContext defaultSDocContext
- $ vcat
- $ pprMsgEnvelopeBagWithLocDefault
- $ getMessages
- $ msgs
-
-- ---------------------------------------------------------------------
exactprintWithChange :: FilePath -> Changer -> ParsedSource -> IO (String, ParsedSource)
=====================================
utils/check-exact/Preprocess.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
+{-# OPTIONS_GHC -Wno-x-internalDebugShow #-}
-- | This module provides support for CPP, interpreter directives and line
-- pragmas.
module Preprocess
@@ -26,13 +27,11 @@ import qualified GHC.Driver.Phases as GHC
import qualified GHC.Driver.Pipeline as GHC
import qualified GHC.Parser.Lexer as GHC
import qualified GHC.Settings as GHC
-import qualified GHC.Types.Error as GHC
import qualified GHC.Types.SourceError as GHC
import qualified GHC.Types.SourceFile as GHC
import qualified GHC.Types.SrcLoc as GHC
import qualified GHC.Utils.Error as GHC
import qualified GHC.Utils.Fingerprint as GHC
-import qualified GHC.Utils.Outputable as GHC
import GHC.Types.SrcLoc (mkSrcSpan, mkSrcLoc)
import GHC.Data.FastString (mkFastString)
@@ -216,20 +215,12 @@ getPreprocessedSrcDirectPrim cppOptions src_fn = do
new_env = hsc_env { GHC.hsc_dflags = injectCppOptions cppOptions dfs }
r <- GHC.liftIO $ GHC.preprocess new_env src_fn Nothing (Just (GHC.Cpp GHC.HsSrcFile))
case r of
- Left err -> error $ showErrorMessages err
+ Left err -> error $ GHC.internalDebugShow err
Right (dflags', hspp_fn) -> do
buf <- GHC.liftIO $ GHC.hGetStringBuffer hspp_fn
txt <- GHC.liftIO $ readFileGhc hspp_fn
return (txt, buf, dflags')
-showErrorMessages :: GHC.Messages GHC.DriverMessage -> String
-showErrorMessages msgs =
- GHC.renderWithContext GHC.defaultSDocContext
- $ GHC.vcat
- $ GHC.pprMsgEnvelopeBagWithLocDefault
- $ GHC.getMessages
- $ msgs
-
injectCppOptions :: CppOptions -> GHC.DynFlags -> GHC.DynFlags
injectCppOptions CppOptions{..} dflags = folded_opt
where
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
=====================================
@@ -97,7 +97,7 @@ ppHyperlinkedModuleSource verbosity srcdir pretty srcs iface = do
mast
| M.size asts == 1 = snd <$> M.lookupMin asts
| otherwise = M.lookup (HiePath (mkFastString file)) asts
- tokens' = parse parserOpts sDocContext file rawSrc
+ tokens' = parse parserOpts file rawSrc
ast = fromMaybe (emptyHieAst fileFs) mast
fullAst = recoverFullIfaceTypes sDocContext types ast
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
=====================================
@@ -9,7 +9,6 @@ import Control.Monad.Trans.Class
import Control.Monad.Trans.Maybe
import qualified Data.ByteString as BS
import Data.List (isPrefixOf, isSuffixOf)
-import GHC.Data.Bag (bagToList)
import GHC.Data.FastString (mkFastString)
import GHC.Data.StringBuffer (StringBuffer, atEnd)
import GHC.Parser.Errors.Ppr ()
@@ -26,10 +25,7 @@ import GHC.Parser.Lexer as Lexer
import qualified GHC.Types.Error as E
import GHC.Types.SourceText
import GHC.Types.SrcLoc
-import GHC.Utils.Error (pprLocMsgEnvelopeDefault)
-import GHC.Utils.Outputable (SDocContext, text, ($$))
-import qualified GHC.Utils.Outputable as Outputable
-import GHC.Utils.Panic (panic)
+import GHC.Utils.Error (panicMessage)
import Haddock.Backends.Hyperlinker.Types as T
import Haddock.GhcUtils
@@ -40,19 +36,14 @@ import Haddock.GhcUtils
-- whitespace, and CPP).
parse
:: ParserOpts
- -> SDocContext
-> FilePath
-- ^ Path to the source of this module
-> BS.ByteString
-- ^ Raw UTF-8 encoded source of this module
-> [T.Token]
-parse parserOpts sDocContext fpath bs = case unP (go False []) initState of
+parse parserOpts fpath bs = case unP (go False []) initState of
POk _ toks -> reverse toks
- PFailed pst ->
- let err : _ = bagToList (E.getMessages $ getPsErrorMessages pst)
- in panic $
- Outputable.renderWithContext sDocContext $
- text "Hyperlinker parse error:" $$ pprLocMsgEnvelopeDefault err
+ PFailed pst -> panicMessage "Hyperlinker parse error:" (E.getMessages $ getPsErrorMessages pst)
where
initState = initParserState parserOpts buf start
buf = stringBufferFromByteString bs
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a6159707c6336f830ebd4a2d20aafb…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a6159707c6336f830ebd4a2d20aafb…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/sol/rename-mc-diagnostics] Rename `MCDiagnostic` to `InternalMCDiagnostic`
by Simon Hengel (@sol) 25 Jun '26
by Simon Hengel (@sol) 25 Jun '26
25 Jun '26
Simon Hengel pushed to branch wip/sol/rename-mc-diagnostics at Glasgow Haskell Compiler / GHC
Commits:
f10a45a6 by Simon Hengel at 2026-06-25T12:44:44+07:00
Rename `MCDiagnostic` to `InternalMCDiagnostic`
`MCDiagnostic` is meant to be used for compiler diagnostics.
Any code that creates `MCDiagnostic` directly, without going through
`GHC.Driver.Errors.printMessage`, sidesteps `-fdiagnostics-as-json` (see
e.g. !14616, !14475, !14492 !14548).
To avoid this in the future, this change more narrowly controls who
creates `MCDiagnostic` (see #24113).
- - - - -
17 changed files:
- compiler/GHC/Driver/Errors.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Types/Error.hs
- − compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/SourceError.hs
- compiler/GHC/Utils/Error.hs
- ghc/GHCi/UI/Exception.hs
- + hadrian/ghci_
- + hadrian/sensei
- utils/check-exact/Main.hs
- utils/check-exact/Preprocess.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
Changes:
=====================================
compiler/GHC/Driver/Errors.hs
=====================================
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
module GHC.Driver.Errors (
reportError
, reportDiagnostic
@@ -66,7 +67,7 @@ printMessage logger msg_opts opts message
doc = updSDocContext (\_ -> ctx) (messageWithHints diagnostic)
messageClass :: MessageClass
- messageClass = MCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
+ messageClass = InternalMCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
style :: PprStyle
style = mkErrStyle (errMsgContext message)
=====================================
compiler/GHC/Driver/Main/Passes.hs
=====================================
@@ -2,6 +2,7 @@
{-# LANGUAGE MultiWayIf #-}
{-# OPTIONS_GHC -fprof-auto-top #-}
+{-# OPTIONS_GHC -Wwarn=x-internalPprMessages #-}
-------------------------------------------------------------------------------
-- | Aspects of GHC.Driver.Main dealing with running particular passes.
@@ -1401,9 +1402,15 @@ markUnsafeInfer tcg_env whyUnsafe = do
whyUnsafe' df = vcat [ quotes pprMod <+> text "has been inferred as unsafe!"
, text "Reason:"
, nest 4 $ (vcat $ badFlags df) $+$
- -- MP: Using defaultDiagnosticOpts here is not right but it's also not right to handle these
- -- unsafety error messages in an unstructured manner.
- (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @e) (getMessages whyUnsafe)) $+$
+
+ -- FIXME: `GHC.Utils.Error.internalPprMessages` is an
+ -- internal function!
+ --
+ -- Use `GHC.Driver.Errors.printMessages` to report the
+ -- diagnostics here and remove `internalPprMessages`
+ -- from the export list of "GHC.Utils.Error".
+ (vcat $ internalPprMessages (getMessages whyUnsafe)) $+$
+
(vcat $ badInsts $ tcg_insts tcg_env)
]
badFlags df = concatMap (badFlag df) unsafeFlagsForInfer
=====================================
compiler/GHC/Driver/Pipeline.hs
=====================================
@@ -101,7 +101,7 @@ import GHC.Iface.Recomp
import GHC.Runtime.Loader ( initializePlugins )
import GHC.Types.Basic ( SuccessFlag(..), ForeignSrcLang(..) )
-import GHC.Types.Error ( singleMessage, getMessages, mkSimpleUnknownDiagnostic, defaultDiagnosticOpts )
+import GHC.Types.Error ( singleMessage, getMessages, mkSimpleUnknownDiagnostic )
import GHC.Types.ForeignStubs ( ForeignStubs (NoStubs) )
import GHC.Types.Target
import GHC.Types.SrcLoc
@@ -169,9 +169,7 @@ preprocess hsc_env input_fn mb_input_buf mb_phase =
to_driver_messages :: Messages GhcMessage -> Messages DriverMessage
to_driver_messages msgs = case traverse to_driver_message msgs of
- Nothing -> pprPanic "non-driver message in preprocess"
- -- MP: Default config is fine here as it's just in a panic.
- (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @GhcMessage) (getMessages msgs))
+ Nothing -> panicMessage "non-driver message in preprocess" (getMessages msgs)
Just msgs' -> msgs'
to_driver_message = \case
=====================================
compiler/GHC/HsToCore/Monad.hs
=====================================
@@ -404,7 +404,7 @@ initTcDsForSolver thing_inside
thing_inside
; case mb_ret of
Just ret -> pure ret
- Nothing -> pprPanic "initTcDsForSolver" (vcat $ pprMsgEnvelopeBagWithLocDefault (getErrorMessages msgs)) }
+ Nothing -> panicMessage "initTcDsForSolver" (getErrorMessages msgs) }
mkDsEnvs :: UnitEnv -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv
-> TcMPluginsRun
=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -71,7 +71,7 @@ import GHC.Core.TyCo.FVs
import GHC.Core.InstEnv
import GHC.Core.TyCon
-import GHC.Utils.Error (diagReasonSeverity, pprLocMsgEnvelope )
+import GHC.Utils.Error (diagReasonSeverity, deferredTypeErrorMessage )
import GHC.Utils.Misc
import GHC.Utils.Outputable as O
import GHC.Utils.Panic
@@ -1395,9 +1395,8 @@ mkErrorTerm ct_loc ty ctxt msg supp hints
hints
-- This will be reported at runtime, so we always want "error:" in the report, never "warning:"
; dflags <- getDynFlags
- ; let err_msg = pprLocMsgEnvelope (initTcMessageOpts dflags) msg
- err_str = showSDoc dflags $
- err_msg $$ text "(deferred type error)"
+ ; let err_msg = deferredTypeErrorMessage (initTcMessageOpts dflags) msg
+ err_str = showSDoc dflags err_msg
; return $ evDelayedError ty err_str }
=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -Wno-x-debugTracePpr #-}
{-
(c) The University of Glasgow 2006
@@ -1432,7 +1433,7 @@ reportDiagnostics = mapM_ reportDiagnostic
reportDiagnostic :: MsgEnvelope TcRnMessage -> TcRn ()
reportDiagnostic msg
- = do { traceTc "Adding diagnostic:" (pprLocMsgEnvelopeDefault msg) ;
+ = do { traceTc "Adding diagnostic:" (debugTracePpr msg) ;
errs_var <- getErrsVar ;
msgs <- readTcRef errs_var ;
writeTcRef errs_var (msg `addMessage` msgs) }
=====================================
compiler/GHC/Types/Error.hs
=====================================
@@ -18,7 +18,7 @@ module GHC.Types.Error
-- * Classifying Messages
- , MessageClass (..)
+ , MessageClass (MCDiagnostic, ..)
, Severity (..)
, Diagnostic (..)
, UnknownDiagnostic (..)
@@ -482,7 +482,7 @@ data MessageClass
-- ^ Log messages intended for end users.
-- No file\/line\/column stuff.
- | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
+ | InternalMCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
-- ^ Diagnostics from the compiler. This constructor is very powerful as
-- it allows the construction of a 'MessageClass' with a completely
-- arbitrary permutation of 'Severity' and 'DiagnosticReason'. As such,
@@ -492,10 +492,19 @@ data MessageClass
-- 'GHC.Utils.Error'. In all the other circumstances, /especially/ when
-- emitting compiler diagnostics, use higher level primitives.
--
+ -- For deconstruction use `MCDiagnostic`.
+ --
-- The @Maybe 'DiagnosticCode'@ field carries a code (if available) for
-- this diagnostic. If you are creating a message not tied to any
-- error-message type, then use Nothing. In the long run, this really
-- should always have a 'DiagnosticCode'. See Note [Diagnostic codes].
+ --
+{-# WARNING in "x-InternalMCDiagnostic" InternalMCDiagnostic
+ "This is an internal constructor. Use `MCDiagnostic` or `GHC.Driver.Errors.printMessages` instead." #-}
+
+{-# COMPLETE MCOutput, MCFatal, MCInteractive, MCDump, MCInfo, MCDiagnostic #-}
+pattern MCDiagnostic :: Severity -> ResolvedDiagnosticReason -> Maybe DiagnosticCode -> MessageClass
+pattern MCDiagnostic severity reason code <- InternalMCDiagnostic severity reason code
{-
Note [Suppressing Messages]
=====================================
compiler/GHC/Types/Error.hs-boot deleted
=====================================
@@ -1,24 +0,0 @@
-module GHC.Types.Error where
-
-import GHC.Prelude (Maybe, Bool, IO)
-import GHC.Utils.Outputable (SDoc)
-import GHC.Types.SrcLoc (SrcSpan)
-
-data MessageClass
- = MCOutput
- | MCFatal
- | MCInteractive
- | MCDump
- | MCInfo
- | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
-
-data Severity
- = SevIgnore
- | SevWarning
- | SevError
-
-data DiagnosticCode
-data ResolvedDiagnosticReason
-
-mkLocMessageWarningGroups :: Bool -> MessageClass -> SrcSpan -> SDoc -> SDoc
-getCaretDiagnostic :: MessageClass -> SrcSpan -> IO SDoc
=====================================
compiler/GHC/Types/SourceError.hs
=====================================
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
-- | Source errors
module GHC.Types.SourceError
( SourceError (..)
@@ -16,8 +17,7 @@ import GHC.Types.Error
import GHC.Utils.Monad
import GHC.Utils.Panic
import GHC.Utils.Exception
-import GHC.Utils.Error (pprMsgEnvelopeBagWithLocDefault, DiagOpts, diag_ppr_ctx)
-import GHC.Utils.Outputable
+import GHC.Utils.Error (debugTraceShow, DiagOpts)
import GHC.Driver.Config.Diagnostic (initDiagOpts, initPrintConfig)
import GHC.Driver.DynFlags (DynFlags, HasDynFlags (getDynFlags))
@@ -73,15 +73,12 @@ initSourceErrorContext dflags =
in SEC diag_opts print_config
instance Show SourceError where
- -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
- -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
+ -- We implement 'Show' because it's required by the 'Exception' instance, but
+ -- diagnostics must not be shown via 'Show', but instead reported via
+ -- `GHC.Driver.Errors.printMessages`.
+ --
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
- show (SourceError (SEC diag_opts _) msgs) =
- renderWithContext (diag_ppr_ctx diag_opts)
- . vcat
- . pprMsgEnvelopeBagWithLocDefault
- . getMessages
- $ msgs
+ show (SourceError _ msgs) = debugTraceShow msgs
instance Exception SourceError
=====================================
compiler/GHC/Utils/Error.hs
=====================================
@@ -1,5 +1,7 @@
{-# LANGUAGE ViewPatterns #-}
+{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
+
{-
(c) The AQUA Project, Glasgow University, 1994-1998
@@ -22,10 +24,11 @@ module GHC.Utils.Error (
errorsFound, isEmptyMessages,
-- ** Formatting
- pprMessageBag, pprMsgEnvelopeBagWithLoc, pprMsgEnvelopeBagWithLocDefault,
- pprMessages,
- pprLocMsgEnvelope, pprLocMsgEnvelopeDefault,
- formatBulleted,
+ pprMessageBag, formatBulleted,
+ deferredTypeErrorMessage,
+ panicMessage, debugTraceShow, debugTracePpr,
+
+ internalPprMessages, -- FIXME: remove this export
-- ** Construction
DiagOpts (..), emptyDiagOpts, diag_wopt, diag_fatal_wopt,
@@ -265,29 +268,40 @@ formatBulleted (unDecorated -> docs)
msgs ctx = filter (not . Outputable.isEmpty ctx) docs
starred = (bullet<+>)
-pprMessages :: Diagnostic e => DiagnosticOpts e -> Messages e -> SDoc
-pprMessages e = vcat . pprMsgEnvelopeBagWithLoc e . getMessages
-
-pprMsgEnvelopeBagWithLoc :: Diagnostic e => DiagnosticOpts e -> Bag (MsgEnvelope e) -> [SDoc]
-pprMsgEnvelopeBagWithLoc e bag = [ pprLocMsgEnvelope e item | item <- sortMsgBag Nothing bag ]
-
--- | Print the messages with the suitable default configuration, usually not what you want but sometimes you don't really
--- care about what the configuration is (for example, if the message is in a panic).
-pprMsgEnvelopeBagWithLocDefault :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
-pprMsgEnvelopeBagWithLocDefault bag = [ pprLocMsgEnvelopeDefault item | item <- sortMsgBag Nothing bag ]
-
-pprLocMsgEnvelopeDefault :: forall e . Diagnostic e => MsgEnvelope e -> SDoc
-pprLocMsgEnvelopeDefault = pprLocMsgEnvelope (defaultDiagnosticOpts @e)
-
-pprLocMsgEnvelope :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
-pprLocMsgEnvelope opts (MsgEnvelope { errMsgSpan = s
+deferredTypeErrorMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+deferredTypeErrorMessage opts msg = internalPprMessage opts msg $$ text "(deferred type error)"
+
+panicMessage :: Diagnostic e => String -> Bag (MsgEnvelope e) -> a
+panicMessage name msgs = pprPanic name (vcat $ internalPprMessages msgs)
+
+{-# WARNING in "x-debugTraceShow" debugTraceShow
+ "Don't use this function for reporting diagnostics! Use `GHC.Driver.Errors.printMessages` instead." #-}
+debugTraceShow :: Diagnostic e => Messages e -> String
+debugTraceShow =
+ renderWithContext defaultSDocContext
+ . vcat
+ . internalPprMessages
+ . getMessages
+
+{-# WARNING in "x-debugTracePpr" debugTracePpr
+ "Don't use this function for reporting diagnostics! Use `GHC.Driver.Errors.printMessage` instead." #-}
+debugTracePpr :: forall e. Diagnostic e => MsgEnvelope e -> SDoc
+debugTracePpr = internalPprMessage (defaultDiagnosticOpts @e)
+
+{-# WARNING in "x-internalPprMessages" internalPprMessages
+ "This function sidesteps @-fdiagnostics-as-json@! Use `GHC.Driver.Errors.printMessages` instead." #-}
+internalPprMessages :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
+internalPprMessages = map (internalPprMessage (defaultDiagnosticOpts @e)) . sortMsgBag Nothing
+
+internalPprMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+internalPprMessage opts (MsgEnvelope { errMsgSpan = s
, errMsgDiagnostic = e
, errMsgSeverity = sev
, errMsgContext = name_ppr_ctx
, errMsgReason = reason })
= withErrStyle name_ppr_ctx $
mkLocMessage
- (MCDiagnostic sev reason (diagnosticCode e))
+ (InternalMCDiagnostic sev reason (diagnosticCode e))
s
(formatBulleted $ diagnosticMessage opts e)
=====================================
ghc/GHCi/UI/Exception.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
module GHCi.UI.Exception
( GhciCommandError(..)
, throwGhciCommandError
@@ -51,15 +52,12 @@ newtype GhciCommandError = GhciCommandError (Messages GhciMessage)
instance Exception GhciCommandError
instance Show GhciCommandError where
- -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
- -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
+ -- We implement 'Show' because it's required by the 'Exception' instance, but
+ -- diagnostics must not be shown via 'Show', but instead reported via
+ -- `GHC.Driver.Errors.printMessages`.
+ --
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
- show (GhciCommandError msgs) =
- renderWithContext defaultSDocContext
- . vcat
- . pprMsgEnvelopeBagWithLocDefault
- . getMessages
- $ msgs
+ show (GhciCommandError msgs) = debugTraceShow msgs
-- | Perform the given action and call the exception handler if the action
-- throws a 'GhciCommandError'. See 'GhciCommandError' for more information.
=====================================
hadrian/ghci_
=====================================
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+# This file is generated by configure from ghci-cabal.in
+
+set -e
+export TOOL_OUTPUT=.hadrian_ghci/ghci_args
+# Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
+CABFLAGS="-v0 $CABFLAGS" "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
+GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | grep '^-' | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+# GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+ghci $GHC_FLAGS $@ -fwrite-interface -hidir=.hadrian_ghci/interface -O0
=====================================
hadrian/sensei
=====================================
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+# This file is generated by configure from ghci-cabal.in
+
+set -e
+export TOOL_OUTPUT=.hadrian_ghci/ghci_args
+# Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
+CABFLAGS="-v0 $CABFLAGS" "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
+GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | grep '^-' | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+# GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+sensei $GHC_FLAGS $@ -fno-code -fwrite-interface -hidir=.hadrian_ghci/interface -O0
=====================================
utils/check-exact/Main.hs
=====================================
@@ -3,6 +3,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE BangPatterns #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
@@ -11,14 +12,11 @@
import Data.Data
import Data.List (intercalate)
import GHC hiding (moduleName)
-import GHC.Driver.Errors.Types
import GHC.Driver.Ppr
import GHC.Hs.Dump
-import GHC.Types.Error
import GHC.Types.Name.Occurrence
import GHC.Types.Name.Reader
import GHC.Utils.Error
-import GHC.Utils.Outputable
import System.Environment( getArgs )
import System.Exit
import System.FilePath
@@ -369,19 +367,11 @@ parseOneFile :: FilePath -> FilePath -> IO (ParsedSource, [Located Token])
parseOneFile libdir fileName = do
res <- parseModuleEpAnnsWithCpp libdir defaultCppOptions fileName
case res of
- Left m -> error (showErrorMessages m)
+ Left m -> error (debugTraceShow m)
Right (injectedComments, _dflags, pmod) -> do
let !pmodWithComments = insertCppComments pmod injectedComments
return (pmodWithComments, [])
-showErrorMessages :: Messages GhcMessage -> String
-showErrorMessages msgs =
- renderWithContext defaultSDocContext
- $ vcat
- $ pprMsgEnvelopeBagWithLocDefault
- $ getMessages
- $ msgs
-
-- ---------------------------------------------------------------------
exactprintWithChange :: FilePath -> Changer -> ParsedSource -> IO (String, ParsedSource)
=====================================
utils/check-exact/Preprocess.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
-- | This module provides support for CPP, interpreter directives and line
-- pragmas.
module Preprocess
@@ -26,13 +27,11 @@ import qualified GHC.Driver.Phases as GHC
import qualified GHC.Driver.Pipeline as GHC
import qualified GHC.Parser.Lexer as GHC
import qualified GHC.Settings as GHC
-import qualified GHC.Types.Error as GHC
import qualified GHC.Types.SourceError as GHC
import qualified GHC.Types.SourceFile as GHC
import qualified GHC.Types.SrcLoc as GHC
import qualified GHC.Utils.Error as GHC
import qualified GHC.Utils.Fingerprint as GHC
-import qualified GHC.Utils.Outputable as GHC
import GHC.Types.SrcLoc (mkSrcSpan, mkSrcLoc)
import GHC.Data.FastString (mkFastString)
@@ -216,20 +215,12 @@ getPreprocessedSrcDirectPrim cppOptions src_fn = do
new_env = hsc_env { GHC.hsc_dflags = injectCppOptions cppOptions dfs }
r <- GHC.liftIO $ GHC.preprocess new_env src_fn Nothing (Just (GHC.Cpp GHC.HsSrcFile))
case r of
- Left err -> error $ showErrorMessages err
+ Left err -> error $ GHC.debugTraceShow err
Right (dflags', hspp_fn) -> do
buf <- GHC.liftIO $ GHC.hGetStringBuffer hspp_fn
txt <- GHC.liftIO $ readFileGhc hspp_fn
return (txt, buf, dflags')
-showErrorMessages :: GHC.Messages GHC.DriverMessage -> String
-showErrorMessages msgs =
- GHC.renderWithContext GHC.defaultSDocContext
- $ GHC.vcat
- $ GHC.pprMsgEnvelopeBagWithLocDefault
- $ GHC.getMessages
- $ msgs
-
injectCppOptions :: CppOptions -> GHC.DynFlags -> GHC.DynFlags
injectCppOptions CppOptions{..} dflags = folded_opt
where
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
=====================================
@@ -97,7 +97,7 @@ ppHyperlinkedModuleSource verbosity srcdir pretty srcs iface = do
mast
| M.size asts == 1 = snd <$> M.lookupMin asts
| otherwise = M.lookup (HiePath (mkFastString file)) asts
- tokens' = parse parserOpts sDocContext file rawSrc
+ tokens' = parse parserOpts file rawSrc
ast = fromMaybe (emptyHieAst fileFs) mast
fullAst = recoverFullIfaceTypes sDocContext types ast
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
=====================================
@@ -9,7 +9,6 @@ import Control.Monad.Trans.Class
import Control.Monad.Trans.Maybe
import qualified Data.ByteString as BS
import Data.List (isPrefixOf, isSuffixOf)
-import GHC.Data.Bag (bagToList)
import GHC.Data.FastString (mkFastString)
import GHC.Data.StringBuffer (StringBuffer, atEnd)
import GHC.Parser.Errors.Ppr ()
@@ -26,10 +25,7 @@ import GHC.Parser.Lexer as Lexer
import qualified GHC.Types.Error as E
import GHC.Types.SourceText
import GHC.Types.SrcLoc
-import GHC.Utils.Error (pprLocMsgEnvelopeDefault)
-import GHC.Utils.Outputable (SDocContext, text, ($$))
-import qualified GHC.Utils.Outputable as Outputable
-import GHC.Utils.Panic (panic)
+import GHC.Utils.Error (panicMessage)
import Haddock.Backends.Hyperlinker.Types as T
import Haddock.GhcUtils
@@ -40,19 +36,14 @@ import Haddock.GhcUtils
-- whitespace, and CPP).
parse
:: ParserOpts
- -> SDocContext
-> FilePath
-- ^ Path to the source of this module
-> BS.ByteString
-- ^ Raw UTF-8 encoded source of this module
-> [T.Token]
-parse parserOpts sDocContext fpath bs = case unP (go False []) initState of
+parse parserOpts fpath bs = case unP (go False []) initState of
POk _ toks -> reverse toks
- PFailed pst ->
- let err : _ = bagToList (E.getMessages $ getPsErrorMessages pst)
- in panic $
- Outputable.renderWithContext sDocContext $
- text "Hyperlinker parse error:" $$ pprLocMsgEnvelopeDefault err
+ PFailed pst -> panicMessage "Hyperlinker parse error:" (E.getMessages $ getPsErrorMessages pst)
where
initState = initParserState parserOpts buf start
buf = stringBufferFromByteString bs
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f10a45a6735383a99607520bfbd25e3…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f10a45a6735383a99607520bfbd25e3…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/sol/rename-mc-diagnostics] Rename `MCDiagnostic` to `InternalMCDiagnostic`
by Simon Hengel (@sol) 25 Jun '26
by Simon Hengel (@sol) 25 Jun '26
25 Jun '26
Simon Hengel pushed to branch wip/sol/rename-mc-diagnostics at Glasgow Haskell Compiler / GHC
Commits:
d2f6112a by Simon Hengel at 2026-06-25T12:36:47+07:00
Rename `MCDiagnostic` to `InternalMCDiagnostic`
`MCDiagnostic` is meant to be used for compiler diagnostics.
Any code that creates `MCDiagnostic` directly, without going through
`GHC.Driver.Errors.printMessage`, sidesteps `-fdiagnostics-as-json` (see
e.g. !14616, !14475, !14492 !14548).
To avoid this in the future, this change more narrowly controls who
creates `MCDiagnostic` (see #24113).
- - - - -
17 changed files:
- compiler/GHC/Driver/Errors.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Types/Error.hs
- − compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/SourceError.hs
- compiler/GHC/Utils/Error.hs
- ghc/GHCi/UI/Exception.hs
- + hadrian/ghci_
- + hadrian/sensei
- utils/check-exact/Main.hs
- utils/check-exact/Preprocess.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
Changes:
=====================================
compiler/GHC/Driver/Errors.hs
=====================================
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
module GHC.Driver.Errors (
reportError
, reportDiagnostic
@@ -66,7 +67,7 @@ printMessage logger msg_opts opts message
doc = updSDocContext (\_ -> ctx) (messageWithHints diagnostic)
messageClass :: MessageClass
- messageClass = MCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
+ messageClass = InternalMCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
style :: PprStyle
style = mkErrStyle (errMsgContext message)
=====================================
compiler/GHC/Driver/Main/Passes.hs
=====================================
@@ -2,6 +2,7 @@
{-# LANGUAGE MultiWayIf #-}
{-# OPTIONS_GHC -fprof-auto-top #-}
+{-# OPTIONS_GHC -Wwarn=x-internalPprMessages #-}
-------------------------------------------------------------------------------
-- | Aspects of GHC.Driver.Main dealing with running particular passes.
@@ -1401,9 +1402,15 @@ markUnsafeInfer tcg_env whyUnsafe = do
whyUnsafe' df = vcat [ quotes pprMod <+> text "has been inferred as unsafe!"
, text "Reason:"
, nest 4 $ (vcat $ badFlags df) $+$
- -- MP: Using defaultDiagnosticOpts here is not right but it's also not right to handle these
- -- unsafety error messages in an unstructured manner.
- (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @e) (getMessages whyUnsafe)) $+$
+
+ -- FIXME: `GHC.Utils.Error.internalPprMessages` is an
+ -- internal function!
+ --
+ -- Use `GHC.Driver.Errors.printMessages` to report the
+ -- diagnostics here and remove `internalPprMessages`
+ -- from the export list of "GHC.Utils.Error".
+ (vcat $ internalPprMessages (getMessages whyUnsafe)) $+$
+
(vcat $ badInsts $ tcg_insts tcg_env)
]
badFlags df = concatMap (badFlag df) unsafeFlagsForInfer
=====================================
compiler/GHC/Driver/Pipeline.hs
=====================================
@@ -101,7 +101,7 @@ import GHC.Iface.Recomp
import GHC.Runtime.Loader ( initializePlugins )
import GHC.Types.Basic ( SuccessFlag(..), ForeignSrcLang(..) )
-import GHC.Types.Error ( singleMessage, getMessages, mkSimpleUnknownDiagnostic, defaultDiagnosticOpts )
+import GHC.Types.Error ( singleMessage, getMessages, mkSimpleUnknownDiagnostic )
import GHC.Types.ForeignStubs ( ForeignStubs (NoStubs) )
import GHC.Types.Target
import GHC.Types.SrcLoc
@@ -169,9 +169,7 @@ preprocess hsc_env input_fn mb_input_buf mb_phase =
to_driver_messages :: Messages GhcMessage -> Messages DriverMessage
to_driver_messages msgs = case traverse to_driver_message msgs of
- Nothing -> pprPanic "non-driver message in preprocess"
- -- MP: Default config is fine here as it's just in a panic.
- (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @GhcMessage) (getMessages msgs))
+ Nothing -> panicMessage "non-driver message in preprocess" (getMessages msgs)
Just msgs' -> msgs'
to_driver_message = \case
=====================================
compiler/GHC/HsToCore/Monad.hs
=====================================
@@ -404,7 +404,7 @@ initTcDsForSolver thing_inside
thing_inside
; case mb_ret of
Just ret -> pure ret
- Nothing -> pprPanic "initTcDsForSolver" (vcat $ pprMsgEnvelopeBagWithLocDefault (getErrorMessages msgs)) }
+ Nothing -> panicMessage "initTcDsForSolver" (getErrorMessages msgs) }
mkDsEnvs :: UnitEnv -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv
-> TcMPluginsRun
=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -71,7 +71,7 @@ import GHC.Core.TyCo.FVs
import GHC.Core.InstEnv
import GHC.Core.TyCon
-import GHC.Utils.Error (diagReasonSeverity, pprLocMsgEnvelope )
+import GHC.Utils.Error (diagReasonSeverity, deferredTypeErrorMessage )
import GHC.Utils.Misc
import GHC.Utils.Outputable as O
import GHC.Utils.Panic
@@ -1395,9 +1395,8 @@ mkErrorTerm ct_loc ty ctxt msg supp hints
hints
-- This will be reported at runtime, so we always want "error:" in the report, never "warning:"
; dflags <- getDynFlags
- ; let err_msg = pprLocMsgEnvelope (initTcMessageOpts dflags) msg
- err_str = showSDoc dflags $
- err_msg $$ text "(deferred type error)"
+ ; let err_msg = deferredTypeErrorMessage (initTcMessageOpts dflags) msg
+ err_str = showSDoc dflags err_msg
; return $ evDelayedError ty err_str }
=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -Wno-x-debugTracePpr #-}
{-
(c) The University of Glasgow 2006
@@ -1432,7 +1433,7 @@ reportDiagnostics = mapM_ reportDiagnostic
reportDiagnostic :: MsgEnvelope TcRnMessage -> TcRn ()
reportDiagnostic msg
- = do { traceTc "Adding diagnostic:" (pprLocMsgEnvelopeDefault msg) ;
+ = do { traceTc "Adding diagnostic:" (debugTracePpr msg) ;
errs_var <- getErrsVar ;
msgs <- readTcRef errs_var ;
writeTcRef errs_var (msg `addMessage` msgs) }
=====================================
compiler/GHC/Types/Error.hs
=====================================
@@ -18,7 +18,7 @@ module GHC.Types.Error
-- * Classifying Messages
- , MessageClass (..)
+ , MessageClass (MCDiagnostic, ..)
, Severity (..)
, Diagnostic (..)
, UnknownDiagnostic (..)
@@ -482,7 +482,7 @@ data MessageClass
-- ^ Log messages intended for end users.
-- No file\/line\/column stuff.
- | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
+ | InternalMCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
-- ^ Diagnostics from the compiler. This constructor is very powerful as
-- it allows the construction of a 'MessageClass' with a completely
-- arbitrary permutation of 'Severity' and 'DiagnosticReason'. As such,
@@ -492,10 +492,19 @@ data MessageClass
-- 'GHC.Utils.Error'. In all the other circumstances, /especially/ when
-- emitting compiler diagnostics, use higher level primitives.
--
+ -- For deconstruction use `MCDiagnostic`.
+ --
-- The @Maybe 'DiagnosticCode'@ field carries a code (if available) for
-- this diagnostic. If you are creating a message not tied to any
-- error-message type, then use Nothing. In the long run, this really
-- should always have a 'DiagnosticCode'. See Note [Diagnostic codes].
+ --
+{-# WARNING in "x-InternalMCDiagnostic" InternalMCDiagnostic
+ "This is an internal constructor. Use `MCDiagnostic` or `GHC.Driver.Errors.printMessages` instead." #-}
+
+{-# COMPLETE MCOutput, MCFatal, MCInteractive, MCDump, MCInfo, MCDiagnostic #-}
+pattern MCDiagnostic :: Severity -> ResolvedDiagnosticReason -> Maybe DiagnosticCode -> MessageClass
+pattern MCDiagnostic severity reason code <- InternalMCDiagnostic severity reason code
{-
Note [Suppressing Messages]
=====================================
compiler/GHC/Types/Error.hs-boot deleted
=====================================
@@ -1,24 +0,0 @@
-module GHC.Types.Error where
-
-import GHC.Prelude (Maybe, Bool, IO)
-import GHC.Utils.Outputable (SDoc)
-import GHC.Types.SrcLoc (SrcSpan)
-
-data MessageClass
- = MCOutput
- | MCFatal
- | MCInteractive
- | MCDump
- | MCInfo
- | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
-
-data Severity
- = SevIgnore
- | SevWarning
- | SevError
-
-data DiagnosticCode
-data ResolvedDiagnosticReason
-
-mkLocMessageWarningGroups :: Bool -> MessageClass -> SrcSpan -> SDoc -> SDoc
-getCaretDiagnostic :: MessageClass -> SrcSpan -> IO SDoc
=====================================
compiler/GHC/Types/SourceError.hs
=====================================
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
-- | Source errors
module GHC.Types.SourceError
( SourceError (..)
@@ -16,8 +17,7 @@ import GHC.Types.Error
import GHC.Utils.Monad
import GHC.Utils.Panic
import GHC.Utils.Exception
-import GHC.Utils.Error (pprMsgEnvelopeBagWithLocDefault, DiagOpts, diag_ppr_ctx)
-import GHC.Utils.Outputable
+import GHC.Utils.Error (debugTraceShow, DiagOpts)
import GHC.Driver.Config.Diagnostic (initDiagOpts, initPrintConfig)
import GHC.Driver.DynFlags (DynFlags, HasDynFlags (getDynFlags))
@@ -73,15 +73,12 @@ initSourceErrorContext dflags =
in SEC diag_opts print_config
instance Show SourceError where
- -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
- -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
+ -- We implement 'Show' because it's required by the 'Exception' instance, but
+ -- diagnostics must not be shown via 'Show', but instead reported via
+ -- `GHC.Driver.Errors.printMessages`.
+ --
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
- show (SourceError (SEC diag_opts _) msgs) =
- renderWithContext (diag_ppr_ctx diag_opts)
- . vcat
- . pprMsgEnvelopeBagWithLocDefault
- . getMessages
- $ msgs
+ show (SourceError _ msgs) = debugTraceShow msgs
instance Exception SourceError
=====================================
compiler/GHC/Utils/Error.hs
=====================================
@@ -1,5 +1,7 @@
{-# LANGUAGE ViewPatterns #-}
+{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
+
{-
(c) The AQUA Project, Glasgow University, 1994-1998
@@ -22,10 +24,11 @@ module GHC.Utils.Error (
errorsFound, isEmptyMessages,
-- ** Formatting
- pprMessageBag, pprMsgEnvelopeBagWithLoc, pprMsgEnvelopeBagWithLocDefault,
- pprMessages,
- pprLocMsgEnvelope, pprLocMsgEnvelopeDefault,
- formatBulleted,
+ pprMessageBag, formatBulleted,
+ deferredTypeErrorMessage,
+ panicMessage, debugTraceShow, debugTracePpr,
+
+ internalPprMessages, -- FIXME: remove this export
-- ** Construction
DiagOpts (..), emptyDiagOpts, diag_wopt, diag_fatal_wopt,
@@ -265,29 +268,40 @@ formatBulleted (unDecorated -> docs)
msgs ctx = filter (not . Outputable.isEmpty ctx) docs
starred = (bullet<+>)
-pprMessages :: Diagnostic e => DiagnosticOpts e -> Messages e -> SDoc
-pprMessages e = vcat . pprMsgEnvelopeBagWithLoc e . getMessages
-
-pprMsgEnvelopeBagWithLoc :: Diagnostic e => DiagnosticOpts e -> Bag (MsgEnvelope e) -> [SDoc]
-pprMsgEnvelopeBagWithLoc e bag = [ pprLocMsgEnvelope e item | item <- sortMsgBag Nothing bag ]
-
--- | Print the messages with the suitable default configuration, usually not what you want but sometimes you don't really
--- care about what the configuration is (for example, if the message is in a panic).
-pprMsgEnvelopeBagWithLocDefault :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
-pprMsgEnvelopeBagWithLocDefault bag = [ pprLocMsgEnvelopeDefault item | item <- sortMsgBag Nothing bag ]
-
-pprLocMsgEnvelopeDefault :: forall e . Diagnostic e => MsgEnvelope e -> SDoc
-pprLocMsgEnvelopeDefault = pprLocMsgEnvelope (defaultDiagnosticOpts @e)
-
-pprLocMsgEnvelope :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
-pprLocMsgEnvelope opts (MsgEnvelope { errMsgSpan = s
+deferredTypeErrorMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+deferredTypeErrorMessage opts msg = internalPrettyMessage opts msg $$ text "(deferred type error)"
+
+panicMessage :: Diagnostic e => String -> Bag (MsgEnvelope e) -> a
+panicMessage name msgs = pprPanic name (vcat $ internalPprMessages msgs)
+
+{-# WARNING in "x-debugTraceShow" debugTraceShow
+ "Don't use this function for reporting diagnostics! Use `GHC.Driver.Errors.printMessages` instead." #-}
+debugTraceShow :: Diagnostic e => Messages e -> String
+debugTraceShow =
+ renderWithContext defaultSDocContext
+ . vcat
+ . internalPprMessages
+ . getMessages
+
+{-# WARNING in "x-debugTracePpr" debugTracePpr
+ "Don't use this function for reporting diagnostics! Use `GHC.Driver.Errors.printMessage` instead." #-}
+debugTracePpr :: forall e. Diagnostic e => MsgEnvelope e -> SDoc
+debugTracePpr = internalPrettyMessage (defaultDiagnosticOpts @e)
+
+{-# WARNING in "x-internalPprMessages" internalPprMessages
+ "This function sidesteps @-fdiagnostics-as-json@! Use `GHC.Driver.Errors.printMessages` instead." #-}
+internalPprMessages :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
+internalPprMessages = map (internalPrettyMessage (defaultDiagnosticOpts @e)) . sortMsgBag Nothing
+
+internalPrettyMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+internalPrettyMessage opts (MsgEnvelope { errMsgSpan = s
, errMsgDiagnostic = e
, errMsgSeverity = sev
, errMsgContext = name_ppr_ctx
, errMsgReason = reason })
= withErrStyle name_ppr_ctx $
mkLocMessage
- (MCDiagnostic sev reason (diagnosticCode e))
+ (InternalMCDiagnostic sev reason (diagnosticCode e))
s
(formatBulleted $ diagnosticMessage opts e)
=====================================
ghc/GHCi/UI/Exception.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
module GHCi.UI.Exception
( GhciCommandError(..)
, throwGhciCommandError
@@ -51,15 +52,12 @@ newtype GhciCommandError = GhciCommandError (Messages GhciMessage)
instance Exception GhciCommandError
instance Show GhciCommandError where
- -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
- -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
+ -- We implement 'Show' because it's required by the 'Exception' instance, but
+ -- diagnostics must not be shown via 'Show', but instead reported via
+ -- `GHC.Driver.Errors.printMessages`.
+ --
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
- show (GhciCommandError msgs) =
- renderWithContext defaultSDocContext
- . vcat
- . pprMsgEnvelopeBagWithLocDefault
- . getMessages
- $ msgs
+ show (GhciCommandError msgs) = debugTraceShow msgs
-- | Perform the given action and call the exception handler if the action
-- throws a 'GhciCommandError'. See 'GhciCommandError' for more information.
=====================================
hadrian/ghci_
=====================================
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+# This file is generated by configure from ghci-cabal.in
+
+set -e
+export TOOL_OUTPUT=.hadrian_ghci/ghci_args
+# Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
+CABFLAGS="-v0 $CABFLAGS" "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
+GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | grep '^-' | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+# GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+ghci $GHC_FLAGS $@ -fwrite-interface -hidir=.hadrian_ghci/interface -O0
=====================================
hadrian/sensei
=====================================
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+# This file is generated by configure from ghci-cabal.in
+
+set -e
+export TOOL_OUTPUT=.hadrian_ghci/ghci_args
+# Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
+CABFLAGS="-v0 $CABFLAGS" "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
+GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | grep '^-' | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+# GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+sensei $GHC_FLAGS $@ -fno-code -fwrite-interface -hidir=.hadrian_ghci/interface -O0
=====================================
utils/check-exact/Main.hs
=====================================
@@ -3,6 +3,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE BangPatterns #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
@@ -11,14 +12,11 @@
import Data.Data
import Data.List (intercalate)
import GHC hiding (moduleName)
-import GHC.Driver.Errors.Types
import GHC.Driver.Ppr
import GHC.Hs.Dump
-import GHC.Types.Error
import GHC.Types.Name.Occurrence
import GHC.Types.Name.Reader
import GHC.Utils.Error
-import GHC.Utils.Outputable
import System.Environment( getArgs )
import System.Exit
import System.FilePath
@@ -369,19 +367,11 @@ parseOneFile :: FilePath -> FilePath -> IO (ParsedSource, [Located Token])
parseOneFile libdir fileName = do
res <- parseModuleEpAnnsWithCpp libdir defaultCppOptions fileName
case res of
- Left m -> error (showErrorMessages m)
+ Left m -> error (debugTraceShow m)
Right (injectedComments, _dflags, pmod) -> do
let !pmodWithComments = insertCppComments pmod injectedComments
return (pmodWithComments, [])
-showErrorMessages :: Messages GhcMessage -> String
-showErrorMessages msgs =
- renderWithContext defaultSDocContext
- $ vcat
- $ pprMsgEnvelopeBagWithLocDefault
- $ getMessages
- $ msgs
-
-- ---------------------------------------------------------------------
exactprintWithChange :: FilePath -> Changer -> ParsedSource -> IO (String, ParsedSource)
=====================================
utils/check-exact/Preprocess.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
-- | This module provides support for CPP, interpreter directives and line
-- pragmas.
module Preprocess
@@ -26,13 +27,11 @@ import qualified GHC.Driver.Phases as GHC
import qualified GHC.Driver.Pipeline as GHC
import qualified GHC.Parser.Lexer as GHC
import qualified GHC.Settings as GHC
-import qualified GHC.Types.Error as GHC
import qualified GHC.Types.SourceError as GHC
import qualified GHC.Types.SourceFile as GHC
import qualified GHC.Types.SrcLoc as GHC
import qualified GHC.Utils.Error as GHC
import qualified GHC.Utils.Fingerprint as GHC
-import qualified GHC.Utils.Outputable as GHC
import GHC.Types.SrcLoc (mkSrcSpan, mkSrcLoc)
import GHC.Data.FastString (mkFastString)
@@ -216,20 +215,12 @@ getPreprocessedSrcDirectPrim cppOptions src_fn = do
new_env = hsc_env { GHC.hsc_dflags = injectCppOptions cppOptions dfs }
r <- GHC.liftIO $ GHC.preprocess new_env src_fn Nothing (Just (GHC.Cpp GHC.HsSrcFile))
case r of
- Left err -> error $ showErrorMessages err
+ Left err -> error $ GHC.debugTraceShow err
Right (dflags', hspp_fn) -> do
buf <- GHC.liftIO $ GHC.hGetStringBuffer hspp_fn
txt <- GHC.liftIO $ readFileGhc hspp_fn
return (txt, buf, dflags')
-showErrorMessages :: GHC.Messages GHC.DriverMessage -> String
-showErrorMessages msgs =
- GHC.renderWithContext GHC.defaultSDocContext
- $ GHC.vcat
- $ GHC.pprMsgEnvelopeBagWithLocDefault
- $ GHC.getMessages
- $ msgs
-
injectCppOptions :: CppOptions -> GHC.DynFlags -> GHC.DynFlags
injectCppOptions CppOptions{..} dflags = folded_opt
where
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
=====================================
@@ -97,7 +97,7 @@ ppHyperlinkedModuleSource verbosity srcdir pretty srcs iface = do
mast
| M.size asts == 1 = snd <$> M.lookupMin asts
| otherwise = M.lookup (HiePath (mkFastString file)) asts
- tokens' = parse parserOpts sDocContext file rawSrc
+ tokens' = parse parserOpts file rawSrc
ast = fromMaybe (emptyHieAst fileFs) mast
fullAst = recoverFullIfaceTypes sDocContext types ast
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
=====================================
@@ -9,7 +9,6 @@ import Control.Monad.Trans.Class
import Control.Monad.Trans.Maybe
import qualified Data.ByteString as BS
import Data.List (isPrefixOf, isSuffixOf)
-import GHC.Data.Bag (bagToList)
import GHC.Data.FastString (mkFastString)
import GHC.Data.StringBuffer (StringBuffer, atEnd)
import GHC.Parser.Errors.Ppr ()
@@ -26,10 +25,7 @@ import GHC.Parser.Lexer as Lexer
import qualified GHC.Types.Error as E
import GHC.Types.SourceText
import GHC.Types.SrcLoc
-import GHC.Utils.Error (pprLocMsgEnvelopeDefault)
-import GHC.Utils.Outputable (SDocContext, text, ($$))
-import qualified GHC.Utils.Outputable as Outputable
-import GHC.Utils.Panic (panic)
+import GHC.Utils.Error (panicMessage)
import Haddock.Backends.Hyperlinker.Types as T
import Haddock.GhcUtils
@@ -40,19 +36,14 @@ import Haddock.GhcUtils
-- whitespace, and CPP).
parse
:: ParserOpts
- -> SDocContext
-> FilePath
-- ^ Path to the source of this module
-> BS.ByteString
-- ^ Raw UTF-8 encoded source of this module
-> [T.Token]
-parse parserOpts sDocContext fpath bs = case unP (go False []) initState of
+parse parserOpts fpath bs = case unP (go False []) initState of
POk _ toks -> reverse toks
- PFailed pst ->
- let err : _ = bagToList (E.getMessages $ getPsErrorMessages pst)
- in panic $
- Outputable.renderWithContext sDocContext $
- text "Hyperlinker parse error:" $$ pprLocMsgEnvelopeDefault err
+ PFailed pst -> panicMessage "Hyperlinker parse error:" (E.getMessages $ getPsErrorMessages pst)
where
initState = initParserState parserOpts buf start
buf = stringBufferFromByteString bs
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2f6112a3c4095f1dbe59d1fb16a896…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2f6112a3c4095f1dbe59d1fb16a896…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/sol/rename-mc-diagnostics] Rename `MCDiagnostic` to `InternalMCDiagnostic`
by Simon Hengel (@sol) 25 Jun '26
by Simon Hengel (@sol) 25 Jun '26
25 Jun '26
Simon Hengel pushed to branch wip/sol/rename-mc-diagnostics at Glasgow Haskell Compiler / GHC
Commits:
63fb1efd by Simon Hengel at 2026-06-25T12:29:15+07:00
Rename `MCDiagnostic` to `InternalMCDiagnostic`
`MCDiagnostic` is meant to be used for compiler diagnostics.
Any code that creates `MCDiagnostic` directly, without going through
`GHC.Driver.Errors.printMessage`, sidesteps `-fdiagnostics-as-json` (see
e.g. !14616, !14475, !14492 !14548).
To avoid this in the future, this change more narrowly controls who
creates `MCDiagnostic` (see #24113).
- - - - -
17 changed files:
- compiler/GHC/Driver/Errors.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Types/Error.hs
- − compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/SourceError.hs
- compiler/GHC/Utils/Error.hs
- ghc/GHCi/UI/Exception.hs
- + hadrian/ghci_
- + hadrian/sensei
- utils/check-exact/Main.hs
- utils/check-exact/Preprocess.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
Changes:
=====================================
compiler/GHC/Driver/Errors.hs
=====================================
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
module GHC.Driver.Errors (
reportError
, reportDiagnostic
@@ -66,7 +67,7 @@ printMessage logger msg_opts opts message
doc = updSDocContext (\_ -> ctx) (messageWithHints diagnostic)
messageClass :: MessageClass
- messageClass = MCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
+ messageClass = InternalMCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
style :: PprStyle
style = mkErrStyle (errMsgContext message)
=====================================
compiler/GHC/Driver/Main/Passes.hs
=====================================
@@ -2,6 +2,7 @@
{-# LANGUAGE MultiWayIf #-}
{-# OPTIONS_GHC -fprof-auto-top #-}
+{-# OPTIONS_GHC -Wwarn=x-internalPprMessages #-}
-------------------------------------------------------------------------------
-- | Aspects of GHC.Driver.Main dealing with running particular passes.
@@ -1401,9 +1402,15 @@ markUnsafeInfer tcg_env whyUnsafe = do
whyUnsafe' df = vcat [ quotes pprMod <+> text "has been inferred as unsafe!"
, text "Reason:"
, nest 4 $ (vcat $ badFlags df) $+$
- -- MP: Using defaultDiagnosticOpts here is not right but it's also not right to handle these
- -- unsafety error messages in an unstructured manner.
- (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @e) (getMessages whyUnsafe)) $+$
+
+ -- FIXME: `GHC.Utils.Error.internalPprMessages` is an
+ -- internal function!
+ --
+ -- Use `GHC.Driver.Errors.printMessages` to report the
+ -- diagnostics here and remove `internalPprMessages`
+ -- from the export list of "GHC.Utils.Error".
+ (vcat $ internalPprMessages (getMessages whyUnsafe)) $+$
+
(vcat $ badInsts $ tcg_insts tcg_env)
]
badFlags df = concatMap (badFlag df) unsafeFlagsForInfer
=====================================
compiler/GHC/Driver/Pipeline.hs
=====================================
@@ -101,7 +101,7 @@ import GHC.Iface.Recomp
import GHC.Runtime.Loader ( initializePlugins )
import GHC.Types.Basic ( SuccessFlag(..), ForeignSrcLang(..) )
-import GHC.Types.Error ( singleMessage, getMessages, mkSimpleUnknownDiagnostic, defaultDiagnosticOpts )
+import GHC.Types.Error ( singleMessage, getMessages, mkSimpleUnknownDiagnostic )
import GHC.Types.ForeignStubs ( ForeignStubs (NoStubs) )
import GHC.Types.Target
import GHC.Types.SrcLoc
@@ -169,9 +169,7 @@ preprocess hsc_env input_fn mb_input_buf mb_phase =
to_driver_messages :: Messages GhcMessage -> Messages DriverMessage
to_driver_messages msgs = case traverse to_driver_message msgs of
- Nothing -> pprPanic "non-driver message in preprocess"
- -- MP: Default config is fine here as it's just in a panic.
- (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @GhcMessage) (getMessages msgs))
+ Nothing -> panicMessage "non-driver message in preprocess" (getMessages msgs)
Just msgs' -> msgs'
to_driver_message = \case
=====================================
compiler/GHC/HsToCore/Monad.hs
=====================================
@@ -404,7 +404,7 @@ initTcDsForSolver thing_inside
thing_inside
; case mb_ret of
Just ret -> pure ret
- Nothing -> pprPanic "initTcDsForSolver" (vcat $ pprMsgEnvelopeBagWithLocDefault (getErrorMessages msgs)) }
+ Nothing -> panicMessage "initTcDsForSolver" (getErrorMessages msgs) }
mkDsEnvs :: UnitEnv -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv
-> TcMPluginsRun
=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -71,7 +71,7 @@ import GHC.Core.TyCo.FVs
import GHC.Core.InstEnv
import GHC.Core.TyCon
-import GHC.Utils.Error (diagReasonSeverity, pprLocMsgEnvelope )
+import GHC.Utils.Error (diagReasonSeverity, deferredTypeErrorMessage )
import GHC.Utils.Misc
import GHC.Utils.Outputable as O
import GHC.Utils.Panic
@@ -1395,9 +1395,8 @@ mkErrorTerm ct_loc ty ctxt msg supp hints
hints
-- This will be reported at runtime, so we always want "error:" in the report, never "warning:"
; dflags <- getDynFlags
- ; let err_msg = pprLocMsgEnvelope (initTcMessageOpts dflags) msg
- err_str = showSDoc dflags $
- err_msg $$ text "(deferred type error)"
+ ; let err_msg = deferredTypeErrorMessage (initTcMessageOpts dflags) msg
+ err_str = showSDoc dflags err_msg
; return $ evDelayedError ty err_str }
=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -Wno-x-debugTracePpr #-}
{-
(c) The University of Glasgow 2006
@@ -1432,7 +1433,7 @@ reportDiagnostics = mapM_ reportDiagnostic
reportDiagnostic :: MsgEnvelope TcRnMessage -> TcRn ()
reportDiagnostic msg
- = do { traceTc "Adding diagnostic:" (pprLocMsgEnvelopeDefault msg) ;
+ = do { traceTc "Adding diagnostic:" (debugTracePpr defaultOpts msg) ;
errs_var <- getErrsVar ;
msgs <- readTcRef errs_var ;
writeTcRef errs_var (msg `addMessage` msgs) }
=====================================
compiler/GHC/Types/Error.hs
=====================================
@@ -18,7 +18,7 @@ module GHC.Types.Error
-- * Classifying Messages
- , MessageClass (..)
+ , MessageClass (MCDiagnostic, ..)
, Severity (..)
, Diagnostic (..)
, UnknownDiagnostic (..)
@@ -482,7 +482,7 @@ data MessageClass
-- ^ Log messages intended for end users.
-- No file\/line\/column stuff.
- | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
+ | InternalMCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
-- ^ Diagnostics from the compiler. This constructor is very powerful as
-- it allows the construction of a 'MessageClass' with a completely
-- arbitrary permutation of 'Severity' and 'DiagnosticReason'. As such,
@@ -492,10 +492,19 @@ data MessageClass
-- 'GHC.Utils.Error'. In all the other circumstances, /especially/ when
-- emitting compiler diagnostics, use higher level primitives.
--
+ -- For deconstruction use `MCDiagnostic`.
+ --
-- The @Maybe 'DiagnosticCode'@ field carries a code (if available) for
-- this diagnostic. If you are creating a message not tied to any
-- error-message type, then use Nothing. In the long run, this really
-- should always have a 'DiagnosticCode'. See Note [Diagnostic codes].
+ --
+{-# WARNING in "x-InternalMCDiagnostic" InternalMCDiagnostic
+ "This is an internal constructor. Use `MCDiagnostic` or `GHC.Driver.Errors.printMessages` instead." #-}
+
+{-# COMPLETE MCOutput, MCFatal, MCInteractive, MCDump, MCInfo, MCDiagnostic #-}
+pattern MCDiagnostic :: Severity -> ResolvedDiagnosticReason -> Maybe DiagnosticCode -> MessageClass
+pattern MCDiagnostic severity reason code <- InternalMCDiagnostic severity reason code
{-
Note [Suppressing Messages]
=====================================
compiler/GHC/Types/Error.hs-boot deleted
=====================================
@@ -1,24 +0,0 @@
-module GHC.Types.Error where
-
-import GHC.Prelude (Maybe, Bool, IO)
-import GHC.Utils.Outputable (SDoc)
-import GHC.Types.SrcLoc (SrcSpan)
-
-data MessageClass
- = MCOutput
- | MCFatal
- | MCInteractive
- | MCDump
- | MCInfo
- | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
-
-data Severity
- = SevIgnore
- | SevWarning
- | SevError
-
-data DiagnosticCode
-data ResolvedDiagnosticReason
-
-mkLocMessageWarningGroups :: Bool -> MessageClass -> SrcSpan -> SDoc -> SDoc
-getCaretDiagnostic :: MessageClass -> SrcSpan -> IO SDoc
=====================================
compiler/GHC/Types/SourceError.hs
=====================================
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
-- | Source errors
module GHC.Types.SourceError
( SourceError (..)
@@ -16,8 +17,7 @@ import GHC.Types.Error
import GHC.Utils.Monad
import GHC.Utils.Panic
import GHC.Utils.Exception
-import GHC.Utils.Error (pprMsgEnvelopeBagWithLocDefault, DiagOpts, diag_ppr_ctx)
-import GHC.Utils.Outputable
+import GHC.Utils.Error (debugTraceShow, DiagOpts)
import GHC.Driver.Config.Diagnostic (initDiagOpts, initPrintConfig)
import GHC.Driver.DynFlags (DynFlags, HasDynFlags (getDynFlags))
@@ -73,15 +73,12 @@ initSourceErrorContext dflags =
in SEC diag_opts print_config
instance Show SourceError where
- -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
- -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
+ -- We implement 'Show' because it's required by the 'Exception' instance, but
+ -- diagnostics must not be shown via 'Show', but instead reported via
+ -- `GHC.Driver.Errors.printMessages`.
+ --
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
- show (SourceError (SEC diag_opts _) msgs) =
- renderWithContext (diag_ppr_ctx diag_opts)
- . vcat
- . pprMsgEnvelopeBagWithLocDefault
- . getMessages
- $ msgs
+ show (SourceError _ msgs) = debugTraceShow msgs
instance Exception SourceError
=====================================
compiler/GHC/Utils/Error.hs
=====================================
@@ -1,5 +1,7 @@
{-# LANGUAGE ViewPatterns #-}
+{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
+
{-
(c) The AQUA Project, Glasgow University, 1994-1998
@@ -22,10 +24,11 @@ module GHC.Utils.Error (
errorsFound, isEmptyMessages,
-- ** Formatting
- pprMessageBag, pprMsgEnvelopeBagWithLoc, pprMsgEnvelopeBagWithLocDefault,
- pprMessages,
- pprLocMsgEnvelope, pprLocMsgEnvelopeDefault,
- formatBulleted,
+ pprMessageBag, formatBulleted,
+ deferredTypeErrorMessage,
+ panicMessage, debugTraceShow, debugTracePpr,
+
+ internalPprMessages, -- FIXME: remove this export
-- ** Construction
DiagOpts (..), emptyDiagOpts, diag_wopt, diag_fatal_wopt,
@@ -265,29 +268,40 @@ formatBulleted (unDecorated -> docs)
msgs ctx = filter (not . Outputable.isEmpty ctx) docs
starred = (bullet<+>)
-pprMessages :: Diagnostic e => DiagnosticOpts e -> Messages e -> SDoc
-pprMessages e = vcat . pprMsgEnvelopeBagWithLoc e . getMessages
-
-pprMsgEnvelopeBagWithLoc :: Diagnostic e => DiagnosticOpts e -> Bag (MsgEnvelope e) -> [SDoc]
-pprMsgEnvelopeBagWithLoc e bag = [ pprLocMsgEnvelope e item | item <- sortMsgBag Nothing bag ]
-
--- | Print the messages with the suitable default configuration, usually not what you want but sometimes you don't really
--- care about what the configuration is (for example, if the message is in a panic).
-pprMsgEnvelopeBagWithLocDefault :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
-pprMsgEnvelopeBagWithLocDefault bag = [ pprLocMsgEnvelopeDefault item | item <- sortMsgBag Nothing bag ]
-
-pprLocMsgEnvelopeDefault :: forall e . Diagnostic e => MsgEnvelope e -> SDoc
-pprLocMsgEnvelopeDefault = pprLocMsgEnvelope (defaultDiagnosticOpts @e)
-
-pprLocMsgEnvelope :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
-pprLocMsgEnvelope opts (MsgEnvelope { errMsgSpan = s
+deferredTypeErrorMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+deferredTypeErrorMessage opts msg = internalPrettyMessage opts msg $$ text "(deferred type error)"
+
+panicMessage :: Diagnostic e => String -> Bag (MsgEnvelope e) -> a
+panicMessage name msgs = pprPanic name (vcat $ internalPprMessages msgs)
+
+{-# WARNING in "x-debugTraceShow" debugTraceShow
+ "Don't use this function for reporting diagnostics! Use `GHC.Driver.Errors.printMessages` instead." #-}
+debugTraceShow :: Diagnostic e => Messages e -> String
+debugTraceShow =
+ renderWithContext defaultSDocContext
+ . vcat
+ . internalPprMessages
+ . getMessages
+
+{-# WARNING in "x-debugTracePpr" debugTracePpr
+ "Don't use this function for reporting diagnostics! Use `GHC.Driver.Errors.printMessage` instead." #-}
+debugTracePpr :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+debugTracePpr = internalPrettyMessage
+
+{-# WARNING in "x-internalPprMessages" internalPprMessages
+ "This function sidesteps @-fdiagnostics-as-json@! Use `GHC.Driver.Errors.printMessages` instead." #-}
+internalPprMessages :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
+internalPprMessages = map (internalPrettyMessage (defaultDiagnosticOpts @e)) . sortMsgBag Nothing
+
+internalPrettyMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
+internalPrettyMessage opts (MsgEnvelope { errMsgSpan = s
, errMsgDiagnostic = e
, errMsgSeverity = sev
, errMsgContext = name_ppr_ctx
, errMsgReason = reason })
= withErrStyle name_ppr_ctx $
mkLocMessage
- (MCDiagnostic sev reason (diagnosticCode e))
+ (InternalMCDiagnostic sev reason (diagnosticCode e))
s
(formatBulleted $ diagnosticMessage opts e)
=====================================
ghc/GHCi/UI/Exception.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
module GHCi.UI.Exception
( GhciCommandError(..)
, throwGhciCommandError
@@ -51,15 +52,12 @@ newtype GhciCommandError = GhciCommandError (Messages GhciMessage)
instance Exception GhciCommandError
instance Show GhciCommandError where
- -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
- -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
+ -- We implement 'Show' because it's required by the 'Exception' instance, but
+ -- diagnostics must not be shown via 'Show', but instead reported via
+ -- `GHC.Driver.Errors.printMessages`.
+ --
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
- show (GhciCommandError msgs) =
- renderWithContext defaultSDocContext
- . vcat
- . pprMsgEnvelopeBagWithLocDefault
- . getMessages
- $ msgs
+ show (GhciCommandError msgs) = debugTraceShow msgs
-- | Perform the given action and call the exception handler if the action
-- throws a 'GhciCommandError'. See 'GhciCommandError' for more information.
=====================================
hadrian/ghci_
=====================================
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+# This file is generated by configure from ghci-cabal.in
+
+set -e
+export TOOL_OUTPUT=.hadrian_ghci/ghci_args
+# Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
+CABFLAGS="-v0 $CABFLAGS" "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
+GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | grep '^-' | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+# GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+ghci $GHC_FLAGS $@ -fwrite-interface -hidir=.hadrian_ghci/interface -O0
=====================================
hadrian/sensei
=====================================
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+# This file is generated by configure from ghci-cabal.in
+
+set -e
+export TOOL_OUTPUT=.hadrian_ghci/ghci_args
+# Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
+CABFLAGS="-v0 $CABFLAGS" "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
+GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | grep '^-' | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+# GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | sed "s|$(pwd)/||g" | tr '\n\r' ' ')"
+sensei $GHC_FLAGS $@ -fno-code -fwrite-interface -hidir=.hadrian_ghci/interface -O0
=====================================
utils/check-exact/Main.hs
=====================================
@@ -3,6 +3,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE BangPatterns #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
@@ -11,14 +12,11 @@
import Data.Data
import Data.List (intercalate)
import GHC hiding (moduleName)
-import GHC.Driver.Errors.Types
import GHC.Driver.Ppr
import GHC.Hs.Dump
-import GHC.Types.Error
import GHC.Types.Name.Occurrence
import GHC.Types.Name.Reader
import GHC.Utils.Error
-import GHC.Utils.Outputable
import System.Environment( getArgs )
import System.Exit
import System.FilePath
@@ -369,19 +367,11 @@ parseOneFile :: FilePath -> FilePath -> IO (ParsedSource, [Located Token])
parseOneFile libdir fileName = do
res <- parseModuleEpAnnsWithCpp libdir defaultCppOptions fileName
case res of
- Left m -> error (showErrorMessages m)
+ Left m -> error (debugTraceShow m)
Right (injectedComments, _dflags, pmod) -> do
let !pmodWithComments = insertCppComments pmod injectedComments
return (pmodWithComments, [])
-showErrorMessages :: Messages GhcMessage -> String
-showErrorMessages msgs =
- renderWithContext defaultSDocContext
- $ vcat
- $ pprMsgEnvelopeBagWithLocDefault
- $ getMessages
- $ msgs
-
-- ---------------------------------------------------------------------
exactprintWithChange :: FilePath -> Changer -> ParsedSource -> IO (String, ParsedSource)
=====================================
utils/check-exact/Preprocess.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
+{-# OPTIONS_GHC -Wno-x-debugTraceShow #-}
-- | This module provides support for CPP, interpreter directives and line
-- pragmas.
module Preprocess
@@ -26,13 +27,11 @@ import qualified GHC.Driver.Phases as GHC
import qualified GHC.Driver.Pipeline as GHC
import qualified GHC.Parser.Lexer as GHC
import qualified GHC.Settings as GHC
-import qualified GHC.Types.Error as GHC
import qualified GHC.Types.SourceError as GHC
import qualified GHC.Types.SourceFile as GHC
import qualified GHC.Types.SrcLoc as GHC
import qualified GHC.Utils.Error as GHC
import qualified GHC.Utils.Fingerprint as GHC
-import qualified GHC.Utils.Outputable as GHC
import GHC.Types.SrcLoc (mkSrcSpan, mkSrcLoc)
import GHC.Data.FastString (mkFastString)
@@ -216,20 +215,12 @@ getPreprocessedSrcDirectPrim cppOptions src_fn = do
new_env = hsc_env { GHC.hsc_dflags = injectCppOptions cppOptions dfs }
r <- GHC.liftIO $ GHC.preprocess new_env src_fn Nothing (Just (GHC.Cpp GHC.HsSrcFile))
case r of
- Left err -> error $ showErrorMessages err
+ Left err -> error $ GHC.debugTraceShow err
Right (dflags', hspp_fn) -> do
buf <- GHC.liftIO $ GHC.hGetStringBuffer hspp_fn
txt <- GHC.liftIO $ readFileGhc hspp_fn
return (txt, buf, dflags')
-showErrorMessages :: GHC.Messages GHC.DriverMessage -> String
-showErrorMessages msgs =
- GHC.renderWithContext GHC.defaultSDocContext
- $ GHC.vcat
- $ GHC.pprMsgEnvelopeBagWithLocDefault
- $ GHC.getMessages
- $ msgs
-
injectCppOptions :: CppOptions -> GHC.DynFlags -> GHC.DynFlags
injectCppOptions CppOptions{..} dflags = folded_opt
where
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
=====================================
@@ -97,7 +97,7 @@ ppHyperlinkedModuleSource verbosity srcdir pretty srcs iface = do
mast
| M.size asts == 1 = snd <$> M.lookupMin asts
| otherwise = M.lookup (HiePath (mkFastString file)) asts
- tokens' = parse parserOpts sDocContext file rawSrc
+ tokens' = parse parserOpts file rawSrc
ast = fromMaybe (emptyHieAst fileFs) mast
fullAst = recoverFullIfaceTypes sDocContext types ast
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
=====================================
@@ -9,7 +9,6 @@ import Control.Monad.Trans.Class
import Control.Monad.Trans.Maybe
import qualified Data.ByteString as BS
import Data.List (isPrefixOf, isSuffixOf)
-import GHC.Data.Bag (bagToList)
import GHC.Data.FastString (mkFastString)
import GHC.Data.StringBuffer (StringBuffer, atEnd)
import GHC.Parser.Errors.Ppr ()
@@ -26,10 +25,7 @@ import GHC.Parser.Lexer as Lexer
import qualified GHC.Types.Error as E
import GHC.Types.SourceText
import GHC.Types.SrcLoc
-import GHC.Utils.Error (pprLocMsgEnvelopeDefault)
-import GHC.Utils.Outputable (SDocContext, text, ($$))
-import qualified GHC.Utils.Outputable as Outputable
-import GHC.Utils.Panic (panic)
+import GHC.Utils.Error (panicMessage)
import Haddock.Backends.Hyperlinker.Types as T
import Haddock.GhcUtils
@@ -40,19 +36,14 @@ import Haddock.GhcUtils
-- whitespace, and CPP).
parse
:: ParserOpts
- -> SDocContext
-> FilePath
-- ^ Path to the source of this module
-> BS.ByteString
-- ^ Raw UTF-8 encoded source of this module
-> [T.Token]
-parse parserOpts sDocContext fpath bs = case unP (go False []) initState of
+parse parserOpts fpath bs = case unP (go False []) initState of
POk _ toks -> reverse toks
- PFailed pst ->
- let err : _ = bagToList (E.getMessages $ getPsErrorMessages pst)
- in panic $
- Outputable.renderWithContext sDocContext $
- text "Hyperlinker parse error:" $$ pprLocMsgEnvelopeDefault err
+ PFailed pst -> panicMessage "Hyperlinker parse error:" (E.getMessages $ getPsErrorMessages pst)
where
initState = initParserState parserOpts buf start
buf = stringBufferFromByteString bs
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/63fb1efd9ac045f5a685fefa108eeac…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/63fb1efd9ac045f5a685fefa108eeac…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/sol/rename-mc-diagnostics] 21 commits: Add missing req_interp modifier to T18441fail3 and T18441fail19
by Simon Hengel (@sol) 25 Jun '26
by Simon Hengel (@sol) 25 Jun '26
25 Jun '26
Simon Hengel pushed to branch wip/sol/rename-mc-diagnostics at Glasgow Haskell Compiler / GHC
Commits:
09326ca6 by Matthew Pickering at 2026-06-20T23:41:12+02:00
Add missing req_interp modifier to T18441fail3 and T18441fail19
These tests require the interpreter but they were failing in a different
way with the javascript backend because the interpreter was disabled and
stderr is ignored by the test.
- - - - -
521e55bf by Matthew Pickering at 2026-06-20T23:41:13+02:00
hadrian: Fill in more of the default.host toolchain file
When you are building a cross compiler this file will be used to build
stage1 and it's libraries, so we need enough information here to work
accurately. There is still more work to be done (see for example, word
size is still fixed).
- - - - -
23c9b6c3 by Matthew Pickering at 2026-06-20T23:42:52+02:00
hadrian: Build stage 2 cross compilers
* Most of hadrian is abstracted over the stage in order to remove the
assumption that the target of all stages is the same platform. This
allows the RTS to be built for two different targets for example.
* Abstracts the bindist creation logic to allow building either normal
or cross bindists. Normal bindists use stage 1 libraries and a stage 2
compiler. Cross bindists use stage 2 libararies and a stage 2
compiler.
* hadrian: Make binary-dist-dir the default build target. This allows us
to have the logic in one place about which libraries/stages to build
with cross compilers. Fixes #24192
New hadrian target:
* `binary-dist-dir-cross`: Build a cross compiler bindist (compiler =
stage 1, libraries = stage 2)
This commit also contains various changes to make stage2 compilers
feasible.
-------------------------
Metric Decrease:
LinkableUsage02
ManyAlternatives
ManyConstructors
MultiComponentModulesRecomp
MultiLayerModulesRecomp
RecordUpdPerf
T10421
T12150
T12227
T12425
T12707
T13035
T13379
T13820
T15703
T16577
T18140
T18282
T18698a
T18698b
T18923
T1969
T20049
T21839c
T3294
T4801
T5030
T5321FD
T5321Fun
T5631
T5642
T6048
T783
T9020
T9198
T9233
T9630
T9872d
T9961
parsing001
T3064
Metric Increase:
T26989
hard_hole_fits
-------------------------
Co-authored-by: Sven Tennie <sven.tennie(a)gmail.com>
- - - - -
26fed8ab by Matthew Pickering at 2026-06-20T23:42:52+02:00
ci: Test cross bindists
We remove the special logic for testing in-tree cross
compilers and instead test cross compiler bindists, like we do for all
other platforms.
- - - - -
80c8910e by Matthew Pickering at 2026-06-20T23:42:52+02:00
ci: Introduce CROSS_STAGE variable
In preparation for building and testing stage3 bindists we introduce the
CROSS_STAGE variable which is used by a CI job to determine what kind of
bindist the CI job should produce.
At the moment we are only using CROSS_STAGE=2 but in the future we will
have some jobs which set CROSS_STAGE=3 to produce native bindists for a
target, but produced by a cross compiler, which can be tested on by
another CI job on the native platform.
CROSS_STAGE=2: Build a normal cross compiler bindist
CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target
- - - - -
8215573d by Sven Tennie at 2026-06-20T23:42:52+02:00
ci: Increase timeout for emulators
Test runs with emulators naturally take longer than on native machines.
Generate jobs.yml
- - - - -
5acb7dbc by Matthew Pickering at 2026-06-20T23:42:52+02:00
ci: Javascript don't set CROSS_EMULATOR
There is no CROSS_EMULATOR needed to run javascript binaries, so we
don't set the CROSS_EMULATOR to some dummy value.
- - - - -
48345343 by Sven Tennie at 2026-06-20T23:42:52+02:00
Javascript skip T23697
See #22355 about how HSC2HS and the Javascript target don't play well
together.
- - - - -
5e44fd05 by Sven Tennie at 2026-06-20T23:42:52+02:00
Mark T24602 as fragile
It was skipped before (due to CROSS_EMULATOR being set, which changed
for JS), so we don't make things worse by marking it as fragile.
- - - - -
ab349ec2 by Sven Tennie at 2026-06-20T23:42:52+02:00
Fix T22744 for GHCJS
In fact, this test needs Template Haskell, not necessarily an
interpreter.
- - - - -
c73352d8 by Sven Tennie at 2026-06-20T23:42:52+02:00
haddock-test: fix GHCJS haddock test failures
Add --ghc-pkg-path flag support so haddock test runner can find
cross-prefixed ghc-pkg (e.g. javascript-unknown-ghcjs-ghc-pkg) which
is not on $PATH in cross install directories.
Skip haddockHtmlTest on GHCJS: Threaded.hs uses forkOS in a TH splice,
which GHCJS RTS doesn't support. Mark with js_skip in all.T.
- - - - -
5e814e76 by Andreas Klebinger at 2026-06-22T23:00:24-04:00
compiler: Deduplicate hscTidy
This function was accidentally duplicated during a refactor.
Fixes #27351
- - - - -
473b97eb by sheaf at 2026-06-22T23:01:22-04:00
Avoid mkTick in Core Prep breaking ANF (part II)
Hotfix for 2f9579765f55b3920ceb2e04995ff41a9d0e2d4e fixing a small
oversight in the call to tickTickedExpr from mkTick, in which we
improperly recursively called mkTick without passing on the preserve_anf
flag.
Fixes #27386
- - - - -
9284a1f7 by Simon Hengel at 2026-06-23T05:55:33-04:00
Don't use global variables to address concurrency bugs! (fixes #27234)
This was originally introduce with
88f38b03025386f0f1e8f5861eed67d80495168a to address #17922.
In this specific case a better fix would have been to synchronize on
stderr:
withHandle_ "stderrSupportsAnsiColors" stderr $ \ _ -> do
...
But apparently the dependency on `terminfo` was removed in
32ab07bf3d6ce45e8ea5b55e8095174a6b42a7f0, preventing #17922 in the first
place.
- - - - -
44309cd3 by Alan Zimmerman at 2026-06-23T05:56:20-04:00
EPA: remove LocatedL / SrcSpanAnnL and LocatedLI / SrcSpanAnnLI
This is part of a refactor towards only having LocatedA / SrcSpanAnnA
It removes the stated items, but has to add back one for BooleanFormula,
LocatedBF / SrcSpanAnnBF
This commit also use the HsConDetails RecCon extension point to
capture the braces in a record constructor
- - - - -
2f6a5534 by Simon Jakobi at 2026-06-23T15:46:20+02:00
Add -dstable-core-dump-order for stable Core dump ordering (#27296)
The order of top-level bindings in Core dumps (-ddump-simpl etc.) is the
compiler's Unique-sensitive internal processing order, so an unrelated
upstream change can reorder them and defeat a textual diff of two dumps.
This adds an opt-in flag -dstable-core-dump-order that reorders the
top-level bindings of dumps routed through dumpPassResult into a stable,
Unique-independent order, so two dumps line up across rebuilds. See
Note [Stable Core dump order] in GHC.Core.Ppr for the sort key and its
rationale.
Adds tests T27296 (binders GHC emits in non-source order by default,
asserted to come out stably ordered under the flag) and T27296b (an
untidied -ddump-float-out dump pinning the ordering of the anonymous lvl
floats by literal value).
Co-Authored-By: Claude Opus 4.8 <noreply(a)anthropic.com>
- - - - -
141986e3 by mangoiv at 2026-06-24T15:51:14-04:00
compiler: refactor error reporting code for ExplicitLevelImports
Refactors error reporting code for ExplicitLevelImports to pass in a
RdrName and a GlobalReaderElt to be able to report errors that are
faithful to the source and to more precisely distinguish between names
that are in scope from different qualifications.
Fixes #27385 and #26616
- - - - -
aa7df6b6 by Simon Hengel at 2026-06-24T15:52:18-04:00
Set GHC_VERSION when calling custom pre-processors (see #25952)
(so that pre-processors can emit backwards compatible code)
- - - - -
a9e494f2 by Simon Hengel at 2026-06-24T15:54:08-04:00
Add a flag to control GHCi specific error hints (close #27409)
- - - - -
a805b2a2 by Simon Hengel at 2026-06-24T15:55:20-04:00
Reference correct package in error messages for reexported modules
(fixes #27417)
- - - - -
d39d7335 by Simon Hengel at 2026-06-25T12:22:57+07:00
Rename `MCDiagnostic` to `InternalMCDiagnostic`
`MCDiagnostic` is meant to be used for compiler diagnostics.
Any code that creates `MCDiagnostic` directly, without going through
`GHC.Driver.Errors.printMessage`, sidesteps `-fdiagnostics-as-json` (see
e.g. !14616, !14475, !14492 !14548).
To avoid this in the future, this change more narrowly controls who
creates `MCDiagnostic` (see #24113).
- - - - -
245 changed files:
- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- + changelog.d/26616
- + changelog.d/T27386
- + changelog.d/interactive-error-hints
- + changelog.d/pp-set-ghc-version
- + changelog.d/reexported-module-errors
- + changelog.d/stable-core-dump-order-27296
- + changelog.d/stage2-cross-compilers
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Ppr.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Data/BooleanFormula.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Errors.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main/Interactive.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Main/Passes.hs-boot
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Stats.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Errors.hs
- compiler/GHC/Iface/Errors/Ppr.hs
- compiler/GHC/Iface/Errors/Types.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Splice.hs-boot
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/SysTools/Tasks.hs
- compiler/GHC/SysTools/Terminal.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Utils/Backpack.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Error.hs
- − compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/SourceError.hs
- compiler/GHC/Unit/Finder.hs
- compiler/GHC/Unit/Finder/Types.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Utils/Error.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/Language/Haskell/Syntax.hs
- compiler/Language/Haskell/Syntax/ImpExp.hs
- configure.ac
- distrib/configure.ac.in
- docs/users_guide/debugging.rst
- docs/users_guide/ghci.rst
- docs/users_guide/phases.rst
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Exception.hs
- ghc/Main.hs
- hadrian/README.md
- hadrian/bindist/config.mk.in
- hadrian/cfg/default.host.target.in
- + hadrian/cfg/system.config.host.in
- hadrian/cfg/system.config.in
- + hadrian/cfg/system.config.target.in
- + hadrian/ghci_
- hadrian/hadrian.cabal
- + hadrian/sensei
- hadrian/src/Base.hs
- + hadrian/src/BindistConfig.hs
- hadrian/src/Builder.hs
- hadrian/src/Context.hs
- hadrian/src/Expression.hs
- hadrian/src/Flavour.hs
- hadrian/src/Flavour/Type.hs
- hadrian/src/Hadrian/Builder.hs
- hadrian/src/Hadrian/Haskell/Hash.hs
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Main.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Oracles/Flavour.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Oracles/TestSettings.hs
- hadrian/src/Packages.hs
- hadrian/src/Rules.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/CabalReinstall.hs
- hadrian/src/Rules/Changelog.hs
- hadrian/src/Rules/Compile.hs
- hadrian/src/Rules/Documentation.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Gmp.hs
- hadrian/src/Rules/Library.hs
- hadrian/src/Rules/Program.hs
- hadrian/src/Rules/Register.hs
- hadrian/src/Rules/Rts.hs
- hadrian/src/Rules/Test.hs
- hadrian/src/Settings.hs
- hadrian/src/Settings/Builders/Cabal.hs
- hadrian/src/Settings/Builders/Common.hs
- hadrian/src/Settings/Builders/Configure.hs
- hadrian/src/Settings/Builders/DeriveConstants.hs
- hadrian/src/Settings/Builders/Ghc.hs
- hadrian/src/Settings/Builders/Hsc2Hs.hs
- hadrian/src/Settings/Builders/RunTest.hs
- hadrian/src/Settings/Builders/SplitSections.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Flavours/GhcInGhci.hs
- hadrian/src/Settings/Flavours/Performance.hs
- hadrian/src/Settings/Flavours/QuickCross.hs
- hadrian/src/Settings/Packages.hs
- hadrian/src/Settings/Program.hs
- hadrian/src/Settings/Warnings.hs
- libraries/base/tests/all.T
- m4/fp_find_nm.m4
- m4/prep_target_file.m4
- testsuite/ghc-config/ghc-config.hs
- testsuite/tests/annotations/should_fail/annfail03.stderr
- testsuite/tests/annotations/should_fail/annfail04.stderr
- testsuite/tests/annotations/should_fail/annfail06.stderr
- testsuite/tests/annotations/should_fail/annfail09.stderr
- testsuite/tests/ghc-api/exactprint/T22919.stderr
- testsuite/tests/ghc-api/exactprint/Test20239.stderr
- testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.stderr
- testsuite/tests/ghc-e/should_fail/all.T
- testsuite/tests/ghci/prog-mhu002/prog-mhu002c.stdout
- testsuite/tests/ghci/scripts/ghci024.stdout
- testsuite/tests/ghci/scripts/ghci024.stdout-mingw32
- testsuite/tests/haddock/haddock_testsuite/Makefile
- testsuite/tests/haddock/haddock_testsuite/all.T
- testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T24221.stderr
- testsuite/tests/javascript/closure/all.T
- testsuite/tests/module/mod185.stderr
- + testsuite/tests/package/ImportReexport.hs
- + testsuite/tests/package/ImportReexport.stderr
- testsuite/tests/package/all.T
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/DumpSemis.stderr
- testsuite/tests/parser/should_compile/KindSigs.stderr
- testsuite/tests/parser/should_compile/T14189.stderr
- testsuite/tests/parser/should_compile/T15323.stderr
- testsuite/tests/parser/should_compile/T20452.stderr
- testsuite/tests/parser/should_compile/T20718.stderr
- testsuite/tests/parser/should_compile/T20718b.stderr
- testsuite/tests/parser/should_compile/T20846.stderr
- testsuite/tests/parser/should_compile/T23315/T23315.stderr
- testsuite/tests/perf/compiler/all.T
- testsuite/tests/printer/AnnotationNoListTuplePuns.stdout
- testsuite/tests/printer/T18791.stderr
- testsuite/tests/printer/Test10309.hs
- testsuite/tests/printer/Test20297.stdout
- testsuite/tests/printer/Test24533.stdout
- + testsuite/tests/profiling/should_compile/T27386.hs
- testsuite/tests/profiling/should_compile/all.T
- testsuite/tests/quasiquotation/qq001/qq001.stderr
- testsuite/tests/quasiquotation/qq002/qq002.stderr
- testsuite/tests/quasiquotation/qq003/qq003.stderr
- testsuite/tests/quasiquotation/qq004/qq004.stderr
- testsuite/tests/quotes/LiftErrMsg.stderr
- testsuite/tests/quotes/LiftErrMsgDefer.stderr
- testsuite/tests/quotes/LiftErrMsgTyped.stderr
- testsuite/tests/quotes/T10384.stderr
- testsuite/tests/quotes/T5721.stderr
- testsuite/tests/quotes/TH_localname.stderr
- testsuite/tests/simplCore/should_compile/Makefile
- + testsuite/tests/simplCore/should_compile/T27296.hs
- + testsuite/tests/simplCore/should_compile/T27296.stdout
- + testsuite/tests/simplCore/should_compile/T27296b.hs
- + testsuite/tests/simplCore/should_compile/T27296b.stdout
- testsuite/tests/simplCore/should_compile/all.T
- testsuite/tests/splice-imports/SI03.stderr
- testsuite/tests/splice-imports/SI05.stderr
- testsuite/tests/splice-imports/SI08.stderr
- testsuite/tests/splice-imports/SI08_oneshot.stderr
- testsuite/tests/splice-imports/SI16.stderr
- testsuite/tests/splice-imports/SI18.stderr
- testsuite/tests/splice-imports/SI20.stderr
- testsuite/tests/splice-imports/SI25.stderr
- testsuite/tests/splice-imports/SI28.stderr
- testsuite/tests/splice-imports/SI29.stderr
- testsuite/tests/splice-imports/SI31.stderr
- testsuite/tests/splice-imports/SI36.stderr
- testsuite/tests/splice-imports/T26088.stderr
- testsuite/tests/splice-imports/T26090.stderr
- + testsuite/tests/splice-imports/T26616.hs
- + testsuite/tests/splice-imports/T26616.stderr
- testsuite/tests/splice-imports/all.T
- testsuite/tests/th/T16976z.stderr
- testsuite/tests/th/T17820a.stderr
- testsuite/tests/th/T17820b.stderr
- testsuite/tests/th/T17820c.stderr
- testsuite/tests/th/T17820d.stderr
- testsuite/tests/th/T17820e.stderr
- testsuite/tests/th/T21547.stderr
- testsuite/tests/th/T23829_hasty.stderr
- testsuite/tests/th/T23829_hasty_b.stderr
- testsuite/tests/th/T23829_tardy.ghc.stderr
- testsuite/tests/th/T26098_local.stderr
- testsuite/tests/th/T26098_quote.stderr
- testsuite/tests/th/T26098_splice.stderr
- testsuite/tests/th/T26099.stderr
- testsuite/tests/th/T26568.stderr
- testsuite/tests/th/T5795.stderr
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Main.hs
- utils/check-exact/Preprocess.hs
- utils/check-exact/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/haddock/haddock-test/src/Test/Haddock/Config.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0484b827f0eb91b11930533351a40b…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0484b827f0eb91b11930533351a40b…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Add explicit setBit/clearBit/complementBit for instance Bits Integer (#21176)
by Marge Bot (@marge-bot) 25 Jun '26
by Marge Bot (@marge-bot) 25 Jun '26
25 Jun '26
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
2152e57f by Simon Jakobi at 2026-06-24T23:10:31-04:00
Add explicit setBit/clearBit/complementBit for instance Bits Integer (#21176)
The default setBit, clearBit, and complementBit methods allocate
intermediate Integers per call. Define them explicitly via the new
integerSetBit[#], integerClearBit[#] and integerComplementBit[#], built
on the BigNat# primitives, which avoid those allocations. Allocation is not
eliminated entirely -- the negative (IN) cases would need in-place mutation,
which is left as future work.
The default methods constant-folded on literal arguments via the
integerOr/integerAnd/integerXor rules, which fold literal Integers of any
size. The explicit functions have no such rule, so they (their Word-argument
wrappers, and the Bits Integer methods) are marked INLINE to expose the
underlying primops to the simplifier; see Note [INLINE for constant folding
of bit operations]. This restores folding only on the small-int (IS) path --
large literal Integers (IP/IN) are no longer constant-folded, a minor
regression for that case. T8832 covers the IS-path folding.
The new golden-output test T21176 checks all three operations against the
default implementations across the sign/size boundaries, recording each
result plus its integerCheck validity. The base and ghc-bignum interface-
stability export goldens gain the new functions.
The main changelog entry lives in changelog.d under a new ghc-internal
section (renamed from ghc-prim).
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/423
Co-Authored-By: Claude Opus 4.7 <noreply(a)anthropic.com>
- - - - -
a79cf59c by Marc Scholten at 2026-06-24T23:10:44-04:00
haddock: use Text in documentation pipeline
This patch moves Haddock's documentation pipeline from String to Text
where the data is already textual. It avoids repeated conversions while
keeping the existing decoding behavior for invalid UTF-8 docstring
chunks.
The main changes are:
* Render and carry docstrings as Text in Haddock-facing paths.
* Use the Binary Text instance from GHC.Utils.Binary for Haddock
interface files, and bump the Haddock binary interface version.
* Add a FastString HTML instance so XHTML rendering avoids
intermediate String allocation.
* Keep HsDocStringChunk decoding lenient, matching the previous
unpackHDSC behavior on invalid UTF-8 input.
* Update the xhtml submodule to 3000.4.1.0, which contains the
apostrophe escaping fix used by the Haddock test output.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot(a)users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply(a)anthropic.com>
Assisted-by: Codex <codex(a)openai.com>
- - - - -
b50d15f3 by mangoiv at 2026-06-24T23:10:46-04:00
compiler: rename ZonkAny to UnusedType and add pretty printing logic
ZonkAny is a hard to understand name for users who do not know how the
compiler works internally. Additionally, it is confusing that ZonkAny,
while being a concrete type *represents* a meta variable, espeically in
the compiler output.
This patch changes the name of ZonkAny to UnusedType which is closer to
its intended semantics and adds special pretty printing logic to display
this type in the same fashion the compiler displays meta variables in
other places, whenever they leak from the implementation to the user.
It also exports the type from ghc-internal:GHC.Internal.Types in order
to expose documentation.
Fixes #27390
Co-Authored-By: Sam Derbyshire <sam.derbyshire(a)gmail.com>
- - - - -
71 changed files:
- + changelog.d/T21176
- changelog.d/config
- + changelog.d/unused-type
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Hs/DocString.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- libraries/base/changelog.md
- libraries/base/src/GHC/Base.hs
- libraries/base/src/GHC/Exts.hs
- libraries/ghc-bignum/changelog.md
- libraries/ghc-experimental/src/GHC/PrimOps.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/Integer.hs
- libraries/ghc-internal/src/GHC/Internal/Bits.hs
- libraries/ghc-internal/src/GHC/Internal/Types.hs
- libraries/xhtml
- testsuite/tests/interface-stability/ghc-bignum-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- + testsuite/tests/numeric/should_run/T21176.hs
- + testsuite/tests/numeric/should_run/T21176.stdout
- + testsuite/tests/numeric/should_run/T21176.stdout-ws-32
- testsuite/tests/numeric/should_run/all.T
- testsuite/tests/perf/compiler/T11068.stdout
- testsuite/tests/pmcheck/should_compile/T12957.stderr
- testsuite/tests/profiling/should_run/staticcallstack002.stdout
- testsuite/tests/simplCore/should_compile/Makefile
- testsuite/tests/simplCore/should_compile/T13156.stdout
- testsuite/tests/simplCore/should_compile/T26615.stderr
- testsuite/tests/simplCore/should_compile/T8832.hs
- testsuite/tests/simplCore/should_compile/T8832.stdout
- testsuite/tests/typecheck/should_fail/T13292.stderr
- + testsuite/tests/typecheck/should_fail/T27390-explicit-kinds.stderr
- + testsuite/tests/typecheck/should_fail/T27390.hs
- + testsuite/tests/typecheck/should_fail/T27390.stderr
- + testsuite/tests/typecheck/should_fail/T27390a.hs
- testsuite/tests/typecheck/should_fail/all.T
- utils/haddock/haddock-api/src/Haddock.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
- utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Meta.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Names.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Doc.hs
- utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
- utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Json.hs
- utils/haddock/haddock-api/src/Haddock/Interface/LexParseRn.hs
- utils/haddock/haddock-api/src/Haddock/Interface/ParseModuleHeader.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs
- utils/haddock/haddock-api/src/Haddock/Options.hs
- utils/haddock/haddock-api/src/Haddock/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/haddock/haddock-api/src/Haddock/Utils/Json.hs
- utils/haddock/haddock-api/src/Haddock/Utils/Json/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Utils/Json/Types.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Doc.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Markup.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Util.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Types.hs
- utils/haddock/haddock-library/test/Documentation/Haddock/ParserSpec.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc1e735decc9469da65213b7a88965…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc1e735decc9469da65213b7a88965…
You're receiving this email because of your account on gitlab.haskell.org.
1
0