[Issue 11715] New: templatized method shadowed by non-templatized in parameterless eponymous template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 10 02:52:57 PST 2013


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

           Summary: templatized method shadowed by non-templatized in
                    parameterless eponymous template
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: monarchdodra at gmail.com


--- Comment #0 from monarchdodra at gmail.com 2013-12-10 02:52:55 PST ---
//----
template bar(T)
{
    void bar(){}        //Non template
    void bar(U)(U u){}  //Template
}

template foo1()
{
    void foo1()(){}     //Template
    void foo1(U)(U u){} //Template
}

template foo2()
{
    void foo2(){}       //Non template
    void foo2(U)(U u){} //Template
}

void main()
{
  bar!int();  //OK
  bar!int(1); //OK
  foo1();     //OK
  foo1(1);    //OK
  foo2();     //OK
  foo2(1);    //NOPE!
}
//----

Results in:

//----
Error: template main.foo2 does not match any function template declaration.
Candidates are:
       main.foo2()()
Error: template main.foo2()() cannot deduce template function from argument
types !()(int)
//----

I think this is not correct behavior. "bar" and "foo2" should have the same
behavior. It *seems* like the compiler does not "see" foo2().foo2(U)(U u)

The workaround (as seen in foo1), is to make the non-template function a
parameter-less template.

-- 
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