On 15.09.2014 10:24, Andrei Alexandrescu wrote:

Hmm, seems fine when I try it. It feels like a bug in the type system,
though: when you make a copy of const(RCXString) to some RCXString, it
removes the const from the referenced RCBuffer struct mbuf!?

The conversion relies on pure constructors. As I noted in the opening
post, I also think there's something too lax in there. If you have a
reduced example that shows a type system breakage without cast, please
submit.

Here's an example:

module module2;

struct S
{
        union
        {
                immutable(char)* iptr;
                char* ptr;
        }
}

void main()
{
        auto s = immutable(S)("hi".ptr);
        S t = s;
        t.ptr[0] = 'A';
}

It seems the union is hiding the fact that there are mutable references. Only the first field is verified when copying the struct. Is this by design? (typeof(s.ptr) is "immutable(char*)")

Reply via email to