[commit: base] master: Fix an egregious bug in the fingerprint calculation for TypeRep (f35ebbd)
Simon Peyton Jones
simonpj at microsoft.com
Wed Apr 4 17:22:21 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/f35ebbd5dfd108487efa7912349e9802f6029897
>---------------------------------------------------------------
commit f35ebbd5dfd108487efa7912349e9802f6029897
Author: Simon Peyton Jones <simonpj at microsoft.com>
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
>---------------------------------------------------------------
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:
More information about the Cvs-libraries
mailing list