class Base { int _val; } class Foo : Base { Base base() const { return this; } } void main() { const(Foo) foo = new const(Foo); static assert(!__traits(compiles, foo._val = 1)); static assert(!__traits(compiles, foo.base()._val = 1)); foo.base()._val = 1; assert(foo._val == 0); } Also broken for immutable and shared. -------- This is probably implemented as 'return cast(Base)this;' and needs to include the right modifiers.
Is this just 3731?
*** This issue has been marked as a duplicate of issue 3731 ***