[Issue 14604] New: "cannot resolve forward reference" when opDispatch results in a template

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon May 18 13:04:53 PDT 2015


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: nobody at puremagic.com
          Reporter: ag0aep6g at gmail.com

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

--


More information about the Digitalmars-d-bugs mailing list