Bug 21450 – slice operator is not required for assignment to all elements of static array

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-12-03T15:50:41Z
Last change time
2024-12-13T19:13:13Z
Assigned to
No Owner
Creator
MrSmith33
Moved to GitHub: dmd#18005 →

Comments

Comment #0 by mrsmith33 — 2020-12-03T15:50:41Z
When assigning to slice, slice operator is required. However when assigning to static array compiler silently allows it, which can lead to bugs. This behavior should be consistent between slices and static arrays. ``` ubyte[] slice; slice[] = 2; // ok slice = 2; // error as expected ubyte[2] array; array[] = 2; // ok array = 2; // doesn't error, works as `array[] = 2` ```
Comment #1 by nick — 2022-09-03T08:05:36Z
I assume static array initialization should still be allowed from a single element? Otherwise the fix is not so trivial for an immutable static array.
Comment #2 by robert.schadek — 2024-12-13T19:13:13Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18005 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB