summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/Rename/Module.hs9
-rw-r--r--compiler/GHC/Tc/Errors/Ppr.hs8
-rw-r--r--compiler/GHC/Tc/Errors/Types.hs11
3 files changed, 20 insertions, 8 deletions
diff --git a/compiler/GHC/Rename/Module.hs b/compiler/GHC/Rename/Module.hs
index ef9769c5a7..c99098963b 100644
--- a/compiler/GHC/Rename/Module.hs
+++ b/compiler/GHC/Rename/Module.hs
@@ -270,7 +270,7 @@ rnSrcWarnDecls _ []
rnSrcWarnDecls bndr_set decls'
= do { -- check for duplicates
; mapM_ (\ dups -> let ((L loc rdr) :| (lrdr':_)) = dups
- in addErrAt (locA loc) (dupWarnDecl lrdr' rdr))
+ in addErrAt (locA loc) (TcRnDuplicateWarningDecls lrdr' rdr))
warn_rdr_dups
; pairs_s <- mapM (addLocMA rn_deprec) decls
; return (WarnSome ((concat pairs_s))) }
@@ -297,13 +297,6 @@ findDupRdrNames = findDupsEq (\ x -> \ y -> rdrNameOcc (unLoc x) == rdrNameOcc (
-- we check that the names are defined above
-- invt: the lists returned by findDupsEq always have at least two elements
-dupWarnDecl :: LocatedN RdrName -> RdrName -> TcRnMessage
--- Located RdrName -> DeprecDecl RdrName -> SDoc
-dupWarnDecl d rdr_name
- = TcRnUnknownMessage $ mkPlainError noHints $
- vcat [text "Multiple warning declarations for" <+> quotes (ppr rdr_name),
- text "also at " <+> ppr (getLocA d)]
-
{-
*********************************************************
* *
diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs
index 727edc78cd..9953971c24 100644
--- a/compiler/GHC/Tc/Errors/Ppr.hs
+++ b/compiler/GHC/Tc/Errors/Ppr.hs
@@ -58,6 +58,10 @@ instance Diagnostic TcRnMessage where
sep [text "This binding for" <+> quotes (ppr occ)
<+> text "shadows the existing binding" <> plural shadowed_locs,
nest 2 (vcat shadowed_locs)]
+ TcRnDuplicateWarningDecls d rdr_name
+ -> mkSimpleDecorated $
+ vcat [text "Multiple warning declarations for" <+> quotes (ppr rdr_name),
+ text "also at " <+> ppr (getLocA d)]
diagnosticReason = \case
TcRnUnknownMessage m
@@ -83,6 +87,8 @@ instance Diagnostic TcRnMessage where
-> ErrorWithoutFlag
TcRnShadowedName{}
-> WarningWithFlag Opt_WarnNameShadowing
+ TcRnDuplicateWarningDecls{}
+ -> ErrorWithoutFlag
diagnosticHints = \case
TcRnUnknownMessage m
@@ -108,6 +114,8 @@ instance Diagnostic TcRnMessage where
-> noHints
TcRnShadowedName{}
-> noHints
+ TcRnDuplicateWarningDecls{}
+ -> noHints
messageWithInfoDiagnosticMessage :: UnitState
-> ErrInfo
diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs
index 26e4308768..f76ac52727 100644
--- a/compiler/GHC/Tc/Errors/Types.hs
+++ b/compiler/GHC/Tc/Errors/Types.hs
@@ -185,6 +185,17 @@ data TcRnMessage where
-}
TcRnShadowedName :: OccName -> ShadowedNameProvenance -> TcRnMessage
+ {-| TcRnDuplicateWarningDecls is an error that occurs whenever
+ a warning is declared twice.
+
+ Examples(s):
+ None.
+
+ Test cases:
+ None.
+ -}
+ TcRnDuplicateWarningDecls :: !(LocatedN RdrName) -> !RdrName -> TcRnMessage
+
-- | Where a shadowed name comes from
data ShadowedNameProvenance