www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10374] New: Associative arrays work with unoverriden `toHash`/`opEquals`/`opCmp`

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

           Summary: Associative arrays work with unoverriden
                    `toHash`/`opEquals`/`opCmp`
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          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
14:01:33 MSD ---
Documentation states classes must override `toHash`/`opEquals`/`opCmp` to work
as associative array keys. But current implementation works anyway.

As people are lazy I suppose lots of such classes are already used as
associative array keys.

So once e.g. compacting GC will be implemented and `Object`'s `toHash` equality
will stop being class instance address equality current AA implementation will
start using `Object`'s `opCmp` which will throw thus breaking lots of code.

I'd suggest to either document such usage or check in AA implementation that
required functions are overriden.

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


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com


--- Comment #1 from Jonathan M Davis <jmdavisProg gmx.com> 2013-06-16 03:25:28
PDT ---
If we ever actually manage to remove those functions from Object like we
decided to do, then this problem is solved in that Object won't have the
functions anyway.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 16 2013