@ntrel created dlang/dmd pull request #16381 "[foreach] Deprecate `ref` for array index or range parameter" fixing this issue:
- Deprecate `ref` for array index or range foreach parameter
Fix Bugzilla 24499 - foreach over a ref parameter to an rvalue should be an error
Fix Bugzilla 24232 - ref for index of foreach for arrays is not allowed by spec but accepted by compiler
https://github.com/dlang/dmd/pull/16381
Comment #3 by robert.schadek — 2024-12-13T19:34:39Z
@ntrel created dlang/dmd pull request #21674 "Deprecate `ref` for range foreach parameter" fixing this issue:
- Deprecate `ref` for range foreach parameter
Fix Bugzilla 24499 - foreach over a ref parameter to an rvalue should be an error
Allow struct variable to be `ref` to avoid destructor call on each iteration.
https://github.com/dlang/dmd/pull/21674