The most confusing error message

Shachar Shemesh shachar at weka.io
Wed Jan 24 07:21:09 UTC 2018


test.d(6): Error: struct test.A(int var = 3) is used as a type

Of course it is. That's how structs are used.

Program causing this:
struct A(int var = 3) {
     int a;
}

void main() {
     A a;
}

To resolve, you need to change A into A!(). For some reason I have not 
been able to fathom, default template parameters on structs don't work 
like they do on functions.


More information about the Digitalmars-d mailing list