D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11715 - templatized method shadowed by non-templatized in parameterless eponymous template
Summary: templatized method shadowed by non-templatized in parameterless eponymous tem...
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-10 02:52 UTC by monarchdodra
Modified: 2024-12-13 18:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description monarchdodra 2013-12-10 02:52:55 UTC
//----
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.
Comment 1 dlangBugzillaToGithub 2024-12-13 18:15:02 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18735

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB