Bug in -J

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 11 20:02:31 PDT 2017


On Saturday, 12 August 2017 at 02:45:30 UTC, rikki cattermole 
wrote:
> On 12/08/2017 3:34 AM, Mr. Pib wrote:
>> I have -J added to the command line like
>> 
>> -JC:\Temp
>> 
>> I then use import(r"C:\Temp\a.dat");
>> 
>> and I get an error about the file not existing in the
>> 
>> main.d: Error: file "C:\\Temp\\a.dat" cannot be found or not 
>> in a path specified with -J
>> 
>> It seems dmd does internally compare the paths to see if they 
>> are identical.

No, it just prefixes the given import() path will all those given 
by -J.

>> Of course, removing the C:\Temp\ part of import works fine.
>> 
>> The problem with that approach is it then is not consistent 
>> with other code. I need to specify the full path because 
>> sometimes it is used.
>> 
>> essentially
>> 
>> version(X)
>> import(path)
>> else
>> load(path);

I don't understand why you would want to do that. Using absolute 
paths makes assumptions about the system your software is being 
built on. Even if you never plan to build the software on any 
computer but your own, it still seems like a questionable design 
decision.

>> while I could do something like
>> 
>> import(baseName(path))
>> 
>> it seems kinda clunky, in any case. It's pretty obvious that 
>> one excepts the same behavior so it could create bugs in code 
>> that except the behavior to work correctly.

You could also use -J/ and import(path[1..$]) (or the Windows 
equivalent). Still a bad idea.

> Most likely related or is the issue[0].
>
> [0] https://issues.dlang.org/show_bug.cgi?id=3420

Nope.



More information about the Digitalmars-d mailing list