diff options
author | Alfredo Di Napoli <alfredo@well-typed.com> | 2021-07-06 09:56:45 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-09 08:46:44 -0400 |
commit | 558724237b978ab2293a62ee48fe2b2f603a6791 (patch) | |
tree | 4d8c615cf09af0de214f26ffed88f55593c98ed6 | |
parent | 573012c7be49e24ec09a88e078fd22f62f9a4b1d (diff) | |
download | haskell-558724237b978ab2293a62ee48fe2b2f603a6791.tar.gz |
Add the TcRnDuplicateWarningDecls to TcRnMessage
-rw-r--r-- | compiler/GHC/Rename/Module.hs | 9 | ||||
-rw-r--r-- | compiler/GHC/Tc/Errors/Ppr.hs | 8 | ||||
-rw-r--r-- | compiler/GHC/Tc/Errors/Types.hs | 11 |
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 |