Bug 3600 – template instantiation with empty tuple

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-12-08T01:36:00Z
Last change time
2015-06-09T01:27:05Z
Keywords
patch
Assigned to
nobody
Creator
garick_home_333
See also
http://d.puremagic.com/issues/show_bug.cgi?id=3278

Comments

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];
Comment #2 by bugzilla — 2010-01-18T01:14:55Z
Changeset 340
Comment #3 by bugzilla — 2010-01-30T22:45:55Z
fixed dmd 2.040