summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-04-01 12:02:46 +0200
committerMatthew Pickering <matthewtpickering@gmail.com>2022-04-01 11:17:56 +0100
commitd85c7dcb7c457efc23b20ac8f4e4ae88bae5b050 (patch)
tree6a052785be9dd3b67e42637102de21f0630f6ddf /compiler/GHC/Core
parent950f58e7bf584ec6970327ac7c7ae3f3fdbc9882 (diff)
downloadhaskell-wip/no-c-stubs.tar.gz
Keep track of promotion ticks in HsOpTywip/no-c-stubswip/matt-merge-batch
This patch adds a PromotionFlag field to HsOpTy, which is used in pretty-printing and when determining whether to emit warnings with -fwarn-unticked-promoted-constructors. This allows us to correctly report tick-related warnings for things like: type A = Int : '[] type B = [Int, Bool] Updates haddock submodule Fixes #19984
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r--compiler/GHC/Core/Ppr.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Ppr.hs b/compiler/GHC/Core/Ppr.hs
index 43579082a9..b319abec08 100644
--- a/compiler/GHC/Core/Ppr.hs
+++ b/compiler/GHC/Core/Ppr.hs
@@ -23,13 +23,15 @@ module GHC.Core.Ppr (
pprCoreBinding, pprCoreBindings, pprCoreAlt,
pprCoreBindingWithSize, pprCoreBindingsWithSize,
pprCoreBinder, pprCoreBinders,
- pprRule, pprRules, pprOptCo
+ pprRule, pprRules, pprOptCo,
+ pprOcc, pprOccWithTick
) where
import GHC.Prelude
import GHC.Core
import GHC.Core.Stats (exprStats)
+import GHC.Types.Fixity (LexicalFixity(..))
import GHC.Types.Literal( pprLiteral )
import GHC.Types.Name( pprInfixName, pprPrefixName )
import GHC.Types.Var
@@ -382,6 +384,17 @@ instance Outputable b => OutputableBndr (TaggedBndr b) where
pprPrefixOcc b = ppr b
bndrIsJoin_maybe (TB b _) = isJoinId_maybe b
+pprOcc :: OutputableBndr a => LexicalFixity -> a -> SDoc
+pprOcc Infix = pprInfixOcc
+pprOcc Prefix = pprPrefixOcc
+
+pprOccWithTick :: OutputableBndr a => LexicalFixity -> PromotionFlag -> a -> SDoc
+pprOccWithTick fixity prom op
+ | isPromoted prom
+ = quote (pprOcc fixity op)
+ | otherwise
+ = pprOcc fixity op
+
pprCoreBinder :: BindingSite -> Var -> SDoc
pprCoreBinder LetBind binder
| isTyVar binder = pprKindedTyVarBndr binder