Bug 4503 – forward reference to aliased template instance

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-07-24T11:41:00Z
Last change time
2015-06-09T05:12:02Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
hoganmeier
Blocks
340, 3679, 4267

Comments

Comment #0 by hoganmeier — 2010-07-24T11:41:59Z
This is an extremely simplified version of my real code (cl4d) where these 3 parts are distributed among several files (and thus heavily depend on the build order). ---- class Collection(T) { } ICollection c; alias Collection!int ICollection; fwdref2.d(4): Error: forward reference to 'Collection!(int)' fwdref2.d(4): Error: ICollection is used as a type ---- Putting ICollection c; at the end makes it compile.
Comment #1 by hoganmeier — 2010-07-24T12:05:53Z
error occurs at mtype.c:5542 if (t->ty == Tinstance && t != this && !t->deco) { error(loc, "forward reference to '%s'", t->toChars()); return; } This is also true if ICollection is referenced like this: void foo(ICollection c) { }
Comment #2 by hoganmeier — 2010-07-25T14:04:50Z
A test with if (t->ty == Tinstance && t != this && !t->deco) { //error(loc, "forward reference to '%s'", t->toChars()); //return; t = t->semantic(loc, sc); } solved this issue. Don't know if that causes other problems though.
Comment #3 by r.sagitario — 2010-07-26T00:32:51Z
This patch seems a bit more generic and solved a similar issue for me. It also works for your code: Index: declaration.c =================================================================== --- declaration.c (revision 576) +++ declaration.c (working copy) @@ -594,6 +594,9 @@ { error("recursive alias declaration"); aliassym = new TypedefDeclaration(loc, ident, Type::terror, NULL); } + else if (!aliassym && scope) + semantic(scope); + Dsymbol *s = aliassym ? aliassym->toAlias() : this; return s; }
Comment #4 by hoganmeier — 2010-07-26T06:05:39Z
Comment #5 by hoganmeier — 2010-07-27T10:18:02Z
Comment #6 by bugzilla — 2010-08-08T21:32:00Z
Comment #7 by clugdbug — 2010-08-29T12:39:56Z
Fixed DMD1.063 and 2.048.