[Issue 20968] Linker error of uninstantiated templated `opEquals` member of struct when compiled with -preview=in

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 22 09:43:07 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20968

Boris Carvajal <boris2.9 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |boris2.9 at gmail.com

--- Comment #2 from Boris Carvajal <boris2.9 at gmail.com> ---
Just quoting forum's reply
https://forum.dlang.org/thread/mftygusieubpaoobyogx@forum.dlang.org

You can get more info compiling with "-verrors=spec"

"(spec:1) Error: template rational.Rational!int.Rational.opEquals cannot deduce
function from argument types !()(const(Rational!int)) const, candidates are:"

>From reading the docs for function opEquals
(https://dlang.org/spec/operatoroverloading.html#equals).
It shows a templated version with a const modifier.
If you change the function signature to:

bool opEquals(Rhs)(Rhs _) const {return true;} // Note the 'const', and putting
some return back because dustmite removed it

The program links fine.

So it seems a compiler error is gagged that should be exposed and also could be
improved.

--


More information about the Digitalmars-d-bugs mailing list