https://issues.dlang.org/show_bug.cgi?id=14604
Issue ID: 14604
Summary: "cannot resolve forward reference" when opDispatch
results in a template
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
Probably related to issue 14603.
----
struct S
{
template opDispatch(string name)
{
void opDispatch()() {}
}
}
alias a = S.opDispatch!"go"; /* ok */
version(none) alias b = S.go; /* "cannot alias an expression" - issue 14603 */
alias Identity(alias thing) = thing;
alias c = Identity!(S.opDispatch!"go"); /* ok */
alias d = Identity!(S.go); /* 'Error: template instance opDispatch!"go" cannot
resolve forward reference' */
----
`S.go` should be equivalent to `S.opDispatch!"go"`.
Workaround:
----
struct S
{
template opDispatch(string name)
{
auto impl(Args ...)(Args args) {}
alias opDispatch = impl;
}
}
----
--