D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5903 - Overloading template functions with typeof() parameter type fails.
Summary: Overloading template functions with typeof() parameter type fails.
Status: RESOLVED DUPLICATE of issue 4413
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-04-28 12:18 UTC by kennytm
Modified: 2012-04-23 17:04 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kennytm 2011-04-28 12:18:38 UTC
Test case:

---------------------------------------------------
static assert(is(int == typeof(0)));

void p()(int a) { pragma(msg, "OK(p)"); }
void p()() { pragma(msg, "Err(p)"); }

void r(R=typeof(0))(R a) { pragma(msg, "OK(r)"); }
void r()() { pragma(msg, "Err(r)"); }

void s()(typeof(0) a) { pragma(msg, "OK(s)"); }

void t(typeof(0) a) { }
void t() { }

void q()(typeof(0) a) { pragma(msg, "OK(q)"); }
void q()() { pragma(msg, "Err(q)"); }

void main() {
    p!()(5);    // without typeof() is ok
    r!()(5);    // put that typeof() elsewhere is ok
    s!()(5);    // no overloading is ok
    t(5);       // no template is ok
    q!()(5);    // Error
}
---------------------------------------------------
OK(p)
OK(r)
OK(s)
x.d(22): Error: template x.q() does not match any function template declaration
x.d(22): Error: template x.q() cannot deduce template function from argument types !()(int)
x.d(22): Error: template instance errors instantiating template
---------------------------------------------------

Probably the same as issue 4413, except it affects more than typeof(this).
Comment 1 SomeDude 2012-04-23 12:54:21 UTC
Compiles with 2.059 Win32.

PS E:\DigitalMars\dmd2\samples> dmd bug.d
OK(p)
OK(r)
OK(s)
OK(q)
PS E:\DigitalMars\dmd2\samples>
Comment 2 Kenji Hara 2012-04-23 17:04:51 UTC

*** This issue has been marked as a duplicate of issue 4413 ***