D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12519 - Some implicit array casts are missing
Summary: Some implicit array casts are missing
Status: REOPENED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2014-04-04 06:37 UTC by Denis Shelomovskii
Modified: 2024-12-13 18:19 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Denis Shelomovskii 2014-04-04 06:37:07 UTC
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 Kenji Hara 2014-05-26 08:06:34 UTC
void[] is an array of untyped *mutable* data. So appending const data to mutable array will violate type system.
Comment 2 Denis Shelomovskii 2014-05-26 13:23:47 UTC
(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 dlangBugzillaToGithub 2024-12-13 18:19:23 UTC
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