Add scope array literals to spec
Requested here: https://github.com/dlang/dmd/pull/14562#issuecomment-1282905802
Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:
- My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
- My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
- I have provided a detailed rationale explaining my changes
- New or modified functions have Ddoc comments (with
Params:andReturns:)
Please see CONTRIBUTING.md for more information.
If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.
Bugzilla references
Your PR doesn't reference any Bugzilla issue.
If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
What about when the element type is not plain old data as mentioned in the changelog: https://github.com/dlang/dmd/pull/14562/files#diff-a773cf7a39af2594f4e2e4f8aa41047d2b2f10a8558a5f0cb1c7d4c86f6d0304R23
What about when the element type is not plain old data as mentioned in the changelog: https://github.com/dlang/dmd/pull/14562/files#diff-a773cf7a39af2594f4e2e4f8aa41047d2b2f10a8558a5f0cb1c7d4c86f6d0304R23
As-if rule may be useful
It is worth noting that this change (and others like it) may silently introduce memory corruption into any @trusted code that relied on the old behavior. For example, the following code is memory safe when compiled with DMD 2.100, but will be unsound when compiled with DMD 2.101:
@trusted int[] example()
{
scope arr = [1, 2, 3];
return arr;
}