[Issue 15086] import doesn't verify module declaration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 13 21:13:09 UTC 2018


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

--- Comment #18 from Timothee Cour <timothee.cour2 at gmail.com> ---
> Even better would be a bug whereby the project builds both ways but does different things. That would be the smoking gun.

could shorten but this shows it:

./asdf/wrong.d
pragma(msg, __FILE__," ",__MODULE__);

extern(C) int baz(){
  return 42;
}
./main.d
static if(__traits(compiles, {import foo.bar6;})) {
  import foo.bar6;
}

extern(C) int baz();
void main(){
  import std.stdio;
  writeln("baz:", baz);
}
./foo/bar6.d
module foo.bar6;

version(A){
import foo.bar4;
import foo.bar3;
}
else version(B){
import foo.bar3;
import foo.bar4;
}
./foo/bar2.d
module foo.bar2;
pragma(msg, __FILE__," ",__MODULE__);
./foo/bar5.d
module foo.bar5;
pragma(msg, __FILE__," ",__MODULE__);
import asdf.wrong;
./foo/bar4.d
module foo.bar4;
pragma(msg, __FILE__," ",__MODULE__);
import asdf.wrong;
./foo/bar.d
pragma(msg, __FILE__," ",__MODULE__);
./foo/bar3.d
module asdf.wrong;
pragma(msg, __FILE__," ",__MODULE__);

extern(C) int baz(){
  return 41;
}



dmd -i -version=A -run main.d
foo/bar4.d foo.bar4
asdf/wrong.d wrong
baz:42
dmd -i -version=B -run main.d
foo/bar3.d asdf.wrong
foo/bar4.d foo.bar4
baz:41

--


More information about the Digitalmars-d-bugs mailing list