Thread overview
[Issue 4503] New: forward reference to aliased template instance
Jul 24, 2010
Trass3r
Jul 24, 2010
Trass3r
Jul 25, 2010
Trass3r
Jul 26, 2010
Rainer Schuetze
Jul 26, 2010
Trass3r
Jul 27, 2010
Trass3r
Aug 09, 2010
Walter Bright
Aug 29, 2010
Don
July 24, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4503

           Summary: forward reference to aliased template instance
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: mrmocool@gmx.de


--- Comment #0 from Trass3r <mrmocool@gmx.de> 2010-07-24 11:41:59 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 24, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4503



--- Comment #1 from Trass3r <mrmocool@gmx.de> 2010-07-24 12:05:53 PDT ---
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)
{
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 25, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4503


Trass3r <mrmocool@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from Trass3r <mrmocool@gmx.de> 2010-07-25 14:04:50 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4503


Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario@gmx.de


--- Comment #3 from Rainer Schuetze <r.sagitario@gmx.de> 2010-07-26 00:32:51 PDT ---
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;
 }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4503



--- Comment #4 from Trass3r <mrmocool@gmx.de> 2010-07-26 06:05:39 PDT ---
Great!
Also seems to solve http://d.puremagic.com/issues/show_bug.cgi?id=4267

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4503


Trass3r <mrmocool@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |4267


--- Comment #5 from Trass3r <mrmocool@gmx.de> 2010-07-27 10:18:02 PDT ---
And this one: http://d.puremagic.com/issues/show_bug.cgi?id=3679

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 09, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4503


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2010-08-08 21:32:00 PDT ---
http://www.dsource.org/projects/dmd/changeset/607

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4503


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |FIXED


--- Comment #7 from Don <clugdbug@yahoo.com.au> 2010-08-29 12:39:56 PDT ---
Fixed DMD1.063 and 2.048.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------