[commit: ghc] master: Fix IfaceType generation for TyCons without TyVars (952eda2)

git at git.haskell.org git at git.haskell.org
Tue Jan 19 19:56:51 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/952eda2ec98e6fde27d25a8c6f398674062e398e/ghc

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

commit 952eda2ec98e6fde27d25a8c6f398674062e398e
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Tue Jan 19 14:56:59 2016 -0500

    Fix IfaceType generation for TyCons without TyVars
    
    - This is only used for printing purposes (in :browse etc.).
    - Fixes #11266.
    
    Reviewers: goldfire, bgamari, austin
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1799
    
    GHC Trac Issues: #11266


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

952eda2ec98e6fde27d25a8c6f398674062e398e
 compiler/iface/MkIface.hs                  | 8 +++++++-
 testsuite/tests/ghci/scripts/T11266.script | 2 ++
 testsuite/tests/ghci/scripts/all.T         | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs
index 1db02bd..8548eb3 100644
--- a/compiler/iface/MkIface.hs
+++ b/compiler/iface/MkIface.hs
@@ -1410,16 +1410,22 @@ tyConToIfaceDecl env tycon
   -- For pretty printing purposes only.
   = ( env
     , IfaceData { ifName       = getOccName tycon,
+                  ifKind       =
+                    -- These don't have `tyConTyVars`, so we use an empty
+                    -- environment here, instead of `tc_env1` defined below.
+                    tidyToIfaceType emptyTidyEnv (tyConKind tycon),
                   ifCType      = Nothing,
                   ifTyVars     = funAndPrimTyVars,
                   ifRoles      = tyConRoles tycon,
-                  ifKind       = if_kind,
                   ifCtxt       = [],
                   ifCons       = IfDataTyCon [] False [],
                   ifRec        = boolToRecFlag False,
                   ifGadtSyntax = False,
                   ifParent     = IfNoParent })
   where
+    -- NOTE: Not all TyCons have `tyConTyVars` field. Forcing this when `tycon`
+    -- is one of these TyCons (FunTyCon, PrimTyCon, PromotedDataCon) will cause
+    -- an error.
     (tc_env1, tc_tyvars) = tidyTyClTyCoVarBndrs env (tyConTyVars tycon)
     if_tc_tyvars = toIfaceTvBndrs tc_tyvars
     if_kind = tidyToIfaceType tc_env1 (tyConKind tycon)
diff --git a/testsuite/tests/ghci/scripts/T11266.script b/testsuite/tests/ghci/scripts/T11266.script
new file mode 100644
index 0000000..9b3df76
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T11266.script
@@ -0,0 +1,2 @@
+:m + GHC.Prim
+:browse GHC.Prim
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 7a6225c..17bee5f 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -239,3 +239,4 @@ test('T10576a', expect_broken(10576), ghci_script, ['T10576a.script'])
 test('T10576b', expect_broken(10576), ghci_script, ['T10576b.script'])
 test('T11051a', normal, ghci_script, ['T11051a.script'])
 test('T11051b', normal, ghci_script, ['T11051b.script'])
+test('T11266', check_stdout(lambda *args: 1), ghci_script, ['T11266.script'])



More information about the ghc-commits mailing list