Testcase requires two files:
```
-- opcmp.d
int opCmp(T, U)(T t, U u); // When this line is removed the error disappears
mixin template DefineOpCmp() {
int opCmp(ref const typeof(this) rhs) const {
return 0;
}
}
-- testcase.d
//version = NO_IMPORT; // Error disappears when NO_IMPORT is set.
version (NO_IMPORT)
{
mixin template DefineOpCmp() {
int opCmp()(auto ref const typeof(this) rhs) const {
return 0;
}
}
struct A {
mixin DefineOpCmp;
}
}
else
{
struct A {
import opcmp;
mixin DefineOpCmp;
}
}
void foo(const(A) a, const(A) b) {
auto d = a.opCmp(b); // Works
pragma(msg, __traits(allMembers, A)); // AliasSeq!("opCmp")
auto c = a < b; // Error: need member function `opCmp()` for struct `const(A)` to compare
}
```
> dmd-2.107.1/osx/bin/dmd -c -o- testcase.d opcmp.d
AliasSeq!("opCmp")
testcase.d(25): Error: need member function `opCmp()` for struct `const(A)` to compare
Compilation succeeds with DMD <= 2.106.
Comment #1 by johanengelen — 2024-04-14T16:42:06Z
Selective import works around the issue somehow:
```
import opcmp : DefineOpCmp;
```
Comment #2 by robert.schadek — 2024-12-13T19:34:42Z