I recently started using that new feature "package.d". While writing codes today, I started seeing some errors. For illustration, I wrote a piece of code. I will list 3 different files here. File-Folder structure is below:

./app.d
./pipes/package.d
./pipes/namedpipe.d


File: app.d
-------------------
import pipes;

void main(){}


File: ./pipes/package.d
-------------------
module pipes;

public import pipes.namedpipe;

public enum PIPE_BUF = 4096;


File: ./pipes/namedpipe.d
-------------------
module pipes.namedpipe;

public int getPipeBufferSize(){ return pipes.PIPE_BUF; }

public void foo( size_t a = pipes.PIPE_BUF ){}


Situation is that if I do not define that "foo" function in namedpipe.d file, everything is fine. No error at all, and "getPipeBufferSize" function returns the value that comes from "pipes.PIPE_BUF". When the function "foo" is defined that takes pipes.PIPE_BUF as its initial value of parameter, following error is seen:

pipes/namedpipe.d(7): Error: cannot resolve type for PIPE_BUF

---

While writing this post, I discovered that in "pipes/package.d" file, if I define "PIPE_BUF" BEFORE the import command as below:

module pipes;

public enum PIPE_BUF = 4096;

public import pipes.namedpipe;


then there is no error at all. Is this intentional? As far as I remember, D compiler was finding definitions no matter later or before defined.

Reply via email to