www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24830] New: separate compilation + circular deps + templated

https://issues.dlang.org/show_bug.cgi?id=24830

          Issue ID: 24830
           Summary: separate compilation + circular deps + templated opCmp
                    = missing symbols
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ilya.yanok gmail.com

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.

--
Oct 23