On Sat, 01 Jan 2011 20:56:20 -0000, Jonathan M Davis <jmdavisp...@gmx.com> wrote:

On Saturday 01 January 2011 11:17:36 Alex Khmara wrote:
Please help: is it compiler bug or I'm doing something wrong?

This code:

module properties;

struct PropertyList {
<-->invariant() {
<--><-->assert(1);
<-->}

<-->this(this) {
<--><-->_props = [];
<-->}

<-->string[] _props;
}


gives compiler error:

Error: __result = this is not mutable
Error: __result = this is not an lvalue

Without invariant all works good.

It's hard to read what you're doing when have those extra arrows in there.

In any case, create a bug report for it. There are several bugs at present with invariants not working because of things like a public member function being pure (that one you can fix by marking the invariant as pure) or returning a ref.
My guess would be that the problem relates to bug
http://d.puremagic.com/issues/show_bug.cgi?id=4867 which makes it so that
postblit constructors cannot currently copy const or immutable objects, but I don't know, since problems with __result have to do with the return value of a function (which would be the result of postblit rather than what's passed in). So, just create a bug report on it and it can be sorted out with the other invariant, postblit, and const problems. For the moment, it probably means that you can't have both an invariant and a postblit constructor, which sucks, but
until the bug is fixed, I don't see what else you can do.

- Jonathan M Davis

Thank you. Sorry for arrows - Midnight Commander marks tabs with them, and I forgot to
disable this.

Filed bug: http://d.puremagic.com/issues/show_bug.cgi?id=5397

Reply via email to