D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2666 - forward reference hell!
Summary: forward reference hell!
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks: 340
  Show dependency treegraph
 
Reported: 2009-02-14 19:14 UTC by sa
Modified: 2014-02-15 13:13 UTC (History)
3 users (show)

See Also:


Attachments
source file (364 bytes, application/x-compressed-tar)
2009-02-14 19:16 UTC, sa
Details

Note You need to log in before you can comment on or make changes to this issue.
Description sa 2009-02-14 19:14:03 UTC
$ 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 sa 2009-02-14 19:16:33 UTC
Created attachment 290 [details]
source file
Comment 2 Lukasz Wrzosek 2012-02-15 04:12:19 UTC
Fixed in:
https://github.com/D-Programming-Language/dmd/commit/a7e086246fa84279a5e16ed39c9b3f015057544a



commit a7e086246fa84279a5e16ed39c9b3f015057544a
Author: Walter Bright <walter@digitalmars.com>
Date:   Mon Aug 9 04:30:47 2010 +0000

    bugzilla 4503 forward reference to aliased template instance