[Issue 14286] New: `alias this` not considered sub-typing in is() expression

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Mar 15 10:02:53 PDT 2015


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: nobody at puremagic.com
          Reporter: schuetzm at gmx.net

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.

--


More information about the Digitalmars-d-bugs mailing list