www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Can D not reduce template error messages?

reply IntegratedDimensions <IntegratedDimensions gmail.com> writes:
Getting N messages for N template parameter variations on a 
template.

void foo(A,B)();

A and B are selected from N different values and all are used.

If there is an error in the function then I get N^2 error 
messages, one for each combination. All the error messages say 
the same thing except A and B are different.

If the error message is several lines then that is multiplied by 
N^2.

Why can't D do a bit of error diagnostics. If the errors pertain 
to the same template and have every character the sample except 
the template values then just make a generic message:

These are the actual error messages, I did not copy and paste!!!



o.d(152): Error: function `foo!(float, float).bar(string)` is not 
callable using argument types `(int)`
o.d(152):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d(174): Error: function `foo!(float, float).bar(string)` is not 
callable using argument types `(int)`
o.d(174):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d-mixin-264(274): Error: template instance `foo!(float, float)` 
error instantiating
o.d(152): Error: function `foo!(float, int).bar(string)` is not 
callable using argument types `(int)`
o.d(152):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d(174): Error: function `foo!(float, int).bar(string)` is not 
callable using argument types `(int)`
o.d(174):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d-mixin-264(277): Error: template instance `foo!(float, int)` 
error instantiating
o.d(152): Error: function `foo!(float, int24).bar(string)` is not 
callable using argument types `(int)`
o.d(152):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d(174): Error: function `foo!(float, int24).bar(string)` is not 
callable using argument types `(int)`
o.d(174):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d-mixin-264(280): Error: template instance `foo!(float, int24)` 
error instantiating
o.d(152): Error: function `foo!(float, short).bar(string)` is not 
callable using argument types `(int)`
o.d(152):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d(174): Error: function `foo!(float, short).bar(string)` is not 
callable using argument types `(int)`
o.d(174):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d-mixin-264(283): Error: template instance `foo!(float, short)` 
error instantiating
o.d(152): Error: function `foo!(float, byte).bar(string)` is not 
callable using argument types `(int)`
o.d(152):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d(174): Error: function `foo!(float, byte).bar(string)` is not 
callable using argument types `(int)`
o.d(174):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d-mixin-264(286): Error: template instance `foo!(float, byte)` 
error instantiating
o.d(152): Error: function `foo!(float, ubyte).bar(string)` is not 
callable using argument types `(int)`
o.d(152):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d(174): Error: function `foo!(float, ubyte).bar(string)` is not 
callable using argument types `(int)`
o.d(174):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d-mixin-264(289): Error: template instance `foo!(float, ubyte)` 
error instantiating
o.d(152): Error: function `foo!(float, void).bar(string)` is not 
callable using argument types `(int)`
o.d(152):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d(174): Error: function `foo!(float, void).bar(string)` is not 
callable using argument types `(int)`


and this is when A is constant!  When I allow A to vary then it 
is squared in number!! It is ridiculous!


It all could be simplified:

.d-mixin-264(274): Error: template instance `foo!(A, B)` error 
instantiating
o.d(152): Error: function `foo!(A, B).bar(string)` is not 
callable using argument types `(int)`
o.d(152):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
o.d(174): Error: function `foo!(A, B).bar(string)` is not 
callable using argument types `(int)`
o.d(174):        cannot pass argument `bufPos` of type `double` 
to parameter `int x = 0`
where A is float, B is ubyte, void, float, etc...
Jun 02 2018
parent I love Ice Cream <IloveIcecream. icecreamsandwhich.com> writes:
On Saturday, 2 June 2018 at 09:48:26 UTC, IntegratedDimensions 
wrote:
 Getting N messages for N template parameter variations on a 
 template.

 void foo(A,B)();

 A and B are selected from N different values and all are used.

 If there is an error in the function then I get N^2 error 
 messages, one for each combination. All the error messages say 
 the same thing except A and B are different.

 If the error message is several lines then that is multiplied 
 by N^2.

 Why can't D do a bit of error diagnostics. If the errors 
 pertain to the same template and have every character the 
 sample except the template values then just make a generic 
 message:

 These are the actual error messages, I did not copy and paste!!!



 o.d(152): Error: function `foo!(float, float).bar(string)` is 
 not callable using argument types `(int)`
 o.d(152):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d(174): Error: function `foo!(float, float).bar(string)` is 
 not callable using argument types `(int)`
 o.d(174):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d-mixin-264(274): Error: template instance `foo!(float, 
 float)` error instantiating
 o.d(152): Error: function `foo!(float, int).bar(string)` is not 
 callable using argument types `(int)`
 o.d(152):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d(174): Error: function `foo!(float, int).bar(string)` is not 
 callable using argument types `(int)`
 o.d(174):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d-mixin-264(277): Error: template instance `foo!(float, int)` 
 error instantiating
 o.d(152): Error: function `foo!(float, int24).bar(string)` is 
 not callable using argument types `(int)`
 o.d(152):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d(174): Error: function `foo!(float, int24).bar(string)` is 
 not callable using argument types `(int)`
 o.d(174):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d-mixin-264(280): Error: template instance `foo!(float, 
 int24)` error instantiating
 o.d(152): Error: function `foo!(float, short).bar(string)` is 
 not callable using argument types `(int)`
 o.d(152):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d(174): Error: function `foo!(float, short).bar(string)` is 
 not callable using argument types `(int)`
 o.d(174):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d-mixin-264(283): Error: template instance `foo!(float, 
 short)` error instantiating
 o.d(152): Error: function `foo!(float, byte).bar(string)` is 
 not callable using argument types `(int)`
 o.d(152):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d(174): Error: function `foo!(float, byte).bar(string)` is 
 not callable using argument types `(int)`
 o.d(174):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d-mixin-264(286): Error: template instance `foo!(float, 
 byte)` error instantiating
 o.d(152): Error: function `foo!(float, ubyte).bar(string)` is 
 not callable using argument types `(int)`
 o.d(152):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d(174): Error: function `foo!(float, ubyte).bar(string)` is 
 not callable using argument types `(int)`
 o.d(174):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d-mixin-264(289): Error: template instance `foo!(float, 
 ubyte)` error instantiating
 o.d(152): Error: function `foo!(float, void).bar(string)` is 
 not callable using argument types `(int)`
 o.d(152):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d(174): Error: function `foo!(float, void).bar(string)` is 
 not callable using argument types `(int)`


 and this is when A is constant!  When I allow A to vary then it 
 is squared in number!! It is ridiculous!


 It all could be simplified:

 .d-mixin-264(274): Error: template instance `foo!(A, B)` error 
 instantiating
 o.d(152): Error: function `foo!(A, B).bar(string)` is not 
 callable using argument types `(int)`
 o.d(152):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 o.d(174): Error: function `foo!(A, B).bar(string)` is not 
 callable using argument types `(int)`
 o.d(174):        cannot pass argument `bufPos` of type `double` 
 to parameter `int x = 0`
 where A is float, B is ubyte, void, float, etc...
Error messages like these are why language designers generally do not go the C++/D style template route, but instead do some limited meta programming, like with generics.
Jun 02 2018