See http://forum.dlang.org/post/[email protected]
Attempts to reproduce this error more concisely have been unsuccessful, either the redundant imports resolve without error (e.g. import some_module duplicated) or the compiler gives an error like "Error: alias some_module.some_struct conflicts with alias some_module.some_struct" (e.g. import some_module : some_struct duplicated). In short - both of those errors are sensible and I haven't been able to pin down what caused the different behavior in the code given in the linked post.
Comment #1 by meapineapple — 2016-05-11T12:34:15Z
In retrospect, inability to reproduce the error seems to be due to having originally encountered the error on Win7 and having attempted to reproduce using a simpler example on OSX Mavericks. Reverting my code to the previous erroneous state that failed to compile on Windows caused no errors on OSX. I can try to come up with a concise example sometime later on for code that fails to compile on Windows, when I have access to my Windows machine again.
Comment #2 by meapineapple — 2016-05-11T22:28:02Z
I was able to reproduce this error on Windows 7 and will try this specific test on OSX Mavericks soon, but I expect the problem is not present on OSX.
Testing this requires two files:
test1.d
import test2 : mystruct;
import std.stdio : writeln;
struct anotherstruct{
int y = 0;
void testmethod(in int x){
writeln(x * this.y);
}
void testmethod(T)(in mystruct!T my){
writeln(my.x * this.y);
}
}
version(unittest) import test2 : mystruct;
unittest{
auto mine = mystruct!int(2);
auto another = anotherstruct(2);
another.testmethod(0); // compiles
another.testmethod(mine); // does not compile
}
test2.d
struct mystruct(T){T x;}
This is the resulting error:
E:\Dropbox\Projects\d\misc\test1.d(19): Error: none of the overloads of 'testmethod' are callable using argument types (mystruct!int), candidates are:
E:\Dropbox\Projects\d\misc\test1.d(6): test1.anotherstruct.testmethod(const(int) x)
Failed: ["dmd", "-IE:/Dropbox/Projects/d", "-debug", "-g", "-unittest", "-v", "-o-", "E:\\Dropbox\\Projects\\d\\misc\\test1.d", "-IE:\\Dropbox\\Projects\\d\\misc"]
[Finished in 0.3s with exit code 1]
[shell_cmd: rdmd -odbin/ -I"E:/Dropbox/Projects/d" -debug -g --main -unittest "E:\Dropbox\Projects\d\misc\test1.d"]
If mystruct is not templated, then sensible descriptive errors occur letting me know that I've aliased the imported "mystruct" twice, and if without the template I just "import test2;" then everything compiles fine.
Removing "version(unittest) import test2 : mystruct;" from test1.d also allows the problematic line to compile.
Comment #3 by meapineapple — 2016-05-12T12:43:55Z
The provided example fails to compile on OSX Mavericks with the same error.
Comment #4 by b2.temp — 2016-05-12T13:43:05Z
Also this doesn't happen when the import is not selective because then there's no alias to the struct declared in the other module.
The problem is a very uninformative message, as you've noted, the conflict is not detected when the struct declared in the second module is not a template.
Comment #5 by robert.schadek — 2024-12-13T18:47:44Z