D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3834 - forward reference in templated class
Summary: forward reference in templated class
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks: 340
  Show dependency treegraph
 
Reported: 2010-02-18 13:00 UTC by bearophile_hugs
Modified: 2013-11-22 02:02 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-02-18 13:00:53 UTC
class Foo(T) {
    Node!T head;
    class Node(T) {}
}
void main() {
    auto f = new Foo!int;
}


dmd prints:

test.d(2): Error: template instance Node!(int) forward references template declaration Node(T)

test.d(2): Error: Node!(int) is used as a type
test.d(2): Error: variable test.Foo!(int).Foo.head voids have no value
test.d(6): Error: template instance test.Foo!(int) error instantiating
Comment 1 bearophile_hugs 2010-04-10 16:14:55 UTC
A simpler case example:

struct Foo(T) {
    Node!T head;
    struct Node(T) {}
}
void main() {
    Foo!int f;
}


dmd 2.043 prints many errors:

test.d(2): Error: template instance Node!(int) forward references template declaration Node(T)

test.d(2): Error: Node!(int) is used as a type
test.d(2): Error: variable test.Foo!(int).Foo.head voids have no value
test.d(6): Error: template instance test.Foo!(int) error instantiating
Comment 2 Kenji Hara 2013-11-22 02:02:45 UTC
The first case in comment#0 was fixed in 2.064, by fixing issue 10583.

The second case in comment #1 was fixed in 2.059.