[Git][ghc/ghc][master] Add structured error messages for GHC.IfaceToCore
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue May 9 01:42:08 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-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/78c8dc509eacef5a5f09601b6bd004e13ae3a4c3
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78c8dc509eacef5a5f09601b6bd004e13ae3a4c3
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/89989b18/attachment-0001.html>
More information about the ghc-commits
mailing list