Skip to content
Snippets Groups Projects
Commit dd2af98d authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by pcapriotti
Browse files

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 f35ebbd5
parent 35c90716
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment