Bug 24501 – [REG2.107] imported mixin opCmp member function not found for a < b

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-04-14T16:38:43Z
Last change time
2024-12-13T19:34:42Z
Keywords
industry, rejects-valid
Assigned to
No Owner
Creator
johanengelen
Moved to GitHub: dmd#20441 →

Comments

Comment #0 by johanengelen — 2024-04-14T16:38:43Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20441 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB