diff options
author | Jan Stolarek <jan.stolarek@p.lodz.pl> | 2015-10-20 14:09:13 +0200 |
---|---|---|
committer | Jan Stolarek <jan.stolarek@p.lodz.pl> | 2015-10-20 20:27:27 +0200 |
commit | 1750ebc2e40bab85246717326d3d5c60f132e652 (patch) | |
tree | fc7317ebcff4e667f38340b4dd5be58579e0226b /testsuite | |
parent | ae4acbd1ba4168b867a1b5fe8de50c0199dfc1f4 (diff) | |
download | haskell-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')
-rw-r--r-- | testsuite/tests/th/T10945.stderr | 29 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 2 |
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']) |