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

          Issue ID: 14286
           Summary: `alias this` not considered sub-typing in is()
                    expression
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: [email protected]
          Reporter: [email protected]

This works:

    class V(string s) {
    }

    class S(int U) : V!"xyz" {
    }

    void main() {
        S!10 a;
        static if(is(typeof(a) : V!Args, Args...))
            pragma(msg, Args);
        else
            pragma(msg, "nope");
    }

This doesn't:

    struct V(string s) {
    }

    struct S(int U) {
        V!"xyz" x;
        alias x this;
    }

    void main() {
        S!10 a;
        static if(is(typeof(a) : V!Args, Args...)) 
            pragma(msg, Args);
        else
            pragma(msg, "nope");
    }

As `alias this` should work wherever sub-typing works, I guess this is a bug.

--

Reply via email to