Comment #0 by garick_home_333 — 2009-12-08T01:36:10Z
string func( A... )( string name, string v )
{
return "int " ~ name ~ " = " ~ v ~ ";";
}
void main()
{
writeln( func!( int, long, float )( "val", "10" ) );
writeln( func!()( "tmp", "77" ) ); // D 2.036 successfully compile this,
// but not 2.037
// worked in 2.037
alias func!() TMP;
writeln( TMP( "tmp", "77" ) );
}
2.037 output:
funcmix.d(13): Error: template funcmix.func(A...) does not match any function template declaration
funcmix.d(13): Error: template funcmix.func(A...) cannot deduce template function from argument types !()(string,string)
funcmix.d(13): Error: template instance errors instantiating template
May be because '()' and '()' tuples are incompartible ?
see Issue 3278
Comment #1 by r.sagitario — 2009-12-29T04:12:05Z
I don't know why this worked before and could not see a change that caused the regression from version 2.036, but here is a patch that adds an empty type tuple to the deduced template parameters if it has not yet been created and does not show up in the function parameters:
Index: template.c
===================================================================
--- template.c (revision 317)
+++ template.c (working copy)
@@ -1142,6 +1142,13 @@
/* Fill in any missing arguments with their defaults.
*/
+ if(tp && fptupindex < 0 && nargsi == dedargs->dim - 1)
+ { // for variadic type parameters not in function parameters, allow empty tuple
+ Tuple *t = new Tuple();
+ dedargs->data[dedargs->dim - 1] = (void *)t;
+ nargsi++;
+ }
+
for (i = nargsi; i < dedargs->dim; i++)
{
TemplateParameter *tp = (TemplateParameter *)parameters->data[i];