diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2021-11-05 00:47:32 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-12 21:22:03 -0500 |
commit | dfc4093ccb7c4b7402830ab7c715b55d90980af1 (patch) | |
tree | 7cd92eafd556c01b35d4298597f364dfbabbe25b /compiler/GHC/Tc/Errors | |
parent | ca90ffa321a31842a32be1b5b6e26743cd677ec5 (diff) | |
download | haskell-dfc4093ccb7c4b7402830ab7c715b55d90980af1.tar.gz |
Implement -Wforall-identifier (#20609)
In accordance with GHC Proposal #281 "Visible forall in types of terms":
For three releases before this change takes place, include a new
warning -Wforall-identifier in -Wdefault. This warning will be triggered
at definition sites (but not use sites) of forall as an identifier.
Updates the haddock submodule.
Diffstat (limited to 'compiler/GHC/Tc/Errors')
-rw-r--r-- | compiler/GHC/Tc/Errors/Ppr.hs | 9 | ||||
-rw-r--r-- | compiler/GHC/Tc/Errors/Types.hs | 11 |
2 files changed, 20 insertions, 0 deletions
diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs index e282d8fe8d..b5a0dbb284 100644 --- a/compiler/GHC/Tc/Errors/Ppr.hs +++ b/compiler/GHC/Tc/Errors/Ppr.hs @@ -517,6 +517,11 @@ instance Diagnostic TcRnMessage where = text " when Safe Haskell is enabled." | otherwise = dot + TcRnForallIdentifier rdr_name + -> mkSimpleDecorated $ + fsep [ text "The use of" <+> quotes (ppr rdr_name) + <+> text "as an identifier", + text "will become an error in a future GHC release." ] diagnosticReason = \case TcRnUnknownMessage m @@ -733,6 +738,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnSpecialClassInst {} -> ErrorWithoutFlag + TcRnForallIdentifier {} + -> WarningWithFlag Opt_WarnForallIdentifier diagnosticHints = \case TcRnUnknownMessage m @@ -943,6 +950,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnSpecialClassInst {} -> noHints + TcRnForallIdentifier {} + -> [SuggestRenameForall] deriveInstanceErrReasonHints :: Class -> UsingGeneralizedNewtypeDeriving diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs index 10cc3524df..98e2479e52 100644 --- a/compiler/GHC/Tc/Errors/Types.hs +++ b/compiler/GHC/Tc/Errors/Types.hs @@ -1412,6 +1412,17 @@ data TcRnMessage where -} TcRnArrowProcGADTPattern :: TcRnMessage + {- TcRnForallIdentifier is a warning (controlled with -Wforall-identifier) that occurs + when a definition uses 'forall' as an identifier. + + Example: + forall x = () + g forall = () + + Test cases: T20609 T20609a T20609b T20609c T20609d + -} + TcRnForallIdentifier :: RdrName -> TcRnMessage + -- | Which parts of a record field are affected by a particular error or warning. data RecordFieldPart = RecordFieldConstructor !Name |