Wrong selection of opEquals for objects.

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Fri Aug 28 08:16:01 UTC 2020


Hi everyone,

there is https://issues.dlang.org/show_bug.cgi?id=21180 bug, 
anyone knows how to avoid it?

Test case:
-------------
import std;

class Silly {
     bool opEquals(const Silly silly) const @safe {
         return silly is this;
     }

     alias opEquals = Object.opEquals;
}

bool comp(T)() @safe {
     return new T() == new T();
}

void main()
{
     comp!Silly.writeln;
     comp!(const Silly).writeln;
     comp!(immutable Silly).writeln;
}
-------------

It always tries to call Object.opEquals, when narrower overload 
should've been selected.

- Alex.


More information about the Digitalmars-d-learn mailing list