[commit: ghc] wip/rae: Fix #11797. (4284193)

git at git.haskell.org git at git.haskell.org
Thu Apr 7 14:50:22 UTC 2016


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

On branch  : wip/rae
Link       : http://ghc.haskell.org/trac/ghc/changeset/4284193c5dc22c6db3d97a49658829be5fe0076d/ghc

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

commit 4284193c5dc22c6db3d97a49658829be5fe0076d
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date:   Wed Apr 6 16:37:22 2016 +0200

    Fix #11797.
    
    DsMeta curiously omitted quantified tyvars in certain circumstances.
    This patch means it doesn't.
    
    Test case: th/T11797


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

4284193c5dc22c6db3d97a49658829be5fe0076d
 compiler/deSugar/DsMeta.hs       | 13 +++++++------
 testsuite/tests/th/T11797.hs     | 14 ++++++++++++++
 testsuite/tests/th/T11797.stderr |  2 ++
 testsuite/tests/th/all.T         |  1 +
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs
index 84f1a9c..3bc4ae9 100644
--- a/compiler/deSugar/DsMeta.hs
+++ b/compiler/deSugar/DsMeta.hs
@@ -872,12 +872,9 @@ repContext ctxt = do preds <- repList typeQTyConName repLTy ctxt
                      repCtxt preds
 
 repHsSigType :: LHsSigType Name -> DsM (Core TH.TypeQ)
-repHsSigType ty = repLTy (hsSigType ty)
-
-repHsSigWcType :: LHsSigWcType Name -> DsM (Core TH.TypeQ)
-repHsSigWcType (HsIB { hsib_vars = vars
-                     , hsib_body = sig1 })
-  | (explicit_tvs, ctxt, ty) <- splitLHsSigmaTy (hswc_body sig1)
+repHsSigType (HsIB { hsib_vars = vars
+                   , hsib_body = body })
+  | (explicit_tvs, ctxt, ty) <- splitLHsSigmaTy body
   = addTyVarBinds (HsQTvs { hsq_implicit = []
                           , hsq_explicit = map (noLoc . UserTyVar . noLoc) vars ++
                                            explicit_tvs
@@ -889,6 +886,10 @@ repHsSigWcType (HsIB { hsib_vars = vars
          then return th_ty
          else repTForall th_tvs th_ctxt th_ty }
 
+repHsSigWcType :: LHsSigWcType Name -> DsM (Core TH.TypeQ)
+repHsSigWcType ib_ty@(HsIB { hsib_body = sig1 })
+  = repHsSigType (ib_ty { hsib_body = hswc_body sig1 })
+
 -- yield the representation of a list of types
 --
 repLTys :: [LHsType Name] -> DsM [Core TH.TypeQ]
diff --git a/testsuite/tests/th/T11797.hs b/testsuite/tests/th/T11797.hs
new file mode 100644
index 0000000..0ee0a04
--- /dev/null
+++ b/testsuite/tests/th/T11797.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module T11797 where
+
+import Language.Haskell.TH
+import System.IO
+
+$(do dec <- [d| class Foo a where
+                  meth :: a -> b -> a |]
+     runIO $ do putStrLn $ pprint dec
+                hFlush stdout
+     return [] )
+
+-- the key bit is the forall b. in the type of the method
diff --git a/testsuite/tests/th/T11797.stderr b/testsuite/tests/th/T11797.stderr
new file mode 100644
index 0000000..1b43982
--- /dev/null
+++ b/testsuite/tests/th/T11797.stderr
@@ -0,0 +1,2 @@
+class Foo_0 a_1
+    where meth_2 :: forall b_3 . a_1 -> b_3 -> a_1
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 3939880..c182479 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -397,3 +397,4 @@ test('T10603', normal, compile, ['-ddump-splices -dsuppress-uniques'])
 test('T11452', normal, compile_fail, ['-v0'])
 test('T9022', normal, compile_and_run, ['-v0'])
 test('T11145', normal, compile_fail, ['-v0 -dsuppress-uniques'])
+test('T11797', normal, compile, ['-v0 -dsuppress-uniques'])



More information about the ghc-commits mailing list