Ticket #5962 (closed bug: fixed)

Opened 14 months ago

Last modified 9 months ago

Data.Typeable: types which should compare equal don't

Reported by: NickSmallbone Owned by: simonpj
Priority: normal Milestone: 7.4.3
Component: libraries/base Version: 7.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Difficulty: Unknown
Test Case: base/tests/T5962 Blocked By:
Blocking: Related Tickets:

Description

Here are two ways to construct a TypeRep? for the type () -> ():

Prelude> import Data.Typeable
Prelude Data.Typeable> let unitToUnit = typeOf (\() -> ())
Prelude Data.Typeable> let unitToUnit' = mkFunTy (typeOf ()) (typeOf ())

It seems to work:

Prelude Data.Typeable> unitToUnit
() -> ()
Prelude Data.Typeable> unitToUnit'
() -> ()

But the two TypeReps? are not equal:

Prelude Data.Typeable> unitToUnit == unitToUnit'
False

Change History

Changed 14 months ago by simonpj

  • owner set to simonpj
  • difficulty set to Unknown

I have a fix for this coming.

Changed 14 months ago by simonpj

  • status changed from new to closed
  • testcase set to base/tests/T5962
  • resolution set to fixed

Excellent point thank you. Fixed by

commit f35ebbd5dfd108487efa7912349e9802f6029897
Author: Simon Peyton Jones <simonpj@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(-)

Changed 14 months ago by simonmar

Aha, good bug!

Changed 10 months ago by simonmar

  • status changed from closed to merge
  • milestone set to 7.4.3

We really should have merged this.

Changed 9 months ago by pcapriotti

  • status changed from merge to closed

Merged as dd2af98d191d762e68e0b4c916096afad8b04dd7.

Note: See TracTickets for help on using tickets.