[Issue 11330] Directory named as imported module should not stop module search

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 23 10:00:38 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11330



--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> 2013-10-23 10:00:36 PDT ---
Hmm. OK, confirmed your point. But I don't think that the current
behavior/design is broken. 

Up to 2.063, d and di files has been considered as a source of the compiler.
>From 2.064, directory name will be added to the compiler's input by
implementing DIP37. That's intended change.

And, I'd like to explain why the current behavior is necessary.
If you have the following project:

./
 +--src1/
 |  +--a/
 |     +--...
 +--src2/
 |  +--a.d
 +--src3/
    +--b.d  (contains "import a;")

And you use the command line "dmd -Isrc1 -Isrc2 -Isrc3 ..." to compile project.
If compiler ignores the directory "src1/a/" when resolving "import a;", it
would be used to import "src2/a.d".
Then, what happen if you add a new file src1/a/package.d by using DIP37
feature? It will break existing the code "import a;'in "src3/b.d". The occurred
problem is contrary to the principle in DIP37- adding package.d should be
breakage-free transparent change.

To avoid the problem, if the directory "a" does not contain package.d file,
compiler should raise an error on "import a;" from the beginning.

========

On the other hand, in the OP case, I think the root issue is that dmd
implicitly adds the current directory in import paths by default. When you use
dmd as just a part of build-tool, the implicit addition could cause problems
like your case.

An idea based on my thought is: add a new compiler switch "--I." which removes
current directory from the import path list.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list