Bug 10374 – [AA] Associative arrays work with unoverriden `toHash`/`opEquals`/`opCmp`

Status
NEW
Severity
normal
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-16T03:01:33Z
Last change time
2024-12-07T13:32:47Z
Assigned to
No Owner
Creator
Denis Shelomovskii
Moved to GitHub: dmd#17257 →

Comments

Comment #0 by verylonglogin.reg — 2013-06-16T03:01:33Z
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.
Comment #1 by issues.dlang — 2013-06-16T03:25:28Z
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.
Comment #2 by robert.schadek — 2024-12-07T13:32:47Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17257 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB