summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-02-14 15:34:56 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-04 23:14:01 -0500
commitdb898c8a33813f4bdfbd38fe7595fbdd819c172a (patch)
treebd6a3a1c90a0af3d6cee1b80c44b5c367692ca74 /compiler
parentf943edb0c40d20e1330450c3e148b8d0c877eded (diff)
downloadhaskell-db898c8a33813f4bdfbd38fe7595fbdd819c172a.tar.gz
Add a Template Haskell warning flag -Wimplicit-lift
Part of #17804.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Driver/Flags.hs1
-rw-r--r--compiler/GHC/Driver/Session.hs3
-rw-r--r--compiler/GHC/Rename/Splice.hs6
-rw-r--r--compiler/GHC/Tc/Gen/Head.hs6
4 files changed, 15 insertions, 1 deletions
diff --git a/compiler/GHC/Driver/Flags.hs b/compiler/GHC/Driver/Flags.hs
index f15d0d4ba1..3a31e55ff1 100644
--- a/compiler/GHC/Driver/Flags.hs
+++ b/compiler/GHC/Driver/Flags.hs
@@ -510,6 +510,7 @@ data WarningFlag =
| Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2
| Opt_WarnOperatorWhitespace -- Since 9.2
| Opt_WarnAmbiguousFields -- Since 9.2
+ | Opt_WarnImplicitLift -- Since 9.2
deriving (Eq, Show, Enum)
-- | Used when outputting warnings: if a reason is given, it is
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 8237525fb7..e0ef09eba8 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -3167,7 +3167,8 @@ wWarningFlagsDeps = [
flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports,
flagSpec "invalid-haddock" Opt_WarnInvalidHaddock,
flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict,
- flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace
+ flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace,
+ flagSpec "implicit-lift" Opt_WarnImplicitLift
]
-- | These @-\<blah\>@ flags can all be reversed with @-no-\<blah\>@
diff --git a/compiler/GHC/Rename/Splice.hs b/compiler/GHC/Rename/Splice.hs
index 885fdf17fd..605da448ce 100644
--- a/compiler/GHC/Rename/Splice.hs
+++ b/compiler/GHC/Rename/Splice.hs
@@ -909,6 +909,12 @@ check_cross_stage_lifting top_lvl name ps_var
; let lift_expr = nlHsApp (nlHsVar liftName) (nlHsVar name)
pend_splice = PendingRnSplice UntypedExpSplice name lift_expr
+ -- Warning for implicit lift (#17804)
+ ; whenWOptM Opt_WarnImplicitLift $
+ addWarnTc (Reason Opt_WarnImplicitLift)
+ (text "The variable" <+> quotes (ppr name) <+>
+ text "is implicitly lifted in the TH quotation")
+
-- Update the pending splices
; ps <- readMutVar ps_var
; writeMutVar ps_var (pend_splice : ps) }
diff --git a/compiler/GHC/Tc/Gen/Head.hs b/compiler/GHC/Tc/Gen/Head.hs
index 5b57f397ce..4214b4cf92 100644
--- a/compiler/GHC/Tc/Gen/Head.hs
+++ b/compiler/GHC/Tc/Gen/Head.hs
@@ -1113,6 +1113,12 @@ checkCrossStageLifting top_lvl id (Brack _ (TcPending ps_var lie_var q))
GHC.Builtin.Names.TH.liftName
[getRuntimeRep id_ty, id_ty]
+ -- Warning for implicit lift (#17804)
+ ; whenWOptM Opt_WarnImplicitLift $
+ addWarnTc (Reason Opt_WarnImplicitLift)
+ (text "The variable" <+> quotes (ppr id) <+>
+ text "is implicitly lifted in the TH quotation")
+
-- Update the pending splices
; ps <- readMutVar ps_var
; let pending_splice = PendingTcSplice id_name