Bug 18911 – __FILE_FULL_PATH__ is wrong in imported module
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-27T09:30:39Z
Last change time
2018-05-27T11:41:41Z
Assigned to
No Owner
Creator
johanengelen
Comments
Comment #0 by johanengelen — 2018-05-27T09:30:39Z
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.