It's probably a rare case, but if I try to compile separately two modules that are part of a dependency cycle, and both of them are instantiating a templated struct that has a templated `opCmp` implementation (I think `opEquals` and `toHash` are also affected), none of the resulting object files will contains the code for the `opCmp` instantiation.
Example:
```d
// option.d
import util;
struct Option(T) {
private T _x;
int opCmp()(const(Option) rhs) const {
return 1;
}
}
Option!string p;
```
```d
// util.d
import option;
Option!string x;
```
This is happening because while compiling `option.d` the compiler thinks `Option!string.opCmp!()` is instantiated in `util.d` and vice versa, so we end up not having it at all.
Comment #1 by ilya.yanok — 2024-10-23T14:18:30Z
This happens since even though while processing the second `Option!string` instantiation we try to update the `minst` of all children to the root module, it fails to update the automatically generated `__xopCmp` method (and friends). I have a fix and currently am working on the test case. I'll send a PR soon.
Comment #2 by dlang-bot — 2024-10-23T15:44:09Z
@yanok updated dlang/dmd pull request #17022 "dsymbolsem/InstMemberWalker: also visit generated structs' members" fixing this issue:
- dsymbolsem/InstMemberWalker: also visit generated structs' members
While updating children's `minst` only going over `members` is not
enough: structs may also have generated methods that are not in
`members`.
As a result, if a generated method instantiates a template, it gets a
poentially wrong `minst`, so can be omitted from the compilation result.
Fixes Bugzilla Issue 24830.
https://github.com/dlang/dmd/pull/17022
Comment #3 by dlang-bot — 2024-10-23T22:40:23Z
dlang/dmd pull request #17022 "dsymbolsem/InstMemberWalker: also visit generated structs' members" was merged into master:
- 1f98c6b69854348a271b9cd1314f77822f875f77 by Ilya Yanok:
dsymbolsem/InstMemberWalker: also visit generated structs' members
While updating children's `minst` only going over `members` is not
enough: structs may also have generated methods that are not in
`members`.
As a result, if a generated method instantiates a template, it gets a
poentially wrong `minst`, so can be omitted from the compilation result.
Fixes Bugzilla Issue 24830.
https://github.com/dlang/dmd/pull/17022