Bug 12519 – Some implicit array casts are missing

Status
REOPENED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-04T06:37:07Z
Last change time
2024-12-13T18:19:23Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Denis Shelomovskii
Moved to GitHub: dmd#17650 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17650 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB