Skip to content
Snippets Groups Projects
Commit 822ef66b authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

Fix pretty printing of WARNING pragmas

There is still something quite unsavoury going on with WARNING pragma
printing because the printing relies on the fact that for decl
deprecations the SourceText of WarningTxt is empty. However, I let that
lion sleep and just fixed things directly.

Fixes #23465
parent 02e6a6ce
Branches master
No related tags found
No related merge requests found
......@@ -1234,7 +1234,7 @@ instance OutputableBndrId p
<+> ppr txt
where
ppr_category = case txt of
WarningTxt (Just cat) _ _ -> text "[" <> ppr (unLoc cat) <> text "]"
WarningTxt (Just cat) _ _ -> text "in" <+> doubleQuotes (ppr cat)
_ -> empty
{-
......
......@@ -222,10 +222,13 @@ deriving instance Eq (IdP pass) => Eq (WarningTxt pass)
deriving instance (Data pass, Data (IdP pass)) => Data (WarningTxt pass)
instance Outputable (WarningTxt pass) where
ppr (WarningTxt _ lsrc ws)
ppr (WarningTxt mcat lsrc ws)
= case unLoc lsrc of
NoSourceText -> pp_ws ws
SourceText src -> ftext src <+> pp_ws ws <+> text "#-}"
NoSourceText -> pp_ws ws
SourceText src -> ftext src <+> ctg_doc <+> pp_ws ws <+> text "#-}"
where
ctg_doc = maybe empty (\ctg -> text "in" <+> doubleQuotes (ppr ctg)) mcat
ppr (DeprecatedTxt lsrc ds)
= case unLoc lsrc of
......
......@@ -790,3 +790,8 @@ Test22765:
Test22771:
$(CHECK_PPR) $(LIBDIR) Test22771.hs
$(CHECK_EXACT) $(LIBDIR) Test22771.hs
.PHONY: Test23464
Test23465:
$(CHECK_PPR) $(LIBDIR) Test23464.hs
$(CHECK_EXACT) $(LIBDIR) Test23464.hs
module T23465 {-# WaRNING in "x-a" "b" #-} where
{-# WARNInG in "x-c" e "d" #-}
e = e
......@@ -190,3 +190,4 @@ test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_
test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy'])
test('Test22765', [ignore_stderr, req_ppr_deps], makefile_test, ['Test22765'])
test('Test22771', [ignore_stderr, req_ppr_deps], makefile_test, ['Test22771'])
test('Test23464', [ignore_stderr, req_ppr_deps], makefile_test, ['Test23464'])
module T23465 {-# WaRNING in "x-a" "b" #-} where
{-# WARNInG in "x-c" e "d" #-}
e = e
==================== Parser ====================
module T23465
{-# WaRNING in "x-a" "b" #-}
where
{-# WARNInG in "x-c" e "d" #-}
e = e
......@@ -66,3 +66,4 @@ test('T22702a', normal, compile, [''])
test('T22702b', normal, compile, [''])
test('T22826', normal, compile, [''])
test('T23573', [extra_files(["T23573.hs", "T23573A.hs", "T23573B.hs"])], multimod_compile, ['T23573', '-v0'])
test('T23465', normal, compile, ['-ddump-parsed'])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment