www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10380] New: Wrong code using associative array as key type in associative array

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380

           Summary: Wrong code using associative array as key type in
                    associative array
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: critical
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-06-16
18:10:44 MSD ---
`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`.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 16 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #1 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-06-16
18:57:46 MSD ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #2 from github-bugzilla puremagic.com 2013-06-22 08:44:22 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/1c6603e9c0f6081d12fa1cd898bc77db7769914a
Override `equals` in `TypeInfo_AssociativeArray`.

Fixes part of Issue 10380.

Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=10380

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #3 from hsteoh quickfur.ath.cx 2013-07-08 19:30:41 PDT ---
Do you have any failing unittest for this bug? I can't seem to reproduce the
problem in git HEAD.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #4 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-07-09
10:49:34 MSD ---
(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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #5 from hsteoh quickfur.ath.cx 2013-07-09 06:44:21 PDT ---
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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #6 from hsteoh quickfur.ath.cx 2013-07-09 07:56:57 PDT ---
https://github.com/D-Programming-Language/druntime/pull/544

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #7 from hsteoh quickfur.ath.cx 2013-07-09 07:58:00 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #8 from hsteoh quickfur.ath.cx 2013-07-27 06:46:52 PDT ---
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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 27 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10380



--- Comment #9 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-07-27
18:24:07 MSD ---
(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 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 27 2013