Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : ghc-7.4

http://hackage.haskell.org/trac/ghc/changeset/dd2af98d191d762e68e0b4c916096afad8b04dd7

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

commit dd2af98d191d762e68e0b4c916096afad8b04dd7
Author: Simon Peyton Jones <[email protected]>
Date:   Fri Mar 30 12:51:14 2012 +0100

    Fix an egregious bug in the fingerprint calculation for TypeRep
    
    Given (T ty1) and ty2, we were computing the fingerprint of the
    application (T ty1 ty2) by combining the two fingerprints from (T ty1)
    and ty2.  But that gives a different answer to combinging the three
    fingerprints from T, ty1, and ty2, which is what happens if you
    build the type all at once.  Urk!
    
    Fixes Trac #5962
    
    MERGED from commit f35ebbd5dfd108487efa7912349e9802f6029897

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

 Data/Typeable/Internal.hs |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Data/Typeable/Internal.hs b/Data/Typeable/Internal.hs
index b5916e1..a89f43c 100644
--- a/Data/Typeable/Internal.hs
+++ b/Data/Typeable/Internal.hs
@@ -157,9 +157,12 @@ funResultTy trFun trArg
 
 -- | Adds a TypeRep argument to a TypeRep.
 mkAppTy :: TypeRep -> TypeRep -> TypeRep
-mkAppTy (TypeRep tr_k tc trs) arg_tr
-  = let (TypeRep arg_k _ _) = arg_tr
-     in  TypeRep (fingerprintFingerprints [tr_k,arg_k]) tc (trs++[arg_tr])
+mkAppTy (TypeRep _ tc trs) arg_tr = mkTyConApp tc (trs ++ [arg_tr])
+   -- Notice that we call mkTyConApp to construct the fingerprint from tc and
+   -- the arg fingerprints.  Simply combining the current fingerprint with
+   -- the new one won't give the same answer, but of course we want to 
+   -- ensure that a TypeRep of the same shape has the same fingerprint!
+   -- See Trac #5962
 
 -- | Builds a 'TyCon' object representing a type constructor.  An
 -- implementation of "Data.Typeable" should ensure that the following holds:



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to