The most confusing error message

Petar Petar
Wed Jan 24 07:46:52 UTC 2018


On Wednesday, 24 January 2018 at 07:32:17 UTC, Petar Kirov 
[ZombineDev] wrote:
> On Wednesday, 24 January 2018 at 07:21:09 UTC, Shachar Shemesh 
> wrote:
>> 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.
>
> Because IFTI is short for implicit function

(Heh, the Send button is too easy to press on the mobile version 
of the forum.)

Because IFTI is short for implicit function template 
instantiation. We don't have this feature for any other type of 
template, though IIRC it has been discussed before. Though one 
may argue that we have this feature for mixin templates:

https://dlang.org/spec/template-mixin.html
If the TemplateDeclaration has no parameters, the mixin form that 
has no !(TemplateArgumentList) can be used.


More information about the Digitalmars-d mailing list