summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser/Errors/Ppr.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Parser/Errors/Ppr.hs')
-rw-r--r--compiler/GHC/Parser/Errors/Ppr.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/GHC/Parser/Errors/Ppr.hs b/compiler/GHC/Parser/Errors/Ppr.hs
index 9396961cab..138a24ccd5 100644
--- a/compiler/GHC/Parser/Errors/Ppr.hs
+++ b/compiler/GHC/Parser/Errors/Ppr.hs
@@ -28,6 +28,7 @@ import GHC.Hs.Type (pprLHsContext)
import GHC.Builtin.Names (allNameStrings)
import GHC.Builtin.Types (filterCTuple)
import qualified GHC.LanguageExtensions as LangExt
+import Data.List.NonEmpty (NonEmpty((:|)))
instance Diagnostic PsMessage where
@@ -44,6 +45,20 @@ instance Diagnostic PsMessage where
-> mkSimpleDecorated $
text "Multiple Haddock comments for a single entity are not allowed." $$
text "The extraneous comment will be ignored."
+ PsWarnBidirectionalFormatChars ((loc,_,desc) :| xs)
+ -> mkSimpleDecorated $
+ text "A unicode bidirectional formatting character" <+> parens (text desc)
+ $$ text "was found at offset" <+> ppr (bufPos (psBufPos loc)) <+> text "in the file"
+ $$ (case xs of
+ [] -> empty
+ xs -> text "along with further bidirectional formatting characters at" <+> pprChars xs
+ where
+ pprChars [] = empty
+ pprChars ((loc,_,desc):xs) = text "offset" <+> ppr (bufPos (psBufPos loc)) <> text ":" <+> text desc
+ $$ pprChars xs
+ )
+ $$ text "Bidirectional formatting characters may be rendered misleadingly in certain editors"
+
PsWarnTab tc
-> mkSimpleDecorated $
text "Tab character found here"
@@ -474,6 +489,7 @@ instance Diagnostic PsMessage where
diagnosticReason = \case
PsUnknownMessage m -> diagnosticReason m
PsHeaderMessage m -> psHeaderMessageReason m
+ PsWarnBidirectionalFormatChars{} -> WarningWithFlag Opt_WarnUnicodeBidirectionalFormatCharacters
PsWarnTab{} -> WarningWithFlag Opt_WarnTabs
PsWarnTransitionalLayout{} -> WarningWithFlag Opt_WarnAlternativeLayoutRuleTransitional
PsWarnOperatorWhitespaceExtConflict{} -> WarningWithFlag Opt_WarnOperatorWhitespaceExtConflict
@@ -586,6 +602,7 @@ instance Diagnostic PsMessage where
diagnosticHints = \case
PsUnknownMessage m -> diagnosticHints m
PsHeaderMessage m -> psHeaderMessageHints m
+ PsWarnBidirectionalFormatChars{} -> noHints
PsWarnTab{} -> [SuggestUseSpaces]
PsWarnTransitionalLayout{} -> noHints
PsWarnOperatorWhitespaceExtConflict sym -> [SuggestUseWhitespaceAfter sym]