July 06, 2004
I've run into some problems using a struct template. I've reduced the code to this

struct vector()
{
    static vector opCall()
    {
        vector v;
        return v;
    }
}

alias vector!() some;

vector!() test()
{
    //return some();
    //return vector!()();
    //return some!()();
}

Now the three lines in the body of test each give a different result.

The first

>dmd test.d
c:\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;

The second

>dmd test.d
test.d(11): template vector() is used as a type
test.d(11): variable v voids have no value
test.d(12): v must be an array or pointer type, not void

The third

>dmd test.d
template instance some!() some is not a template declaration

Now, the first case is obviously fine, no problem. The third case is obviously not fine, its illegal but here the problem is that the compiler crashes. The second case I'd expect to work. The difference between the first and the second case is that the first case calls opCall on an aliased instance of vector while the second case instantiates vector and calls opCall on it inline.