Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templatized method shadowed by non-templatized in parameterless eponymous template #18735

Open
dlangBugzillaToGithub opened this issue Dec 10, 2013 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

monarchdodra reported this on 2013-12-10T02:52:55Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=11715

Description

//----
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant