[commit: ghc] master: Fix embarrassing, egregious bug in roles of (->) (255d2e3)

git at git.haskell.org git at git.haskell.org
Thu Nov 1 21:43:07 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/255d2e323a8879a7296a5ab94e6cc49023e2c86e/ghc

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

commit 255d2e323a8879a7296a5ab94e6cc49023e2c86e
Author: Richard Eisenberg <rae at cs.brynmawr.edu>
Date:   Thu Nov 1 15:07:36 2018 -0400

    Fix embarrassing, egregious bug in roles of (->)
    
    Previously, I had inexplicably decided that (->)'s roles
    were all Representational. But, of course, its first two
    parameters are *dependent* RuntimeReps. All dependent parameters
    have a Nominal role, because all roles in kinds are Nominal.
    
    Fix is easy, but I have no idea how the world hasn't come
    crashing down before now.
    
    This was found while investigating #15801, which requires
    visible type application in types to observe. Hence, the test
    case will come with the main patch for #12045.


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

255d2e323a8879a7296a5ab94e6cc49023e2c86e
 compiler/iface/IfaceSyn.hs | 2 +-
 compiler/types/TyCon.hs    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler/iface/IfaceSyn.hs b/compiler/iface/IfaceSyn.hs
index 3266c5a..7d1e697 100644
--- a/compiler/iface/IfaceSyn.hs
+++ b/compiler/iface/IfaceSyn.hs
@@ -903,7 +903,7 @@ pprRoles :: (Role -> Bool) -> SDoc -> [IfaceTyConBinder]
 pprRoles suppress_if tyCon bndrs roles
   = sdocWithDynFlags $ \dflags ->
       let froles = suppressIfaceInvisibles dflags bndrs roles
-      in ppUnless (all suppress_if roles || null froles) $
+      in ppUnless (all suppress_if froles || null froles) $
          text "type role" <+> tyCon <+> hsep (map ppr froles)
 
 pprInfixIfDeclBndr :: ShowHowMuch -> OccName -> SDoc
diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs
index c96cb6b..eeebf8b 100644
--- a/compiler/types/TyCon.hs
+++ b/compiler/types/TyCon.hs
@@ -2259,7 +2259,7 @@ tyConRoles :: TyCon -> [Role]
 -- See also Note [TyCon Role signatures]
 tyConRoles tc
   = case tc of
-    { FunTyCon {}                         -> const_role Representational
+    { FunTyCon {}                         -> [Nominal, Nominal, Representational, Representational]
     ; AlgTyCon { tcRoles = roles }        -> roles
     ; SynonymTyCon { tcRoles = roles }    -> roles
     ; FamilyTyCon {}                      -> const_role Nominal



More information about the ghc-commits mailing list