[Issue 12447] New: variadic template functions hijack all eponymous enum and alias template overloads

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 23 16:27:08 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12447

           Summary: variadic template functions hijack all eponymous enum
                    and alias template overloads
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: 2krnk at gmx.net


--- Comment #0 from det <2krnk at gmx.net> 2014-03-23 16:27:05 PDT ---
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 );
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list