I'm experimenting with several designs and I think I might have hit a bug, but I wanted to confirm it. Is this a bug?

    class A
    {
        void opDispatch(string name, T...)(T msg) {}
    }

    class B : A
    {
        C obj;
        alias obj this;

        @disable void opDispatch(string name, T...)(T msg);
    }

    class C
    {
        void foo() {}
    }

    void main()
    {
        auto b = new B;
        b.foo();
    }

 Output:

    Error: no property 'foo' for type 'B'

Disabling the opDispatch that B inherits from A also seems to disable B's alias this to C. The @disable works well in isolation -- as does the alias this, of course.

My current workaround:

    class B : A
    {
        C obj;

        void opDispatch(string name, T...)(T msg)
        {
            mixin("obj." ~ name ~ "();");
        }
    }

(which now makes me wonder what actually are the differences between those two...)

BTW, I was asking in the IRC channel (I should have discovered that lovely place earlier!) about the following:

1:    T[string] foo;
2:    foo[""] = new T;
3:    foo[null] = new T;

Lines 2 and 3 seem to do the same, apparently. People seemed to agree that 3 should not be relied upon (should it?), but if I recall/understand it was not totally clear to people why 2 and 3 *do* do the same thing, so feel free to clarify.

Reply via email to