summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/T13885.hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-08-22 09:28:56 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2017-08-22 09:28:56 -0400
commit79b259ae6a0a0c17568d7d03d82e378ad4c4001a (patch)
treedd2e517db55d20728aafa6259a6295f17a468969 /testsuite/tests/th/T13885.hs
parenta89bb806c58d3e601b37d6f2c4ebec6514fd2776 (diff)
downloadhaskell-79b259ae6a0a0c17568d7d03d82e378ad4c4001a.tar.gz
Fix #13885 by freshening reified GADT constructors' universal tyvars
Summary: When reifying GADTs with Template Haskell, the universally quantified type variables were being reused across both the data type head and the constructors' type signatures. This had the annoying effect of causing sets of differently scoped variables to have the same uniques. To avoid this, we now freshen the universal tyvars before reifying the constructors so as to ensure they have distinct uniques. Test Plan: make test TEST=T13885 Reviewers: goldfire, austin, bgamari, simonpj Reviewed By: simonpj Subscribers: rwbarton, thomie GHC Trac Issues: #13885 Differential Revision: https://phabricator.haskell.org/D3867
Diffstat (limited to 'testsuite/tests/th/T13885.hs')
-rw-r--r--testsuite/tests/th/T13885.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/th/T13885.hs b/testsuite/tests/th/T13885.hs
new file mode 100644
index 0000000000..0e29c88610
--- /dev/null
+++ b/testsuite/tests/th/T13885.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
+module Main where
+
+import Data.Function (on)
+import Language.Haskell.TH.Syntax
+
+data a :~: b = a ~ b => Refl
+
+$(return [])
+
+main :: IO ()
+main = print
+ $(do TyConI (DataD _ _ tycon_tyvars _
+ [ForallC con_tyvars _ _] _) <- reify ''(:~:)
+
+ let tvbName :: TyVarBndr -> Name
+ tvbName (PlainTV n) = n
+ tvbName (KindedTV n _) = n
+
+ lift $ and $ zipWith ((/=) `on` tvbName) tycon_tyvars con_tyvars)