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 --------------------
Created attachment 356 [details] This patch should fix the problem.
*** Issue 3048 has been marked as a duplicate of this issue. ***
*** Issue 2799 has been marked as a duplicate of this issue. ***
On svn 484(DMD 2.046), this patch doesn't fix the test case. It's possible that the patch will work once bug 3667 is fixed, but I haven't tested that.
Fixed when bug 3667 was fixed, in svn 490 (DMD 2.047).