Bug 22138 – foreach cannot declare the loop variables as scope

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-07-23T21:01:43Z
Last change time
2021-07-26T03:03:31Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Walter Bright

Comments

Comment #0 by bugzilla — 2021-07-23T21:01:43Z
The following fails to compile: void test() { int[] a; foreach (scope e; a) { } } but ref, enum, alias, const, immutable, shared, and inout work.
Comment #1 by dlang-bot — 2021-07-23T22:26:44Z
@WalterBright created dlang/dmd pull request #12912 "fix Issue 22138 - foreach cannot declare the loop variables as scope" fixing this issue: - fix Issue 22138 - foreach cannot declare the loop variables as scope https://github.com/dlang/dmd/pull/12912
Comment #2 by dlang-bot — 2021-07-26T03:03:31Z
dlang/dmd pull request #12912 "fix Issue 22138 - foreach cannot declare the loop variables as scope" was merged into master: - fb9a0aa82e5217d4689d08a3330ae22a096114e8 by Walter Bright: fix Issue 22138 - foreach cannot declare the loop variables as scope https://github.com/dlang/dmd/pull/12912