Thread overview
[Issue 1667] New: Forward reference to struct initializer in template
Nov 13, 2007
d-bugmail
Nov 13, 2008
d-bugmail
Nov 14, 2008
d-bugmail
Nov 14, 2008
d-bugmail
November 13, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1667

           Summary: Forward reference to struct initializer in template
           Product: D
           Version: 1.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: jarrett.billingsley@gmail.com


struct S
{ // line 34 is this brace.
        int x;
}

template Foo(T)
{
        alias Tuple!(T.init) Foo;
}

alias Tuple!(Foo!(S)) t;


dtest.d(34): declaration _D5dtest1S6__initZ forward declaration


RRRRRRRRRGHHHHHHHH
GHASDIGHGHHGGH
GGGGGGGGGGGGGGG


-- 

November 13, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1667





------- Comment #1 from jarrett.billingsley@gmail.com  2008-11-12 20:01 -------
*** Bug 2449 has been marked as a duplicate of this bug. ***


-- 

November 14, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1667


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com




------- Comment #2 from smjg@iname.com  2008-11-13 19:10 -------
Is this really a forward reference issue?  There is no forward reference in the code.  Moreover, under DMD 1.036 it generates a quite different set of errors:

bz1667.d(8): template instance identifier 'Tuple' is not defined
bz1667.d(11): template instance bz1667.Foo!(S) error instantiating
bz1667.d(11): template instance identifier 'Tuple' is not defined

It's true that the errors change if the pieces are swapped around - if the alias t is moved to the top

bz1667.d(1): template instance forward reference to template declaration Foo(T)
bz1667.d(1): template instance identifier 'Tuple' is not defined

but that's not the problem being reported here.


-- 

November 14, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1667





------- Comment #3 from jarrett.billingsley@gmail.com  2008-11-13 20:03 -------
(In reply to comment #2)
> Is this really a forward reference issue?  There is no forward reference in the code.  Moreover, under DMD 1.036 it generates a quite different set of errors:
> 
> bz1667.d(8): template instance identifier 'Tuple' is not defined
> bz1667.d(11): template instance bz1667.Foo!(S) error instantiating
> bz1667.d(11): template instance identifier 'Tuple' is not defined
> 
> It's true that the errors change if the pieces are swapped around - if the alias t is moved to the top
> 
> bz1667.d(1): template instance forward reference to template declaration Foo(T)
> bz1667.d(1): template instance identifier 'Tuple' is not defined
> 
> but that's not the problem being reported here.

My bad, I didn't include the definition of Tuple.

struct S
{
        int x;
}

template Tuple(T...)
{
        alias T Tuple;
}

template Foo(T)
{
        alias Tuple!(T.init) Foo;
}

alias Tuple!(Foo!(S)) t;

That gives the reported error, even in 1.036.


--