diff options
-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 |