While this @nogc code currently gives an error, the array could be allocated on the stack:
```
void main() @nogc {
scope int[] a = new int[10];
scope int[] a = [1, 2, 3];
}
```
It's already done for `scope` classes and array literals passed to scope parameters. It has been brought up before (https://github.com/dlang/dmd/pull/11039#issuecomment-613518685) but I don't see a bugzilla issue for it yet.
Comment #1 by dlang-bot — 2022-10-14T20:08:33Z
@dkorpel created dlang/dmd pull request #14562 "Fix issue 22306 - scope array variable should be stack allocated" fixing this issue:
- Fix issue 22306 - scope array variable should be stack allocated
https://github.com/dlang/dmd/pull/14562
Comment #2 by dlang-bot — 2022-10-18T19:32:35Z
dlang/dmd pull request #14562 "Fix issue 22306 - scope array variable should be stack allocated" was merged into master:
- 0987a2a95b902d287c4e8efa3628ce4a494b2715 by Dennis Korpel:
Fix issue 22306 - scope array variable should be stack allocated
https://github.com/dlang/dmd/pull/14562