Thread overview
[Issue 16015] Sometimes importing a module both top-level and in a version(unittest) block causes some method overrides to be hidden
May 11, 2016
Sophie
May 11, 2016
Sophie
May 12, 2016
Sophie
May 12, 2016
b2.temp@gmx.com
Mar 21, 2020
Basile-z
Dec 17, 2022
Iain Buclaw
May 11, 2016
https://issues.dlang.org/show_bug.cgi?id=16015

Sophie <meapineapple@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |x86_64
                 OS|Mac OS X                    |Windows

--- Comment #1 from Sophie <meapineapple@gmail.com> ---
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.

--
May 11, 2016
https://issues.dlang.org/show_bug.cgi?id=16015

--- Comment #2 from Sophie <meapineapple@gmail.com> ---
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.

--
May 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16015

--- Comment #3 from Sophie <meapineapple@gmail.com> ---
The provided example fails to compile on OSX Mavericks with the same error.

--
May 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16015

b2.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com
           Hardware|x86_64                      |All
                 OS|Windows                     |All

--- Comment #4 from b2.temp@gmx.com ---
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.

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=16015

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=16015

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=16015

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19122

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--