Bug 12311 – Use `opCmp` for equality check if defined

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-07T01:28:20Z
Last change time
2024-12-13T18:18:00Z
Assigned to
No Owner
Creator
Denis Shelomovskii
Moved to GitHub: dmd#18790 →

Comments

Comment #0 by verylonglogin.reg — 2014-03-07T01:28:20Z
As `opCmp` is enough to check for equality a compiler could use it: --- struct S { int opCmp(const S) const { return 1; } } class C { override int opCmp(Object) { return 0; } } void main() { assert(S.init != S.init); assert(new C == new C); } ---
Comment #1 by verylonglogin.reg — 2014-03-07T01:28:50Z
With such behaviour we can change associative arrays to use `equals` instead of `compare` [1] without any breaking changes. [1] https://github.com/D-Programming-Language/druntime/pull/522
Comment #2 by robert.schadek — 2024-12-13T18:18:00Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18790 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB