www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - templates

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

The second
dmd test.d

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

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.
Jul 06 2004