diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2019-12-06 17:11:46 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-02-11 18:04:17 -0500 |
commit | 82023524ff050f26bf00be3432a97f1e537caf41 (patch) | |
tree | 27357f3a71baec1bbe8dab1c59ca82e370b3ca44 /testsuite | |
parent | 58a4ddeff7730d160dd66f19c288f8b5b27679e3 (diff) | |
download | haskell-82023524ff050f26bf00be3432a97f1e537caf41.tar.gz |
TemplateHaskellQuotes: Allow nested splices
There is no issue with nested splices as they do not require any compile
time code execution. All execution is delayed until the top-level
splice.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/quotes/TH_double_splice.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/quotes/TH_double_splice.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/quotes/TH_nested_splice.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/quotes/TH_top_splice.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/quotes/TH_top_splice.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/quotes/TTH_top_splice.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/quotes/TTH_top_splice.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/quotes/all.T | 4 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/safeLanguage/SafeLang12.stderr | 5 |
9 files changed, 54 insertions, 3 deletions
diff --git a/testsuite/tests/quotes/TH_double_splice.hs b/testsuite/tests/quotes/TH_double_splice.hs new file mode 100644 index 0000000000..d8a0faeeae --- /dev/null +++ b/testsuite/tests/quotes/TH_double_splice.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +module TH_double_splice where + +-- Should be a compile time error as TemplateHaskell is not enabled. + +foo = [| $($(error "should not happen")) |] + diff --git a/testsuite/tests/quotes/TH_double_splice.stderr b/testsuite/tests/quotes/TH_double_splice.stderr new file mode 100644 index 0000000000..34cb933a1d --- /dev/null +++ b/testsuite/tests/quotes/TH_double_splice.stderr @@ -0,0 +1,7 @@ + +TH_double_splice.hs:6:12: error: + • Top-level splices are not permitted without TemplateHaskell + • In the untyped splice: $(error "should not happen") + In the untyped splice: $($(error "should not happen")) + In the Template Haskell quotation + [| $($(error "should not happen")) |] diff --git a/testsuite/tests/quotes/TH_nested_splice.hs b/testsuite/tests/quotes/TH_nested_splice.hs new file mode 100644 index 0000000000..811aa5e426 --- /dev/null +++ b/testsuite/tests/quotes/TH_nested_splice.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE NoMonomorphismRestriction #-} +module TH_nested_splice where + +a = [| 5 |] + +b = [| $(a) |] + +c = [|| 5 ||] + +d = [|| $$(c) ||] diff --git a/testsuite/tests/quotes/TH_top_splice.hs b/testsuite/tests/quotes/TH_top_splice.hs new file mode 100644 index 0000000000..a7092bfd9d --- /dev/null +++ b/testsuite/tests/quotes/TH_top_splice.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +module TH_top_splice where + +-- Should be a compile time error as TemplateHaskell is not enabled. + +foo = $([| 1 |]) + diff --git a/testsuite/tests/quotes/TH_top_splice.stderr b/testsuite/tests/quotes/TH_top_splice.stderr new file mode 100644 index 0000000000..8ca30c2426 --- /dev/null +++ b/testsuite/tests/quotes/TH_top_splice.stderr @@ -0,0 +1,4 @@ + +TH_top_splice.hs:6:7: error: + • Top-level splices are not permitted without TemplateHaskell + • In the untyped splice: $([| 1 |]) diff --git a/testsuite/tests/quotes/TTH_top_splice.hs b/testsuite/tests/quotes/TTH_top_splice.hs new file mode 100644 index 0000000000..53b85434de --- /dev/null +++ b/testsuite/tests/quotes/TTH_top_splice.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +module TTH_top_splice where + +-- Should be a compile time error as TemplateHaskell is not enabled. + +qux = $$([|| 1 ||]) + + diff --git a/testsuite/tests/quotes/TTH_top_splice.stderr b/testsuite/tests/quotes/TTH_top_splice.stderr new file mode 100644 index 0000000000..ef659c21d8 --- /dev/null +++ b/testsuite/tests/quotes/TTH_top_splice.stderr @@ -0,0 +1,4 @@ + +TTH_top_splice.hs:6:7: error: + • Top-level splices are not permitted without TemplateHaskell + • In the typed splice: $$([|| 1 ||]) diff --git a/testsuite/tests/quotes/all.T b/testsuite/tests/quotes/all.T index a10da1046f..46f53bce6a 100644 --- a/testsuite/tests/quotes/all.T +++ b/testsuite/tests/quotes/all.T @@ -30,3 +30,7 @@ test('TH_repE3', normal, compile, ['']) test('TH_abstractFamily', normal, compile_fail, ['']) test('TH_localname', normal, compile_fail, ['']) test('TH_typed_csp', normal, compile, ['']) +test('TH_nested_splice', normal, compile, ['']) +test('TH_top_splice', normal, compile_fail, ['']) +test('TTH_top_splice', normal, compile_fail, ['']) +test('TH_double_splice', normal, compile_fail, ['']) diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang12.stderr b/testsuite/tests/safeHaskell/safeLanguage/SafeLang12.stderr index 55aa3a5a6c..c7923a0403 100644 --- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang12.stderr +++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang12.stderr @@ -8,6 +8,5 @@ SafeLang12_B.hs:2:14: warning: [2 of 3] Compiling SafeLang12_B ( SafeLang12_B.hs, SafeLang12_B.o ) [3 of 3] Compiling Main ( SafeLang12.hs, SafeLang12.o ) -SafeLang12.hs:8:1: error: - parse error on input ‘$’ - Perhaps you intended to use TemplateHaskell +SafeLang12.hs:1:1: error: + Top-level splices are not permitted without TemplateHaskell |