www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18188] New: rdmd ignores dependency in 'static this()'


          Issue ID: 18188
           Summary: rdmd ignores dependency in 'static this()'
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dragoscarp gmail.com

There are cases when rdmd ignores the local imports defined in 'static this()'.
Moving 'import baz' out of static this will give the expected result.

See the example bellow.

// foo.d
void main()
    import bar;

// bar.d
static this()
    import baz : baz;

// baz.d
int baz()
    return 0;

$ rdmd --build-only --chatty foo.d
mkdirRecurse /tmp/.rdmd-500
mkdirRecurse /tmp/.rdmd-500/rdmd-foo.d-882FBF761B809294731EC3E5E391C36F
lock /tmp/.rdmd-500/rdmd-foo.d-882FBF761B809294731EC3E5E391C36F/rdmd.lock
mkdirRecurse /tmp/.rdmd-500/rdmd-foo.d-882FBF761B809294731EC3E5E391C36F/objs
stat /tmp/.rdmd-500/rdmd-foo.d-882FBF761B809294731EC3E5E391C36F/rdmd.deps
spawn ["/usr/bin/dmd", "-v", "-o-", "foo.d", "-I."]
read /tmp/.rdmd-500/rdmd-foo.d-882FBF761B809294731EC3E5E391C36F/rdmd.deps
which /usr/bin/dmd
stat /etc/dmd.conf
stat /tmp/.rdmd-500/rdmd-foo.d-882FBF761B809294731EC3E5E391C36F/.built
stat ./foo
stat foo.d
stat foo.d
stat /etc/dmd.conf
stat bar.d
stat /usr/bin/dmd
stat ./foo
spawn ["/usr/bin/dmd", "-of./foo.tmp",
"-od/tmp/.rdmd-500/rdmd-foo.d-882FBF761B809294731EC3E5E391C36F/objs", "-I.",
"foo.d", "bar.d"]
/tmp/.rdmd-500/rdmd-foo.d-882FBF761B809294731EC3E5E391C36F/objs/foo.o: In
function `_D3bar12_staticCtor1FZv':
bar.d:(.text._D3bar12_staticCtor1FZv[_D3bar12_staticCtor1FZv]+0x5): undefined
reference to `_D3bazQeFZi'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1

Jan 03 2018