Thread overview
[Issue 16974] Equal associative arrays with associative array keys are considered unequal
Dec 15, 2016
Denis Shelomovskii
Dec 16, 2016
safety0ff.bugz
Dec 16, 2016
Denis Shelomovskii
Dec 16, 2016
Denis Shelomovskii
[Issue 16974] [REG2.068] Equal associative arrays with associative array keys are considered unequal
Dec 16, 2016
safety0ff.bugz
December 15, 2016
https://issues.dlang.org/show_bug.cgi?id=16974

--- Comment #1 from Denis Shelomovskii <verylonglogin.reg@gmail.com> ---
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

--
December 16, 2016
https://issues.dlang.org/show_bug.cgi?id=16974

safety0ff.bugz <safety0ff.bugz@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safety0ff.bugz@gmail.com

--- Comment #2 from safety0ff.bugz <safety0ff.bugz@gmail.com> ---
You've marked this as a regression, which version did this previously work in?

--
December 16, 2016
https://issues.dlang.org/show_bug.cgi?id=16974

--- Comment #3 from Denis Shelomovskii <verylonglogin.reg@gmail.com> ---
(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

--
December 16, 2016
https://issues.dlang.org/show_bug.cgi?id=16974

--- Comment #4 from Denis Shelomovskii <verylonglogin.reg@gmail.com> ---
(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.

--
December 16, 2016
https://issues.dlang.org/show_bug.cgi?id=16974

safety0ff.bugz <safety0ff.bugz@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Equal associative arrays    |[REG2.068] Equal
                   |with associative array keys |associative arrays with
                   |are considered unequal      |associative array keys are
                   |                            |considered unequal

--- Comment #5 from safety0ff.bugz <safety0ff.bugz@gmail.com> ---
(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.

--
December 28, 2016
https://issues.dlang.org/show_bug.cgi?id=16974

--- Comment #6 from github-bugzilla@puremagic.com ---
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

--
December 28, 2016
https://issues.dlang.org/show_bug.cgi?id=16974

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
January 15, 2017
https://issues.dlang.org/show_bug.cgi?id=16974

--- Comment #7 from github-bugzilla@puremagic.com ---
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

--
January 16, 2017
https://issues.dlang.org/show_bug.cgi?id=16974

--- Comment #8 from github-bugzilla@puremagic.com ---
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

--