[Git][ghc/ghc][wip/marge_bot_batch_merge_job] Add structured error messages for GHC.IfaceToCore
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Mon May 8 23:11:12 UTC 2023
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
24effc02 by Torsten Schmits at 2023-05-08T19:11:07-04:00
Add structured error messages for GHC.IfaceToCore
Tracking ticket: #20114
MR: !10390
This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.
- - - - -
4 changed files:
- compiler/GHC/Iface/Errors/Ppr.hs
- compiler/GHC/Iface/Errors/Types.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Types/Error/Codes.hs
Changes:
=====================================
compiler/GHC/Iface/Errors/Ppr.hs
=====================================
@@ -65,6 +65,8 @@ interfaceErrorHints = \ case
missingInterfaceErrorHints err
Can'tFindNameInInterface {} ->
noHints
+ CircularImport {} ->
+ noHints
missingInterfaceErrorHints :: MissingInterfaceError -> [GhcHint]
missingInterfaceErrorHints = \case
@@ -86,6 +88,8 @@ interfaceErrorReason (Can'tFindInterface err _)
= missingInterfaceErrorReason err
interfaceErrorReason (Can'tFindNameInInterface {})
= ErrorWithoutFlag
+interfaceErrorReason (CircularImport {})
+ = ErrorWithoutFlag
missingInterfaceErrorReason :: MissingInterfaceError -> DiagnosticReason
missingInterfaceErrorReason = \ case
@@ -287,6 +291,9 @@ interfaceErrorDiagnostic opts = \ case
LookingForSig sig ->
hang (text "Could not find interface file for signature" <+> quotes (ppr sig) <> colon)
2 (missingInterfaceErrorDiagnostic opts err)
+ CircularImport mod ->
+ text "Circular imports: module" <+> quotes (ppr mod)
+ <+> text "depends on itself"
readInterfaceErrorDiagnostic :: ReadInterfaceError -> SDoc
readInterfaceErrorDiagnostic = \ case
=====================================
compiler/GHC/Iface/Errors/Types.hs
=====================================
@@ -45,6 +45,7 @@ data IfaceMessage
| Can'tFindNameInInterface
Name
[TyThing] -- possibly relevant TyThings
+ | CircularImport !Module
deriving Generic
data MissingInterfaceError
=====================================
compiler/GHC/IfaceToCore.hs
=====================================
@@ -605,7 +605,7 @@ tcHiBootIface hsc_src mod
(LookingForHiBoot mod)
in failWithTc (TcRnInterfaceError diag)
-- The hi-boot file has mysteriously disappeared.
- NotBoot -> failWithTc (mkTcRnUnknownMessage $ mkPlainError noHints moduleLoop)
+ NotBoot -> failWithTc (TcRnInterfaceError (CircularImport mod))
-- Someone below us imported us!
-- This is a loop with no hi-boot in the way
}}}}
@@ -613,11 +613,6 @@ tcHiBootIface hsc_src mod
need = text "Need the hi-boot interface for" <+> ppr mod
<+> text "to compare against the Real Thing"
- moduleLoop = text "Circular imports: module" <+> quotes (ppr mod)
- <+> text "depends on itself"
-
-
-
mkSelfBootInfo :: ModIface -> ModDetails -> TcRn SelfBootInfo
mkSelfBootInfo iface mds
= do -- NB: This is computed DIRECTLY from the ModIface rather
=====================================
compiler/GHC/Types/Error/Codes.hs
=====================================
@@ -719,6 +719,7 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "NoUnitIdMatching" = 51294
GhcDiagnosticCode "NotAModule" = 35235
GhcDiagnosticCode "Can'tFindNameInInterface" = 83249
+ GhcDiagnosticCode "CircularImport" = 75429
GhcDiagnosticCode "HiModuleNameMismatchWarn" = 53693
GhcDiagnosticCode "ExceptionOccurred" = 47808
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/24effc0241d63dffc8f0add3c2092a860187c231
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/24effc0241d63dffc8f0add3c2092a860187c231
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230508/89b2a9db/attachment-0001.html>
More information about the ghc-commits
mailing list