http://d.puremagic.com/issues/show_bug.cgi?id=7512



--- Comment #5 from hst...@quickfur.ath.cx 2012-02-27 17:39:10 PST ---
Found cause of problem:

const int[] key = [1,2,3,4];
int[int[]] map1 = [ key: 1234 ];

// map1's internal hashtable has keyti pointing to typeid(const(int)[])

int[int[]] map2;
map2[key] = 1234;

// map2's internal hashtable has keyti pointing to typeid(int[])

This causes 'key' to map to a different hash value in map1 than in map2. So
far, no real problem yet. However, this:

map1[key] = 1234;

computes the hash value of 'key' using typeid(int[]).getHash(), NOT
typeid(const(int)[]).getHash(), causing a duplicate entry to appear in map1.
That is, the hash value of 'key' in the above line is exactly the same as the
hash value of key in "map2[key] = 1234". In fact, it seems that AA.get() and
AA[...] always uses the non-const typeinfo to compute the hash value, so it
will never find the keys created by the AA literal. The only time the entries
in the AA literal are actually visible is via foreach.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to