summaryrefslogtreecommitdiff
path: root/testsuite/tests/th
diff options
context:
space:
mode:
authorJan Stolarek <jan.stolarek@p.lodz.pl>2015-10-20 14:09:13 +0200
committerJan Stolarek <jan.stolarek@p.lodz.pl>2015-10-20 20:27:27 +0200
commit1750ebc2e40bab85246717326d3d5c60f132e652 (patch)
treefc7317ebcff4e667f38340b4dd5be58579e0226b /testsuite/tests/th
parentae4acbd1ba4168b867a1b5fe8de50c0199dfc1f4 (diff)
downloadhaskell-1750ebc2e40bab85246717326d3d5c60f132e652.tar.gz
Reject top-level typed TH splices. Fixes #10945
When TemplateHaskell language extension is enabled it is valid to have top-level expressions. Each such expression is treated as a contents of a splice. The problem arises with typed splices. They are not valid at the top level and therefore we should interpret them not as a splice but as a top-level expression (aka. implicit splice). So saying: $$foo is equivalent of: $( $$foo ) This patch makes sure that this is indeed the case. Until now we incorrectly treated typed splices as explicit splices.
Diffstat (limited to 'testsuite/tests/th')
-rw-r--r--testsuite/tests/th/T10945.stderr29
-rw-r--r--testsuite/tests/th/all.T2
2 files changed, 30 insertions, 1 deletions
diff --git a/testsuite/tests/th/T10945.stderr b/testsuite/tests/th/T10945.stderr
new file mode 100644
index 0000000000..0c1d949053
--- /dev/null
+++ b/testsuite/tests/th/T10945.stderr
@@ -0,0 +1,29 @@
+
+T10945.hs:7:11:
+ Couldn't match expected type ‘TExp DecsQ’ with actual type ‘[Dec]’
+ In the first argument of ‘return’, namely
+ ‘[SigD
+ (mkName "m")
+ (ForallT
+ [PlainTV (mkName "a")]
+ []
+ (AppT (AppT ArrowT (VarT (mkName "a"))) (VarT (mkName "a")))),
+ FunD (mkName "m") [Clause [...] (NormalB (VarE (mkName "x"))) []]]’
+ In the expression:
+ return
+ [SigD
+ (mkName "m")
+ (ForallT
+ [PlainTV (mkName "a")]
+ []
+ (AppT (AppT ArrowT (VarT (mkName "a"))) (VarT (mkName "a")))),
+ FunD (mkName "m") [Clause [...] (NormalB (VarE (mkName "x"))) []]]
+ In the Template Haskell splice
+ $$(return
+ [SigD
+ (mkName "m")
+ (ForallT
+ [PlainTV (mkName "a")]
+ []
+ (AppT (AppT ArrowT (VarT (mkName "a"))) (VarT (mkName "a")))),
+ FunD (mkName "m") [Clause [...] (NormalB (VarE (mkName "x"))) []]])
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 1e05d72171..3d08f365fa 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -366,5 +366,5 @@ test('T10796b', normal, compile_fail, ['-v0'])
test('T10811', normal, compile, ['-v0'])
test('T10810', normal, compile, ['-v0'])
test('T10891', normal, compile, ['-v0'])
-test('T10945', expect_broken(10945), compile, ['-v0'])
+test('T10945', normal, compile_fail, ['-v0'])
test('T10946', expect_broken(10946), compile, ['-v0'])