https://issues.dlang.org/show_bug.cgi?id=12797
Issue ID: 12797
Summary: RDMD tries to compile imports inside
traits(compiles,...)
Product: D
Version: unspecified
Hardware: x86_64
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: tools
Assignee: [email protected]
Reporter: [email protected]
// test.d
enum x = __traits(compiles, (){ import doesNotExist; });
DMD works:
> dmd -c test.d
RDMD fails:
> rdmd -c test.d
Error: cannot read file doesNotExist.d
The problem is RDMD gets dependencies by reading DMD's -v output, which always
includes doesNotExist (since DMD *does* attempt to import it). Since RDMD sees
doesNotExist in the -v output, it mistakenly tries to build it.
This prevents optional imports from working with RDMD:
static if( __traits(compiles, (){ import foobar; }) )
{ import foobar; }
else
/+ do something else +/
It might be better for RDMD to read the -deps output instead, and omit the
files listed with "(???)" as the filename.
--