www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18271] New: `dmd -deps fun1.d fun2.d` produces very different

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

          Issue ID: 18271
           Summary: `dmd -deps fun1.d fun2.d` produces very different
                    results when order of source files changes
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

$ time ~/Downloads/dmd2_074/osx/bin/dmd     -c -deps=/tmp/z02.txt fun2.d fun3.d
&& wc -l /tmp/z02.txt
cpu 0.052 total
     109 /tmp/z02.txt

$ time ~/Downloads/dmd2_074/osx/bin/dmd     -c -deps=/tmp/z02.txt fun3.d fun2.d
&& wc -l /tmp/z02.txt
cpu 0.055 total
     109 /tmp/z02.txt

with dmd_075 up to today(v2.077.1) I get:

$ time dmd     -c -deps=/tmp/z02.txt fun3.d fun2.d && wc -l /tmp/z02.txt
cpu 0.784 total
    1137 /tmp/z02.txt
$ time dmd     -c -deps=/tmp/z02.txt fun2.d fun3.d && wc -l /tmp/z02.txt
cpu 0.058 total
     107 /tmp/z02.txt

Note also that (depending on order), dmd produces much more output (and is
slower) than before; I'm guessing (depending on order), it will do semantic
analysis on function local imports; in any way, the order-dependency is a bug.


```
// fun2.d
void test2(){
        import fun3;
        test3;
}
// fun3.d
void test3(){
        import std.stdio;
        writeln(__FILE__);
}
```

--
Jan 20 2018