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
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?
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