dub test errors during linking for struct with uninstantiated templated opEquals
Per Nordlöw
per.nordlow at gmail.com
Sun Jun 21 12:42:11 UTC 2020
When a module containing
module nxt.rational;
Rational!(I1) rational(I1, I2)(I1 , I2)
{
return typeof(return)();
}
struct Rational(Int)
{
bool opEquals(Rhs)(Rhs _) {}
}
@nogc unittest
{
auto _ = rational(1, 2);
}
is used as the sole module of a dub project then `dub test` fails
as
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-06C9DAF60B64114484B3FE9AC9866D5F/phobos-next-test-library.o:src/nxt/rational.d:_D40TypeInfo_S3nxt8rational__T8RationalTiZQm6__initZ: error: undefined reference to '_D6object10_xopEqualsFMxPvMxQeZb'
When I remove
bool opEquals(Rhs)(Rhs _) {}
the error goes away.
I'm suspecting this is a bug in dmd that fails to correctly check
if a struct has its templated `opEquals` instantiated.
For a complete minimal sample project see
https://github.com/nordlow/phobos-next/tree/master/rational.reduced
More information about the Digitalmars-d
mailing list