The issue: https://pharo.fogbugz.com/f/cases/16760/Dictionary-breaks-when-comparing-ide...
Sent: Sunday, October 11, 2015 at 7:23 AM From: monty <monty2@programmer.net> To: pharo-dev@lists.pharo.org Subject: Re: [Pharo-dev] hash and Collections
Resending because the last was HTML'd:
Never use #newFrom: with associations from another dictonary if you reuse the first after. Â The bug is actually deeper than you know: dic1 := Dictionary newFrom:{'test' -> 4}. dic2 := IdentityDictionary newFrom: {'test' copy -> 4}. dic1 = dic2. dic2 = dic1. Â Depending on the order, they are equal or inequal. Â The bug is caused by Dictionary>>= using a polymorphic type test #isDictionary. Squeak is unaffected: its #= uses a hardcoded class == test. The least disruptive fix I can think of is adding another type test #isIdentityDictionary in Dictionary that returns false but returns true for every identity dictionary class (like SmalllIdentityDictionary). Then only compare the associations if "self isIdentityDictionary = aDictionary isIdentityDictionary". Â I will open an issue.