http://d.puremagic.com/issues/show_bug.cgi?id=2933
Summary: Cannot return const/immutable with contracts (out/invariant) enabled Product: D Version: 2.029 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzi...@digitalmars.com ReportedBy: tek...@gmail.com If a method of a class returns a const or immutable value, and the class has class invariant, then the compile fails. It also fails if a method returning a const/immutable has an out contract. The following code: -------------------- class Foo { invariant() {} const(int) foo() { return 0; } immutable(int) bar() out(abc) { } body { return 0; } } -------------------- causes this compile error: -------------------- test.d(4): Error: variable test.Foo.foo.__result cannot modify const test.d(9): Error: variable test.Foo.bar.abc cannot modify mutable -------------------- --