summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2019-02-03 11:46:28 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-02-10 08:35:46 -0500
commita48753bdbc99cda36890e851950f5b79e1c3b2b2 (patch)
tree6046bf111b644d492ea21ab3ee499809650e61c6 /testsuite
parent027017fb33923b106765f5a0a6fc000ebe421d40 (diff)
downloadhaskell-a48753bdbc99cda36890e851950f5b79e1c3b2b2.tar.gz
Capture and simplify constraints arising from running typed splices
This fixes a regression caused by #15471 where splicing in a trivial program such as `[|| return () ||]` would fail as the dictionary for `return` would never get bound in the module containing the splice. Arguably this is symptomatic of a major problem affecting TTH where we serialise renamed asts and then retype check them. The reference to the dictionary should be fully determined at the quote site so that splicing doesn't have to solve any implicits at all. It's a coincidence this works due to coherence but see #15863 and #15865 for examples where things do go very wrong. Fixes #16195
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/th/T16195.hs15
-rw-r--r--testsuite/tests/th/T16195A.hs13
-rw-r--r--testsuite/tests/th/all.T1
3 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/th/T16195.hs b/testsuite/tests/th/T16195.hs
new file mode 100644
index 0000000000..70e936548d
--- /dev/null
+++ b/testsuite/tests/th/T16195.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T16195 where
+
+import T16195A
+
+main2 :: IO ()
+main2 = return ()
+
+main :: IO ()
+main = $$foo
+
+main3 :: IO ()
+main3 = putStrLn ($$showC $$unitC)
+
+
diff --git a/testsuite/tests/th/T16195A.hs b/testsuite/tests/th/T16195A.hs
new file mode 100644
index 0000000000..b79aff77af
--- /dev/null
+++ b/testsuite/tests/th/T16195A.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T16195A where
+
+import Language.Haskell.TH
+
+foo :: Q (TExp (IO ()))
+foo = [|| return () ||]
+
+showC :: Q (TExp (() -> String))
+showC = [|| show ||]
+
+unitC :: Q (TExp ())
+unitC = [|| () ||]
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 0d34c69c5c..a92cef42f1 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -463,3 +463,4 @@ test('T16133', normal, compile_fail, [''])
test('T15471', normal, multimod_compile, ['T15471.hs', '-v0'])
test('T16180', normal, compile_and_run, ['-package ghc'])
test('T16183', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
+test('T16195', normal, multimod_compile, ['T16195.hs', '-v0'])