Comment #0 by verylonglogin.reg — 2014-04-04T06:37:07Z
This code should compile:
---
void main()
{
void[] va;
byte[] ba;
byte[1] sba;
const byte[] cba;
const byte[1] csba;
va ~= ba; // ok
va ~= sba; // ok
va ~= cba; // Error: cannot append type const(byte[]) to type void[]
va ~= csba; // Error: cannot append type const(byte[1]) to type void[]
}
---
Comment #1 by k.hara.pg — 2014-05-26T08:06:34Z
void[] is an array of untyped *mutable* data. So appending const data to mutable array will violate type system.
Comment #2 by verylonglogin.reg — 2014-05-26T13:23:47Z
(In reply to Kenji Hara from comment #1)
> void[] is an array of untyped *mutable* data. So appending const data to
> mutable array will violate type system.
But `byte` has no indirections so `const byte` is convertible to `byte` and this logically equivalent code is valid:
---
void main()
{
void[] va;
const byte[] cba;
const byte[1] csba;
byte[] tmp;
tmp ~= cba;
tmp ~= csba;
va = tmp;
}
---
Comment #3 by robert.schadek — 2024-12-13T18:19:23Z