www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19925] New: static opDispatch not considered in WithStatement

https://issues.dlang.org/show_bug.cgi?id=19925

          Issue ID: 19925
           Summary: static opDispatch not considered in WithStatement
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

The below code does not compile, but should:

unittest {
    with (S) {
        a(); // Compiles!
        b(); // Fails!
    }
}

struct S {
    static void a() {}
    static void opDispatch(string name)() {}
}

To make it worse, this compiles:

unittest {
    with (S.init) {
        a(); // Compiles!
        b(); // Compiles!
    }
}

, showing that static methods are considered when looking up methods of an
instance.

--
May 31 2019