wilzbach / tools-test

1 stars 0 forks source link

RDMD tries to compile imports inside traits(compiles,...) #107

Closed wilzbach closed 6 years ago

wilzbach commented 10 years ago

Note: the issue was created automatically migrated from https://issues.dlang.org

Original bug ID: BZ#12797 From: Nick Sabalausky <bus_dbugzilla@semitwist.com> Reported version: D2 CC: b2.temp@gmx.com

wilzbach commented 10 years ago

Comment author: Nick Sabalausky <bus_dbugzilla@semitwist.com>

// 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.

wilzbach commented 6 years ago

Comment author: Basile B. <b2.temp@gmx.com>

RDMD still uses -v but DMD -v doesn't include it anymore so it works now