digitalmars.D - dub test errors during linking for struct with uninstantiated
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (24/24) Jun 21 2020 When a module containing
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (3/4) Jun 21 2020 BTW this fails for dmd stable and dmd nightly but works for ldc
- kinke (5/7) Jun 21 2020 I'd suggest taking dub out of the equation then, so that you can
- kinke (4/5) Jun 21 2020 After quickly looking at your list of compiler flags in dub.sdl,
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/7) Jun 21 2020 Thanks a lot! I'll do so.
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/3) Jun 21 2020 Done: https://issues.dlang.org/show_bug.cgi?id=20968
- Boris Carvajal (14/17) Jun 22 2020 You can get more info compiling with "-verrors=spec"
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__T8Ra ionalTiZQm6__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
Jun 21 2020
On Sunday, 21 June 2020 at 12:42:11 UTC, Per Nordlöw wrote:When a module containingBTW this fails for dmd stable and dmd nightly but works for ldc 1.22.0.
Jun 21 2020
On Sunday, 21 June 2020 at 12:42:11 UTC, Per Nordlöw wrote:I'm suspecting this is a bug in dmd that fails to correctly check if a struct has its templated `opEquals` instantiated.I'd suggest taking dub out of the equation then, so that you can file a DMD issue once you can confirm it. Your sample works with `-main -unittest` on run.dlang.io, so it seems to depend on how the test executable is built.
Jun 21 2020
On Sunday, 21 June 2020 at 16:58:43 UTC, kinke wrote:Your sample works with `-main -unittest` on run.dlang.ioAfter quickly looking at your list of compiler flags in dub.sdl, the problem manifests when adding `-preview=in`. Please file an issue.
Jun 21 2020
On Sunday, 21 June 2020 at 17:05:11 UTC, kinke wrote:On Sunday, 21 June 2020 at 16:58:43 UTC, kinke wrote:Thanks a lot! I'll do so.Your sample works with `-main -unittest` on run.dlang.ioAfter quickly looking at your list of compiler flags in dub.sdl, the problem manifests when adding `-preview=in`. Please file an issue.
Jun 21 2020
On Sunday, 21 June 2020 at 17:05:11 UTC, kinke wrote:Please file an issue.Done: https://issues.dlang.org/show_bug.cgi?id=20968
Jun 21 2020
On Sunday, 21 June 2020 at 22:48:20 UTC, Per Nordlöw wrote:On Sunday, 21 June 2020 at 17:05:11 UTC, kinke wrote: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.Please file an issue.Done: https://issues.dlang.org/show_bug.cgi?id=20968
Jun 22 2020