Bug 10380 – [AA] Wrong code using associative array as key type in associative array

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-16T07:10:00Z
Last change time
2014-06-02T20:21:42Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2013-06-16T07:10:44Z
`TypeInfo_AssociativeArray` don't override `equals` and `compare` so one get mess if an associative array is used as a key type in an associative array. E.g. `keyti.compare` in `_aaEqual` calls `TypeInfo`'s `compare` which always return `0`.
Comment #1 by verylonglogin.reg — 2013-06-16T07:57:46Z
Override `equals` in `TypeInfo_AssociativeArray`: https://github.com/D-Programming-Language/druntime/pull/523 Currently there is no comparison functions for AA-s, see Issue 10381.
Comment #2 by github-bugzilla — 2013-06-22T08:44:22Z
Comment #3 by hsteoh — 2013-07-08T19:30:41Z
Do you have any failing unittest for this bug? I can't seem to reproduce the problem in git HEAD.
Comment #4 by verylonglogin.reg — 2013-07-08T23:49:34Z
(In reply to comment #3) > Do you have any failing unittest for this bug? I can't seem to reproduce the > problem in git HEAD. It's hard to create unittests as the problem will appear iff we will have to unequal AA-s with equal hashes.
Comment #5 by hsteoh — 2013-07-09T06:44:21Z
I have a fix for this, but I need to somehow make a unittest to verify that it actually fixes the problem. Maybe we can somehow craft a unittest using typeid(aa).compare?
Comment #6 by hsteoh — 2013-07-09T07:56:57Z
Comment #7 by hsteoh — 2013-07-09T07:58:00Z
I figured out a way to test for broken .compare: make an AA key type that overrides both opEquals and opCmp, and deliberately have wrong implementation for opCmp.
Comment #8 by hsteoh — 2013-07-27T06:46:52Z
Hi Denis, Can you check this bug again? Recently Kenji & I made some fixes in this area, and this may be fixed now. Could you verify?
Comment #9 by verylonglogin.reg — 2013-07-27T07:24:07Z
(In reply to comment #8) > Hi Denis, > > Can you check this bug again? Recently Kenji & I made some fixes in this area, > and this may be fixed now. Could you verify? Currently `equals` is overriden in `TypeInfo_AssociativeArray` as druntime pull 523 is merged. But it doesn't changes this issue situation as `equals` isn't used. The issue will be fixed if e.g. this pull will be merged: https://github.com/D-Programming-Language/druntime/pull/522
Comment #10 by verylonglogin.reg — 2013-11-07T07:42:47Z
*** Issue 6254 has been marked as a duplicate of this issue. ***
Comment #11 by verylonglogin.reg — 2014-03-09T00:16:32Z
As pull 522 was rejected opened a new one for exactly this issue: https://github.com/D-Programming-Language/druntime/pull/736
Comment #12 by github-bugzilla — 2014-03-12T02:21:24Z
Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/33ea0c56407b4a37c382e3fbfb11206c66900dae Hack fix Issue 10380 - [AA] Wrong code using associative array as key type in associative array Issue URL: https://d.puremagic.com/issues/show_bug.cgi?id=10380 https://github.com/D-Programming-Language/druntime/commit/feb4560cb25ca6575c3491324a468a783c3567ba Merge pull request #736 from denis-sh/hack-fix-Issue-10380 Hack fix Issue 10380 - [AA] Wrong code using associative array as key type in associative array
Comment #13 by verylonglogin.reg — 2014-03-12T02:44:34Z
Hack-fixed.
Comment #14 by github-bugzilla — 2014-06-01T00:57:45Z
Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/1b40f861923bb39a8fca9cb42f0268608860ad8c Revert "Hack fix Issue 10380 - [AA] Wrong code using associative array as key type in associative array" This reverts commit 33ea0c56407b4a37c382e3fbfb11206c66900dae.
Comment #15 by verylonglogin.reg — 2014-06-02T20:21:42Z
Hack-fix is reverted as the issue is correctly fixed by druntime pull 522 [1] which is finally reopened and merged. [1] https://github.com/D-Programming-Language/druntime/pull/522