www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16995] New: __traits(getUnittests) doesn't work with separate


          Issue ID: 16995
           Summary: __traits(getUnittests) doesn't work with separate
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: atila.neves gmail.com

void main() {
    import bar;
    foreach(ut; __traits(getUnitTests, bar)) ut();

unittest { assert(1 == 2); }

# compile all at once
dmd -unittest foo.d bar.d # fine

# compile separately
dmd -c -unittest foo.d
dmd -c -unittest bar.d
dmd foo.o bar.o
foo.o:foo.d:function _Dmain: error: undefined reference to
collect2: error: ld returned 1 exit status
--- errorlevel 1

objdump shows me that bar.o has a '_D3bar14__unittestL2_1FZv' symbol, which is
nearly, but not quite, what foo.o is trying to call.

Dec 20 2016