summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite/tests/th/T17820a.hs7
-rw-r--r--testsuite/tests/th/T17820a.stderr5
-rw-r--r--testsuite/tests/th/T17820b.hs7
-rw-r--r--testsuite/tests/th/T17820b.stderr5
-rw-r--r--testsuite/tests/th/T17820c.hs8
-rw-r--r--testsuite/tests/th/T17820c.stderr5
-rw-r--r--testsuite/tests/th/T17820d.hs6
-rw-r--r--testsuite/tests/th/T17820d.stderr7
-rw-r--r--testsuite/tests/th/T17820e.hs9
-rw-r--r--testsuite/tests/th/T17820e.stderr5
-rw-r--r--testsuite/tests/th/all.T5
11 files changed, 69 insertions, 0 deletions
diff --git a/testsuite/tests/th/T17820a.hs b/testsuite/tests/th/T17820a.hs
new file mode 100644
index 0000000000..6caf010de6
--- /dev/null
+++ b/testsuite/tests/th/T17820a.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Main where
+
+data D = C ()
+
+$( const mempty C )
diff --git a/testsuite/tests/th/T17820a.stderr b/testsuite/tests/th/T17820a.stderr
new file mode 100644
index 0000000000..2a4b5c2f25
--- /dev/null
+++ b/testsuite/tests/th/T17820a.stderr
@@ -0,0 +1,5 @@
+
+T17820a.hs:7:17: error:
+ GHC stage restriction:
+ ‘C’ is used in a top-level splice, quasi-quote, or annotation,
+ and must be imported, not defined locally
diff --git a/testsuite/tests/th/T17820b.hs b/testsuite/tests/th/T17820b.hs
new file mode 100644
index 0000000000..f42b7cce1a
--- /dev/null
+++ b/testsuite/tests/th/T17820b.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Main where
+
+data D = C { f :: () }
+
+$( const mempty f )
diff --git a/testsuite/tests/th/T17820b.stderr b/testsuite/tests/th/T17820b.stderr
new file mode 100644
index 0000000000..941a3b1e49
--- /dev/null
+++ b/testsuite/tests/th/T17820b.stderr
@@ -0,0 +1,5 @@
+
+T17820b.hs:7:17: error:
+ GHC stage restriction:
+ ‘f’ is used in a top-level splice, quasi-quote, or annotation,
+ and must be imported, not defined locally
diff --git a/testsuite/tests/th/T17820c.hs b/testsuite/tests/th/T17820c.hs
new file mode 100644
index 0000000000..ed463e63df
--- /dev/null
+++ b/testsuite/tests/th/T17820c.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Main where
+
+class C t where
+ meth :: t ()
+
+$( const mempty (meth :: forall t. C t => t ()) )
diff --git a/testsuite/tests/th/T17820c.stderr b/testsuite/tests/th/T17820c.stderr
new file mode 100644
index 0000000000..469a94352c
--- /dev/null
+++ b/testsuite/tests/th/T17820c.stderr
@@ -0,0 +1,5 @@
+
+T17820c.hs:8:18: error:
+ GHC stage restriction:
+ ‘meth’ is used in a top-level splice, quasi-quote, or annotation,
+ and must be imported, not defined locally
diff --git a/testsuite/tests/th/T17820d.hs b/testsuite/tests/th/T17820d.hs
new file mode 100644
index 0000000000..712b5d5073
--- /dev/null
+++ b/testsuite/tests/th/T17820d.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Main where
+
+decls = [d| data D = MkD { foo :: Int }
+ blargh = $(const [| 0 |] foo) |]
diff --git a/testsuite/tests/th/T17820d.stderr b/testsuite/tests/th/T17820d.stderr
new file mode 100644
index 0000000000..3d624c7104
--- /dev/null
+++ b/testsuite/tests/th/T17820d.stderr
@@ -0,0 +1,7 @@
+
+T17820d.hs:6:38: error:
+ • Stage error: ‘foo’ is bound at stage 2 but used at stage 1
+ • In the untyped splice: $(const [| 0 |] foo)
+ In the Template Haskell quotation
+ [d| data D = MkD {foo :: Int}
+ blargh = $(const [| 0 |] foo) |]
diff --git a/testsuite/tests/th/T17820e.hs b/testsuite/tests/th/T17820e.hs
new file mode 100644
index 0000000000..b42707d8a7
--- /dev/null
+++ b/testsuite/tests/th/T17820e.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE TemplateHaskell, TypeFamilies #-}
+
+module Main where
+
+data family F a
+
+data instance F () = C ()
+
+$( const mempty C )
diff --git a/testsuite/tests/th/T17820e.stderr b/testsuite/tests/th/T17820e.stderr
new file mode 100644
index 0000000000..2c74b263e2
--- /dev/null
+++ b/testsuite/tests/th/T17820e.stderr
@@ -0,0 +1,5 @@
+
+T17820e.hs:9:17: error:
+ GHC stage restriction:
+ ‘C’ is used in a top-level splice, quasi-quote, or annotation,
+ and must be imported, not defined locally
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 306af0a911..5bc6d89135 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -534,3 +534,8 @@ test('T19737', normal, compile, [''])
test('T19759', normal, compile, [''])
test('T20060', normal, compile, [''])
test('T20179', normal, compile_fail, [''])
+test('T17820a', normal, compile_fail, [''])
+test('T17820b', normal, compile_fail, [''])
+test('T17820c', normal, compile_fail, [''])
+test('T17820d', normal, compile_fail, [''])
+test('T17820e', normal, compile_fail, [''])