summaryrefslogtreecommitdiff
path: root/testsuite
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 /testsuite
parentf943edb0c40d20e1330450c3e148b8d0c877eded (diff)
downloadhaskell-db898c8a33813f4bdfbd38fe7595fbdd819c172a.tar.gz
Add a Template Haskell warning flag -Wimplicit-lift
Part of #17804.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/th/T17804.hs26
-rw-r--r--testsuite/tests/th/T17804.stderr10
-rw-r--r--testsuite/tests/th/all.T1
3 files changed, 37 insertions, 0 deletions
diff --git a/testsuite/tests/th/T17804.hs b/testsuite/tests/th/T17804.hs
new file mode 100644
index 0000000000..152812a728
--- /dev/null
+++ b/testsuite/tests/th/T17804.hs
@@ -0,0 +1,26 @@
+{-# OPTIONS_GHC -Wimplicit-lift #-}
+{-# LANGUAGE TemplateHaskell #-}
+module T17804 where
+
+import Language.Haskell.TH.Syntax
+
+warning1 :: Lift t => t -> Q Exp
+warning1 x = [| x |]
+
+warning2 :: Lift t => t -> Code Q t
+warning2 x = [|| x ||]
+
+noWarning1 :: Q Exp
+noWarning1 = [| \x -> x |]
+
+noWarning2 :: Code Q (a -> a)
+noWarning2 = [|| \x -> x ||]
+
+i :: Int
+i = 0
+
+noWarning3 :: Q Exp
+noWarning3 = [| i |]
+
+noWarning4 :: Code Q Int
+noWarning4 = [|| i ||]
diff --git a/testsuite/tests/th/T17804.stderr b/testsuite/tests/th/T17804.stderr
new file mode 100644
index 0000000000..6a18945635
--- /dev/null
+++ b/testsuite/tests/th/T17804.stderr
@@ -0,0 +1,10 @@
+
+T17804.hs:8:17: warning: [-Wimplicit-lift]
+ • The variable ‘x’ is implicitly lifted in the TH quotation
+ • In the Template Haskell quotation [| x |]
+
+T17804.hs:11:18: warning: [-Wimplicit-lift]
+ • The variable ‘x’ is implicitly lifted in the TH quotation
+ • In the Template Haskell quotation [|| x ||]
+ In the expression: [|| x ||]
+ In an equation for ‘warning2’: warning2 x = [|| x ||]
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 235c0148f7..fbc8428503 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -520,3 +520,4 @@ test('T18740c', normal, compile_fail, [''])
test('T18740d', normal, compile_fail, [''])
test('T19363', normal, compile_and_run, [''])
test('T19377', normal, compile, [''])
+test('T17804', normal, compile, [''])