This is correctly rejected:
```
ref int f(ref scope int[] arr) {
foreach(ref e; arr)
return e; // Error: scope variable `__r2` may not be returned
assert(0);
}
```
This isn't: (`scope` => `return scope`)
```
ref int f(ref return scope int[] arr) {
foreach(ref e; arr)
return e;
assert(0);
}
```
The `return` applies to the `ref arr`, not the `int[]`. This is another case of the compiler conflating `return ref` and `return scope` like in issue 21868.
Comment #1 by dkorpel — 2024-07-19T13:17:19Z
With the new rules, `return scope` now applies to the `int[]` instead of the `ref arr`.