www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18911] New: __FILE_FULL_PATH__ is wrong in imported module

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

          Issue ID: 18911
           Summary: __FILE_FULL_PATH__ is wrong in imported module
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johanengelen weka.io

In a module that is imported after being found by the import path on the
cmdline, __FILE_FULL_PATH__ is wrong, e.g. it is:
"/Users/johan/bla/bla/include//Users/johan/bla/bla/bla/" (somehow duplicating
part of the path).

Testcase:

```
// File: fullfilepath.d
import a;

enum THIS_FILE = __FILE_FULL_PATH__;

enum suffix_this = "fullfilepath.d";

static assert(THIS_FILE[0..$-suffix_this.length] ==
A_FILE[0..$-suffix_a.length]);
```

```
// File: include/a.d
enum A_FILE = __FILE_FULL_PATH__;
enum suffix_a = "include/a.d";
```

Compilation fails both with relative include path:
```
dmd -c -Iinclude fullfilepath.d
```
and with absolute include path:
```
dmd -c -I/your/absolute/path/include fullfilepath.d
```

This was fixed in DMD 2.079.
But there is no testcase for it, so opening this bug report and submitting a PR
with testcase soon after.

--
May 27 2018