This code should run fine: --- void main() { int[int] a = [1 : 2]; assert([a : 3] == [a : 3]); // fails assert([a : 3] == [[1 : 2] : 3]); // fails } ---
The reason is incorrect hash calculation: --- int[int] a = [1 : 2]; assert(typeid(a).getHash(&a) == typeid(a).getHash(&a)); // fails --- Opened druntime pull 1715 [1]. This incorrect hash calculation became possible because of `hashOf` signature, see Issue 16973. [1] https://github.com/dlang/druntime/pull/1715
You've marked this as a regression, which version did this previously work in?
(In reply to safety0ff.bugz from comment #2) > You've marked this as a regression, which version did this previously work > in? Because at least before 79bc91b41334c1805f557ef2f1606de31c6764d1 [1] `rt.util.hash.hashOf` was used in `_aaGetHash`. Though I didn't actually test it. [1] https://github.com/dlang/druntime/commit/79bc91b41334c1805f557ef2f1606de31c6764d1
(In reply to Denis Shelomovskii from comment #3) > Though I didn't actually My friend's code which worked around 2.5 years ago is now broken.
(In reply to Denis Shelomovskii from comment #3) > > Because at least before 79bc91b41334c1805f557ef2f1606de31c6764d1 [1] > `rt.util.hash.hashOf` was used in `_aaGetHash`. Though I didn't actually > test it. Ah, yea, I see the import was removed, good enough for me.
Commits pushed to stable at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/5cc28431b92d6849ef7758d200f714f5aee996f3 Fix Issue 16974 - Equal associative arrays with associative array keys are considered unequal Use correct overload of `hashOf` in `_aaGetHash`. This incorrect usage is possible because of Issue 16973 - `hashOf` has error-prone signature as `(T, seed)` may be confused with `(ptr, length)` [1]. [1] https://issues.dlang.org/show_bug.cgi?id=16973 https://github.com/dlang/druntime/commit/d57fdb116ebb9dc1a7c0f1983c253db58dbbc22b Merge pull request #1715 from denis-sh/fix-Issue-16974 [REG2.068] Fix Issue 16974 - Equal associative arrays with associative array keys are considered unequal
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/5cc28431b92d6849ef7758d200f714f5aee996f3 Fix Issue 16974 - Equal associative arrays with associative array keys are considered unequal https://github.com/dlang/druntime/commit/d57fdb116ebb9dc1a7c0f1983c253db58dbbc22b Merge pull request #1715 from denis-sh/fix-Issue-16974
Commits pushed to newCTFE at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/5cc28431b92d6849ef7758d200f714f5aee996f3 Fix Issue 16974 - Equal associative arrays with associative array keys are considered unequal https://github.com/dlang/druntime/commit/d57fdb116ebb9dc1a7c0f1983c253db58dbbc22b Merge pull request #1715 from denis-sh/fix-Issue-16974