www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4503] New: forward reference to aliased template instance

reply d-bugmail puremagic.com writes:
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



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: -------
Jul 24 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4503




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: -------
Jul 24 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4503


Trass3r <mrmocool gmx.de> changed:

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



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: -------
Jul 25 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jul 26 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4503




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: -------
Jul 26 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4503


Trass3r <mrmocool gmx.de> changed:

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



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: -------
Jul 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4503


Walter Bright <bugzilla digitalmars.com> changed:

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



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: -------
Aug 08 2010
prev sibling parent d-bugmail puremagic.com writes:
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



Fixed DMD1.063 and 2.048.

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