Bug 12447 – variadic template functions hijack all eponymous enum and alias template overloads
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-23T16:27:00Z
Last change time
2015-02-18T03:38:47Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
2krnk
Comments
Comment #0 by 2krnk — 2014-03-23T16:27:05Z
see following example code.
the two 'test' templates work fine by themselves. if they are in the same module, however, the eponymous enum template does not work anymore. instead the compiler tries to instantiate the variadic template - and fails. same issue with eponymous alias templates.
this should not happen as
o the two templates have very different signatures, i.e. completely incompatible argument lists ( zero vs >0 arguments)
o the string parameter is more specialized than the take-all tuple
example code:
=============
// cannot be used with function arguments:
enum test(string str ) = "templated enum 'test' used with "~str;
// cannot be called with less than 1 function arguments:
string test (T ...)( T strs )
if( strs.length )
{
return "templated function 'test' called with "~strs[0];
}
// enum epo = test!("foo"); // use eponymous enum
// if commented in:
// Error: tuple T is used as a type
// in line 5 = string test (T ...)( T strs )
enum vari = test("bar"); // use templated/variadic function
void main(string[] args)
{
import std.stdio;
// writeln( epo );
writeln( vari );
}