On Wednesday, 15 October 2014 at 21:28:05 UTC, Nils Boßung wrote:
On Wednesday 15 October 2014 22:13, John Colvin wrote:

On Wednesday, 15 October 2014 at 19:29:27 UTC, Jack Applegame
wrote:
I don't understand why this code doesn't compile:

http://dpaste.dzfl.pl/dfd8df7f80ad

that should be immutable(ubyte)[] not immutable ubyte[] which is
equivalent to immutable(ubyte[]). You can't overwrite immutable
data, hence the error.

Then

  Foo1 foo1; foo1 = Foo1(); // compiles

shouldn't compile either.

Good point. That's an accepts-invalid IMO.

Nonetheless:
union { string a; immutable ubyte[] b; }
is broken, it is effectively casting away immutability.
union { string a; immutable(ubyte)[] b; } is the correct approach.

Reply via email to