summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-01-15 13:02:34 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-01-27 10:03:42 -0500
commit1132602f764ef4694b52abeaeeaa8da544915134 (patch)
treeb7891c18a744b233a3e5fd568209dfa5ba81f9ac /testsuite
parent0940b59accb6926aaede045bcd5f5bdc77c7075d (diff)
downloadhaskell-1132602f764ef4694b52abeaeeaa8da544915134.tar.gz
Use splitLHs{ForAll,Sigma}TyInvis throughout the codebase
Richard points out in #17688 that we use `splitLHsForAllTy` and `splitLHsSigmaTy` in places that we ought to be using the corresponding `-Invis` variants instead, identifying two bugs that are caused by this oversight: * Certain TH-quoted type signatures, such as those that appear in quoted `SPECIALISE` pragmas, silently turn visible `forall`s into invisible `forall`s. * When quoted, the type `forall a -> (a ~ a) => a` will turn into `forall a -> a` due to a bug in `DsMeta.repForall` that drops contexts that follow visible `forall`s. These are both ultimately caused by the fact that `splitLHsForAllTy` and `splitLHsSigmaTy` split apart visible `forall`s in addition to invisible ones. This patch cleans things up: * We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis` throughout the codebase. Relatedly, the `splitLHsForAllTy` and `splitLHsSigmaTy` have been removed, as they are easy to misuse. * `DsMeta.repForall` now only handles invisible `forall`s to reduce the chance for confusion with visible `forall`s, which need to be handled differently. I also renamed it from `repForall` to `repForallT` to emphasize that its distinguishing characteristic is the fact that it desugars down to `L.H.TH.Syntax.ForallT`. Fixes #17688.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/th/T17688a.hs10
-rw-r--r--testsuite/tests/th/T17688a.stderr1
-rw-r--r--testsuite/tests/th/T17688b.hs15
-rw-r--r--testsuite/tests/th/T17688b.stderr2
-rw-r--r--testsuite/tests/th/all.T2
5 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/tests/th/T17688a.hs b/testsuite/tests/th/T17688a.hs
new file mode 100644
index 0000000000..aae0b6da21
--- /dev/null
+++ b/testsuite/tests/th/T17688a.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE TemplateHaskell #-}
+module T17688a where
+
+import Language.Haskell.TH
+import System.IO
+
+$( do ty <- [d| {-# SPECIALISE id :: forall a -> a -> a #-} |]
+ runIO $ hPutStrLn stderr $ pprint ty
+ return [] )
diff --git a/testsuite/tests/th/T17688a.stderr b/testsuite/tests/th/T17688a.stderr
new file mode 100644
index 0000000000..f746b553b8
--- /dev/null
+++ b/testsuite/tests/th/T17688a.stderr
@@ -0,0 +1 @@
+{-# SPECIALISE GHC.Base.id :: forall a_0 -> a_0 -> a_0 #-}
diff --git a/testsuite/tests/th/T17688b.hs b/testsuite/tests/th/T17688b.hs
new file mode 100644
index 0000000000..f78cf0266a
--- /dev/null
+++ b/testsuite/tests/th/T17688b.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE StandaloneKindSignatures #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TypeFamilies #-}
+module T17688b where
+
+import Data.Kind
+import Language.Haskell.TH hiding (Type)
+import System.IO
+
+$(do decs <- [d| type T :: forall (a :: Type) -> (a ~ a) => Type
+ data T x |]
+ runIO $ hPutStrLn stderr $ pprint decs
+ return [] )
diff --git a/testsuite/tests/th/T17688b.stderr b/testsuite/tests/th/T17688b.stderr
new file mode 100644
index 0000000000..e5384ff045
--- /dev/null
+++ b/testsuite/tests/th/T17688b.stderr
@@ -0,0 +1,2 @@
+type T_0 :: forall (a_1 :: *) -> a_1 ~ a_1 => *
+data T_0 x_2
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 1e0eb38218..72cb2b96df 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -496,5 +496,7 @@ test('T17379b', normal, compile_fail, [''])
test('T17461', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('T17511', normal, compile, [''])
test('T17608', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
+test('T17688a', normal, compile, [''])
+test('T17688b', normal, compile, [''])
test('TH_PprStar', normal, compile, ['-v0 -dsuppress-uniques'])
test('TH_StringLift', normal, compile, [''])