www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21238] New: -deps considers only the first instantiation site

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

          Issue ID: 21238
           Summary: -deps considers only the first instantiation site of a
                    template for dependencies
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

Related forum thread: https://forum.dlang.org/post/rjfu9o$uq$1 digitalmars.com

This regression was introduced by the fix for issue 9948.

Consider these four modules:

    --- foo.d
    import baz;
    alias x = t!();

    --- bar.d
    import baz;
    alias x = t!();

    --- baz.d
    template t() { import qux; }

    --- qux.d
    // empty

`-deps` should show dependency paths going from foo and bar to qux, either
directly or via baz.

`dmd2.063 -o- -deps=>(cat) foo.d bar.d | grep -v druntime` prints (excerpt):

    foo (foo.d) : private : baz (baz.d)
    baz (baz.d) : private : qux (qux.d)
    bar (bar.d) : private : baz (baz.d)

I.e., it shows the expected paths (via baz).

Since 2.064, the same command prints:

    foo (foo.d) : private : baz (baz.d)
    foo (foo.d) : private : qux (qux.d)
    bar (bar.d) : private : baz (baz.d)

Note that it shows a direct edge from foo to qux (which is ok), but no path
from bar to qux (neither direct, nor via baz).

The same thing happens with other kinds of dependencies: `import("qux")`,
`version (qux) {}`, `pragma(lib, "qux")`.

Possible fixes:
1) revert to the behavior of 2.063, or
2) fix -deps to also print a direct edge from bar to qux.

--
Sep 11 2020