Ooh - Got me an OPTLINK error!

Steven Schveighoffer schveiguy at yahoo.com
Sat Nov 10 06:16:46 PST 2007


"Janice Caron"  wrote
> The following won't compile with the latest D2.007. The error is:
>
> OPTLINK (R) for Win32  Release 7.50B1
> Copyright (C) Digital Mars 1989 - 2001  All Rigths Reserved
>
> demo.obj(demo)  Offset 0035EH Record Type 009D
> Error 16: Index Range
>
> It seems to be the alias on the last line that kills it.
>
> ///////////////////////////
>
> void main() {}
>
> template A()
> {
>    const uint N = 16;
>
>    class A
>    {
>        ubyte[] f()
>        {
>            return new ubyte[N];
>        }
>    }
> }
>
> alias A!() B;

This doesn't seem valid.  I thought you could only use implicit template 
properties if there was only one member of the template?  Does changing the 
line to A!().A B; work?

>From spec:
If a template has exactly one member in it, and the name of that member is 
the same as the template name, that member is assumed to be referred to in a 
template instantiation:

template Foo(T)
{
    T Foo;	// declare variable Foo of type T
}

void test()
{
    Foo!(int) = 6;	// instead of Foo!(int).Foo
}
-Steve 





More information about the Digitalmars-d mailing list