[Issue 18271] `dmd -deps fun1.d fun2.d` produces very different results when order of source files changes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 20 09:23:37 UTC 2018


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

--- Comment #2 from Timothee Cour <timothee.cour2 at gmail.com> ---
according to @marler8997 on
https://github.com/dlang/tools/pull/291#issuecomment-359156301

> I think this may be by design. It only performs the full semantic analysis on modules imported by the first module given on the command line. I remember seeing the code do this and I thought it was odd but I assumed there was a reason for this.


> https://github.com/dlang/dmd/blob/f947c0881432988dcd8cd80d5abe71e4c0463867/src/dmd/mars.d#L822

> This is where the extra semantic analysis is done when the -deps flag is used. As you can see, only module[0].aimports is being scanned. This is either a bug or by design. If it's a bug, then the fix is likely to loop over Modules.modules instead of modules[0].aimports.


-----
* this is not documented in -deps (and also not in dmd changelog)
* what's a use case for doing it only on the 1st module?
here's a use case for doing it on all files passed on cmdline:

```
// main.d:
extern(C) void fun();
import other1;
void main(){fun();}

// mylib.d:
import other2;
extern(C) void fun(){}

// cmd line
dmd -deps main.d mylib.d
```

Would be nice to have as orthogonal features as possible;
could we have:
-i mean recurse on imports (while respecting -i=pattern)
-deps mean output dependencies (on whatever's being analyzed)

--


More information about the Digitalmars-d-bugs mailing list