Bug 16974 – [REG2.068] Equal associative arrays with associative array keys are considered unequal
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-12-15T16:13:00Z
Last change time
2017-01-16T23:24:45Z
Keywords
wrong-code
Assigned to
nobody
Creator
verylonglogin.reg
Comments
Comment #0 by verylonglogin.reg — 2016-12-15T16:13:35Z
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
}
---
Comment #1 by verylonglogin.reg — 2016-12-15T16:26:12Z
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
Comment #2 by safety0ff.bugz — 2016-12-16T02:09:56Z
You've marked this as a regression, which version did this previously work in?
Comment #3 by verylonglogin.reg — 2016-12-16T10:24:14Z
(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
Comment #4 by verylonglogin.reg — 2016-12-16T12:59:29Z
(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.
Comment #5 by safety0ff.bugz — 2016-12-16T16:25:03Z
(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.
Comment #6 by github-bugzilla — 2016-12-28T00:09:57Z