[commit: ghc] master: PrelInfo: Ensure that tuple promoted datacon names are in knownKeyNames (4aa299d)

git at git.haskell.org git at git.haskell.org
Sat Jun 4 07:33:04 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/4aa299db6b1025822673713a110b17c002ddcfaf/ghc

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

commit 4aa299db6b1025822673713a110b17c002ddcfaf
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Fri Jun 3 22:19:17 2016 +0200

    PrelInfo: Ensure that tuple promoted datacon names are in knownKeyNames
    
    Previously the promoted datacons of the boxed tuple types were not
    included in knownKeyNames, which lead to #12132.
    
    Test Plan: Test with included TypeOf testcase
    
    Reviewers: austin, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2279
    
    GHC Trac Issues: #12132


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

4aa299db6b1025822673713a110b17c002ddcfaf
 compiler/iface/LoadIface.hs                        | 2 +-
 compiler/prelude/PrelInfo.hs                       | 7 ++++---
 testsuite/tests/typecheck/should_run/TypeOf.hs     | 1 +
 testsuite/tests/typecheck/should_run/TypeOf.stdout | 1 +
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/compiler/iface/LoadIface.hs b/compiler/iface/LoadIface.hs
index 64d100f..ba58c9e 100644
--- a/compiler/iface/LoadIface.hs
+++ b/compiler/iface/LoadIface.hs
@@ -169,7 +169,7 @@ for any module with an instance decl or RULE that we might want.
 
 * BUT, if the TyCon is a wired-in TyCon, we don't really need its interface;
   but we must make sure we read its interface in case it has instances or
-  rules.  That is what LoadIface.loadWiredInHomeInterface does.  It's called
+  rules.  That is what LoadIface.loadWiredInHomeIface does.  It's called
   from TcIface.{tcImportDecl, checkWiredInTyCon, ifCheckWiredInThing}
 
 * HOWEVER, only do this for TyCons.  There are no wired-in Classes.  There
diff --git a/compiler/prelude/PrelInfo.hs b/compiler/prelude/PrelInfo.hs
index 74005ed..52493b4 100644
--- a/compiler/prelude/PrelInfo.hs
+++ b/compiler/prelude/PrelInfo.hs
@@ -85,19 +85,20 @@ knownKeyNames
 
            , concatMap tycon_kk_names typeNatTyCons
 
-           , concatMap (rep_names . tupleTyCon Boxed) [2..mAX_TUPLE_SIZE]  -- Yuk
+           , concatMap (tycon_kk_names . tupleTyCon Boxed) [2..mAX_TUPLE_SIZE]  -- Yuk
 
            , cTupleTyConNames
              -- Constraint tuples are known-key but not wired-in
              -- They can't show up in source code, but can appear
-             -- in intreface files
+             -- in interface files
 
            , map idName wiredInIds
            , map (idName . primOpId) allThePrimOps
            , basicKnownKeyNames ]
 
   where
-    -- "kk" short for "known-key"
+  -- All of the names associated with a known-key thing.
+  -- This includes TyCons, DataCons and promoted TyCons.
   tycon_kk_names :: TyCon -> [Name]
   tycon_kk_names tc = tyConName tc : (rep_names tc ++ concatMap thing_kk_names (implicitTyConThings tc))
 
diff --git a/testsuite/tests/typecheck/should_run/TypeOf.hs b/testsuite/tests/typecheck/should_run/TypeOf.hs
index efd26f9..53e0359 100644
--- a/testsuite/tests/typecheck/should_run/TypeOf.hs
+++ b/testsuite/tests/typecheck/should_run/TypeOf.hs
@@ -31,4 +31,5 @@ main = do
   print $ typeOf (Proxy :: Proxy *)
   print $ typeOf (Proxy :: Proxy ★)
   print $ typeOf (Proxy :: Proxy 'PtrRepLifted)
+  print $ typeOf (Proxy :: Proxy '(1, "hello"))
   print $ typeOf (Proxy :: Proxy (~~))
diff --git a/testsuite/tests/typecheck/should_run/TypeOf.stdout b/testsuite/tests/typecheck/should_run/TypeOf.stdout
index 6f160f5..3e3396f 100644
--- a/testsuite/tests/typecheck/should_run/TypeOf.stdout
+++ b/testsuite/tests/typecheck/should_run/TypeOf.stdout
@@ -20,4 +20,5 @@ Proxy Constraint Constraint
 Proxy Constraint Constraint
 Proxy Constraint Constraint
 Proxy RuntimeRep 'PtrRepLifted
+Proxy (Nat,Symbol) ('(,) Nat Symbol 1 "hello")
 Proxy (Constraint -> Constraint -> Constraint) ~~



More information about the ghc-commits mailing list