Could someone please explain why the following doesn't compile with "const" qualifier while it does work without it?

/* test.d */

module test;

mixin template Foo() {
    mixin("@property int bar() const { return foo; }");
}

int foo = 1;

mixin Foo;

unittest {
    assert(foo == bar);
}

rdmd -main -unittest test.d
test.d-mixin-4(4): Error: function test.Foo!().bar without 'this' cannot be const
test.d(9): Error: mixin test.Foo!() error instantiating

Reply via email to