Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/rt/aaA.d
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ extern (C) hash_t _aaGetHash(in AA* aa, in TypeInfo tiRaw) nothrow
continue;
size_t[2] h2 = [b.hash, valHash(b.entry + off)];
// use XOR here, so that hash is independent of element order
h ^= hashOf(h2.ptr, h2.length * h2[0].sizeof);
h ^= hashOf(h2);
}
return h;
}
Expand Down Expand Up @@ -1001,3 +1001,15 @@ pure nothrow unittest
assert(aa.length == 1);
assert(aa[5] == 6);
}

// test AA as key (Issue 16974)
unittest
{
int[int] a = [1 : 2], a2 = [1 : 2];

assert([a : 3] == [a : 3]);
assert([a : 3] == [a2 : 3]);

assert(typeid(a).getHash(&a) == typeid(a).getHash(&a));
assert(typeid(a).getHash(&a) == typeid(a).getHash(&a2));
}