[commit: ghc] ghc-8.0: Fix #11797. (3f7832b)

git at git.haskell.org git at git.haskell.org
Fri Apr 15 09:57:50 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/3f7832bc36f6cca42a33ec274fc5e7808af74a38/ghc

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

commit 3f7832bc36f6cca42a33ec274fc5e7808af74a38
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
    
    (cherry picked from commit dd99f2ece1bd139be02beddc6dc672862ee5ae34)


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

3f7832bc36f6cca42a33ec274fc5e7808af74a38
 compiler/deSugar/DsMeta.hs       | 13 +++++++------
 docs/users_guide/8.0.1-notes.rst |  8 ++++++++
 testsuite/tests/th/T11797.hs     | 14 ++++++++++++++
 testsuite/tests/th/T11797.stderr |  2 ++
 testsuite/tests/th/T8031.hs      |  3 ++-
 testsuite/tests/th/all.T         |  1 +
 6 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs
index d221979..a24bbeb 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/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst
index 87aeda5..1d1553c 100644
--- a/docs/users_guide/8.0.1-notes.rst
+++ b/docs/users_guide/8.0.1-notes.rst
@@ -432,6 +432,14 @@ Template Haskell
    whether flags such as :ghc-flag:`-XStrictData` or
    :ghc-flag:`-funbox-strict-fields` are enabled.
 
+-  Previously, quoting a type signature like ``a -> a`` would produce the
+   abstract syntax for ``forall a. a -> a``. This behavior remains, but it
+   is extended to kinds, too, meaning that ``Proxy a -> Proxy a`` becomes
+   ``forall k (a :: k). Proxy a -> Proxy a``. This change is not intentional,
+   but is forced by the fact that GHC has a hard time telling kinds apart
+   from types. The effect of this change is that round-tripping kind-
+   polymorphic types will now require :ghc-flag:`-XTypeInType`.
+
 Runtime system
 ~~~~~~~~~~~~~~
 
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/T8031.hs b/testsuite/tests/th/T8031.hs
index e71f347..9f06c06 100644
--- a/testsuite/tests/th/T8031.hs
+++ b/testsuite/tests/th/T8031.hs
@@ -1,9 +1,10 @@
-{-# LANGUAGE TemplateHaskell, RankNTypes, DataKinds, TypeOperators, PolyKinds,
+{-# LANGUAGE TemplateHaskell, RankNTypes, TypeOperators, TypeInType,
              GADTs #-}
 
 module T8031 where
 
 import Data.Proxy
+import Data.Kind
 
 data SList :: [k] -> * where
   SCons :: Proxy h -> Proxy t -> SList (h ': t)
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 9055430..ccf6e48 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -403,3 +403,4 @@ test('T11145', normal, compile_fail, ['-v0 -dsuppress-uniques'])
 test('T11463', normal, compile_and_run, ['-v0 -dsuppress-uniques'])
 test('T11680', normal, compile_fail, ['-v0'])
 test('T11809', normal, compile, ['-v0'])
+test('T11797', normal, compile, ['-v0 -dsuppress-uniques'])



More information about the ghc-commits mailing list