I would imagine that you have more code (so for example, vec3 really does
depend on mat3 and quat). As far as I'm concerned, this is a bug in the
compiler that Walter has never been particularly intent on fixing. I've
always ended up just clumping any circularly-dependent modules into one
file, even if it doesn't really make sense to. Makes the compiler shut up.

Yeah, this is the code stripped down to its most minimal form that still causes
the compiler to barf.
If someone can tell me for sure that this is a compiler bug, I'll have a go at
fixing it myself.
Cheers
S
Jarrett Billingsley Wrote:

I would imagine that you have more code (so for example, vec3 really does
depend on mat3 and quat). As far as I'm concerned, this is a bug in the
compiler that Walter has never been particularly intent on fixing. I've
always ended up just clumping any circularly-dependent modules into one
file, even if it doesn't really make sense to. Makes the compiler shut up.

The correct ways in the given case are at least
- to compile by `dmd mat3 main'
- to change the import declaration in "main.d" so that
`mat3' is imported before `vec3'
- to change the position of the import declaration in "vec3.d" so
that it follows lexically the definition of type `Vec3'
All these ways enable the compiler to destroy the cyclic importing
in the given case.
But according to the specs the compiler is indeed buggy.
The specs say:
| The order in which ImportDeclarations occur has no significance.
With your slightly modified example the compiler continues to emit
errors if the import declaration `import vec3, mat3, quat;' is
changed to
import vec3;
import mat3;
import quat;
But the error vanishes on changing the order to
import mat3;
import vec3;
import quat;
This is the proof that the order indeed has a significance for the
compiler.
-manfred