[Issue 21450] New: slice operator is not required for assignment to all elements of static array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 3 15:50:41 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21450

          Issue ID: 21450
           Summary: slice operator is not required for assignment to all
                    elements of static array
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: mrsmith33 at yandex.ru

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`
```

--


More information about the Digitalmars-d-bugs mailing list