D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2654 - Forward reference error with array of struct and circular import
Summary: Forward reference error with array of struct and circular import
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on: 2386
Blocks: 340
  Show dependency treegraph
 
Reported: 2009-02-10 15:04 UTC by sa
Modified: 2015-06-09 01:21 UTC (History)
3 users (show)

See Also:


Attachments
the source code. (340 bytes, application/x-compressed-tar)
2009-02-10 15:06 UTC, sa
Details

Note You need to log in before you can comment on or make changes to this issue.
Description sa 2009-02-10 15:04:31 UTC
http://www.digitalmars.com/d/archives/digitalmars/D/circular_deps_53496.html

But according to the specs the compiler is indeed buggy.
The specs say:
| The order in which ImportDeclarations occur has no significance.

//main.d --------------8<---------------
import vec3, mat3, quat;
int main() { return 0; }

// mat3.d--------------8<---------------
module mat3;
import vec3, quat;
struct Mat3 { Vec3[3] m; }

// quat.d--------------8<---------------
module quat;
import vec3, mat3;
struct Quat {}

// vec3.d--------------8<---------------
module vec3;
import mat3, quat;
struct Vec3 { }


I get this back from the compiler....

unixbox$ dmd main.d vec3.d mat3.d quat.d 
vec3.d(6): struct vec3.Vec3 no size yet for forward reference
vec3.d(6): struct vec3.Vec3 no size yet for forward reference
vec3.d(6): struct vec3.Vec3 no size yet for forward reference
unixbox$
Comment 1 sa 2009-02-10 15:06:38 UTC
Created attachment 288 [details]
the source code.
Comment 2 Stewart Gordon 2009-02-15 19:48:50 UTC
Please remember to assign keywords to bug reports.  To everybody reading this: Please look through issues you've reported and check for missing keywords.

Moreover, what was the point of the attachment when you've already posted the code?  What's more, it's so small that by gzipping it you've actually made it bigger than the original files!

Anyway, this seems to be closely related to issue 2386....
Comment 3 Rainer Schuetze 2010-03-27 06:18:36 UTC
Although the test case looks a bit different, the patch for #2386 also fixes this issue
Comment 4 bearophile_hugs 2010-05-15 17:58:28 UTC
Fixed in dmd v1.061 and v2.046.