Bug 2666 – forward reference hell!

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2009-02-14T19:14:00Z
Last change time
2014-02-15T13:13:32Z
Keywords
rejects-valid
Assigned to
nobody
Creator
someanon
Blocks
340

Attachments

IDFilenameSummaryContent-TypeSize
290forwardref.tgzsource fileapplication/x-compressed-tar364

Comments

Comment #0 by someanon — 2009-02-14T19:14:03Z
$ cat vector.d #----------------------------------------------------- module vector; class Vector(E) { E[] data; } $ cat student.d #----------------------------------------------------- module student; import vector; import teacher; // define Student class Student { void ask(Teacher teacher) { } } // define Students alias Vector!(Student) Students; $ cat teacher.d #----------------------------------------------------- module teacher; import student; class Teacher { Students students; } =============================================== $ dmd -c student.d teacher.d(6): Error: forward reference to 'Vector!(Student)' teacher.d(6): Error: Students is used as a type teacher.d(6): variable teacher.Teacher.students voids have no value =============================================== sure I know if I do: $ dmd -c vector.d teacher.d student.d all the three files can be compiled without error. But my question is: why can't file be individually compiled? I think I have the most natural/logical organization of files; if you move the 'Students' alias around, it could get compiled, but what's wrong with my current organization?
Comment #1 by someanon — 2009-02-14T19:16:33Z
Created attachment 290 source file
Comment #2 by luk.wrzosek — 2012-02-15T04:12:19Z
Fixed in: https://github.com/D-Programming-Language/dmd/commit/a7e086246fa84279a5e16ed39c9b3f015057544a commit a7e086246fa84279a5e16ed39c9b3f015057544a Author: Walter Bright <[email protected]> Date: Mon Aug 9 04:30:47 2010 +0000 bugzilla 4503 forward reference to aliased template instance