December 16, 2006
[I'll file this for real once Bugzill is back]

This may not be a bug for some technical reason unbeknownst to me that the spec mentions, but I found it unexpected.  You can't use 'this' as an alias paramter to a mixin in a class member function.  The workaround is pretty easy, you just assign it to a local dummy variable, and use that instead.


import std.stdio : writefln;

template printer_mix(alias T)
{
    void print() {
        writefln(T);
    }
}

class Foo
{
    void dump() {
        // Error: mixin printer_mix!(this) does not match any template declaration
        mixin printer_mix!(this);

        // this version ok:
        //Foo x = this;
        //mixin printer_mix!(x);

        print();
    }
    char[] toString() { return "I'm Batman"; }
}

void main()
{
    Foo f = new Foo();
    f.dump();
}