diff options
author | Alfredo Di Napoli <alfredo@well-typed.com> | 2021-07-06 15:12:28 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-09 08:46:44 -0400 |
commit | 8d28b481098742f4fded2ae465a3f49516e2a95c (patch) | |
tree | 39b70b2b8b3299fa30ae3b9990734e7bccec0fbf | |
parent | 6b4f3a99f1e04943ca5a43490284c5774a346bbb (diff) | |
download | haskell-8d28b481098742f4fded2ae465a3f49516e2a95c.tar.gz |
Add TcRnCharLiteralOutOfRange to TcRnMessage
-rw-r--r-- | compiler/GHC/Rename/Pat.hs | 7 | ||||
-rw-r--r-- | compiler/GHC/Tc/Errors/Ppr.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Tc/Errors/Types.hs | 11 |
3 files changed, 18 insertions, 6 deletions
diff --git a/compiler/GHC/Rename/Pat.hs b/compiler/GHC/Rename/Pat.hs index 91da0f4454..4dda6ee44b 100644 --- a/compiler/GHC/Rename/Pat.hs +++ b/compiler/GHC/Rename/Pat.hs @@ -954,7 +954,7 @@ are made available. -} rnLit :: HsLit p -> RnM () -rnLit (HsChar _ c) = checkErr (inCharRange c) (bogusCharError c) +rnLit (HsChar _ c) = checkErr (inCharRange c) (TcRnCharLiteralOutOfRange c) rnLit _ = return () -- | Turn a Fractional-looking literal which happens to be an integer into an @@ -1021,8 +1021,3 @@ patSigErr :: Outputable a => a -> SDoc patSigErr ty = (text "Illegal signature in pattern:" <+> ppr ty) $$ nest 4 (text "Use ScopedTypeVariables to permit it") - -bogusCharError :: Char -> TcRnMessage -bogusCharError c - = TcRnUnknownMessage $ mkPlainError noHints $ - text "character literal out of range: '\\" <> char c <> char '\'' diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs index c8ed6a04eb..0d842c0e2d 100644 --- a/compiler/GHC/Tc/Errors/Ppr.hs +++ b/compiler/GHC/Tc/Errors/Ppr.hs @@ -86,6 +86,8 @@ instance Diagnostic TcRnMessage where text "in record", pprRecordFieldPart fld_part] TcRnIllegalViewPattern pat -> mkSimpleDecorated $ vcat [text "Illegal view pattern: " <+> ppr pat] + TcRnCharLiteralOutOfRange c + -> mkSimpleDecorated $ text "character literal out of range: '\\" <> char c <> char '\'' diagnosticReason = \case TcRnUnknownMessage m @@ -127,6 +129,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnIllegalViewPattern{} -> ErrorWithoutFlag + TcRnCharLiteralOutOfRange{} + -> ErrorWithoutFlag diagnosticHints = \case TcRnUnknownMessage m @@ -168,6 +172,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnIllegalViewPattern{} -> [SuggestExtension LangExt.ViewPatterns] + TcRnCharLiteralOutOfRange{} + -> noHints messageWithInfoDiagnosticMessage :: UnitState -> ErrInfo diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs index 3fd9698b10..0af49bc19a 100644 --- a/compiler/GHC/Tc/Errors/Types.hs +++ b/compiler/GHC/Tc/Errors/Types.hs @@ -10,6 +10,8 @@ module GHC.Tc.Errors.Types ( , RecordFieldPart(..) ) where +import GHC.Prelude + import GHC.Hs import GHC.Tc.Types.Constraint import GHC.Types.Error @@ -292,6 +294,15 @@ data TcRnMessage where -} TcRnIllegalViewPattern :: !(Pat GhcPs) -> TcRnMessage + {-| TcRnCharLiteralOutOfRange is an error that occurs whenever + a character is out of range. + + Examples(s): None + + Test cases: None + -} + TcRnCharLiteralOutOfRange :: !Char -> TcRnMessage + -- | Which parts of a record field are affected by a particular error or warning. data RecordFieldPart = RecordFieldConstructor !Name |