summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-09-13 09:37:13 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2017-09-13 09:37:13 -0400
commit9ff9c35895ecc072f289c93addd1faad884bf122 (patch)
tree30707ea1b2139ecd555f5352d85cee0bf17f0718 /testsuite/tests
parent0ebc8dc3525ddaa04a0c9e4c0c1aef70fd3fe725 (diff)
downloadhaskell-9ff9c35895ecc072f289c93addd1faad884bf122.tar.gz
Check if -XStaticPointers is enabled when renaming static expressions
Summary: Trying to use `static` expressions without the `-XStaticPointers` extension enabled can lead to runtime errors. Normally, such a situation isn't possible, but Template Haskell provides a backdoor that allows it to happen, as shown in #14204. To prevent this, we ensure that `-XStaticPointers` is enabled when renaming `static` expressions. Test Plan: make test TEST=T14204 Reviewers: facundominguez, austin, bgamari, simonpj Reviewed By: facundominguez, simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #14204 Differential Revision: https://phabricator.haskell.org/D3931
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/th/T14204.hs8
-rw-r--r--testsuite/tests/th/T14204.stderr5
-rw-r--r--testsuite/tests/th/all.T1
3 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/tests/th/T14204.hs b/testsuite/tests/th/T14204.hs
new file mode 100644
index 0000000000..e952dbd5a7
--- /dev/null
+++ b/testsuite/tests/th/T14204.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T14204 where
+
+import GHC.StaticPtr
+import Language.Haskell.TH
+
+main :: IO ()
+main = putStrLn (deRefStaticPtr $(pure (StaticE (LitE (StringL "wat")))))
diff --git a/testsuite/tests/th/T14204.stderr b/testsuite/tests/th/T14204.stderr
new file mode 100644
index 0000000000..90150e2050
--- /dev/null
+++ b/testsuite/tests/th/T14204.stderr
@@ -0,0 +1,5 @@
+
+T14204.hs:8:35: error:
+ • Illegal static expression: static "wat"
+ Use StaticPointers to enable this extension
+ • In the untyped splice: $(pure (StaticE (LitE (StringL "wat"))))
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 1e737ace8f..aa973f7203 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -394,4 +394,5 @@ test('T13856', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('T13885', normal, compile_and_run, ['-v0'])
test('T13887', normal, compile_and_run, ['-v0'])
test('T13968', normal, compile_fail, ['-v0'])
+test('T14204', normal, compile_fail, ['-v0'])
test('T14060', normal, compile_and_run, ['-v0'])