[commit: ghc] master: Line up kind and type variables correctly when desugaring TH brackets (571f0ad)

git at git.haskell.org git at git.haskell.org
Thu Jun 12 16:23:47 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/571f0adccda687098d59f63524357f4ac98e72fb/ghc

>---------------------------------------------------------------

commit 571f0adccda687098d59f63524357f4ac98e72fb
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Jun 12 16:36:59 2014 +0100

    Line up kind and type variables correctly when desugaring TH brackets
    
    This bug was causing Trac #9199


>---------------------------------------------------------------

571f0adccda687098d59f63524357f4ac98e72fb
 compiler/deSugar/DsMeta.hs  | 13 ++++++++-----
 testsuite/tests/th/T9199.hs |  9 +++++++++
 testsuite/tests/th/all.T    |  1 +
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs
index 687cf55..b5d1b0f 100644
--- a/compiler/deSugar/DsMeta.hs
+++ b/compiler/deSugar/DsMeta.hs
@@ -63,6 +63,7 @@ import DynFlags
 import FastString
 import ForeignCall
 import Util
+import TcRnMonad( traceOptIf )
 
 import Data.Maybe
 import Control.Monad
@@ -707,12 +708,14 @@ addTyVarBinds :: LHsTyVarBndrs Name                            -- the binders to
 -- the computations passed as the second argument is executed in that extended
 -- meta environment and gets the *new* names on Core-level as an argument
 
-addTyVarBinds tvs m
-  = do { freshNames <- mkGenSyms (hsLKiTyVarNames tvs)
-       ; term <- addBinds freshNames $
-                 do { kbs <- repList tyVarBndrTyConName mk_tv_bndr (hsQTvBndrs tvs `zip` freshNames)
+addTyVarBinds (HsQTvs { hsq_kvs = kvs, hsq_tvs = tvs }) m
+  = do { fresh_kv_names <- mkGenSyms kvs
+       ; fresh_tv_names <- mkGenSyms (map hsLTyVarName tvs)
+       ; let fresh_names = fresh_kv_names ++ fresh_tv_names
+       ; term <- addBinds fresh_names $
+                 do { kbs <- repList tyVarBndrTyConName mk_tv_bndr (tvs `zip` fresh_tv_names)
                     ; m kbs }
-       ; wrapGenSyms freshNames term }
+       ; wrapGenSyms fresh_names term }
   where
     mk_tv_bndr (tv, (_,v)) = repTyVarBndrWithKind tv (coreVar v)
 
diff --git a/testsuite/tests/th/T9199.hs b/testsuite/tests/th/T9199.hs
new file mode 100644
index 0000000..aa41198
--- /dev/null
+++ b/testsuite/tests/th/T9199.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE TemplateHaskell, PolyKinds, TypeFamilies #-}
+
+module T9160 where
+
+$( [d| class C (a :: k) where
+          type F (a :: k) :: *
+    |]
+ )
+
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index ca7ead6..6e86d30 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -327,4 +327,5 @@ test('T8954', normal, compile, ['-v0'])
 test('T8932', normal, compile_fail, ['-v0'])
 test('T8987', normal, compile_fail, ['-v0'])
 test('T7241', normal, compile_fail, ['-v0'])
+test('T9199', normal, compile, ['-v0'])
 



More information about the ghc-commits mailing list