Bug 3818 – Generic error message for wrong foreach
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-02-18T10:18:34Z
Last change time
2022-01-20T00:56:04Z
Keywords
bootcamp, diagnostic, pull
Assigned to
No Owner
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2010-02-18T10:18:34Z
void main() {
auto a = [10];
foreach(i, x, a) {}
}
This common programming mistake produces this error message:
test.d(3): no identifier for declarator a
But it's better if dmd here prints a better error message, specific for foreach(), to help programmers.
(I think this typing mistake is sometimes caused because inside a foreach a comma sometimes looks quite similar to a semicolon.)
Comment #1 by bearophile_hugs — 2010-07-30T15:00:41Z
See bug 4537 too.
Comment #2 by andrej.mitrovich — 2013-01-20T13:27:13Z
*** Issue 4537 has been marked as a duplicate of this issue. ***
Comment #3 by dlang-bot — 2022-01-19T21:11:08Z
@WalterBright created dlang/dmd pull request #13551 "fix Issue 3818 - Generic error message for wrong foreach" fixing this issue:
- fix Issue 3818 - Generic error message for wrong foreach
https://github.com/dlang/dmd/pull/13551
Comment #4 by dlang-bot — 2022-01-20T00:56:04Z
dlang/dmd pull request #13551 "fix Issue 3818 - Generic error message for wrong foreach" was merged into master:
- 5be20717184db43f1fe7341873019f1e8d4c72fb by Walter Bright:
fix Issue 3818 - Generic error message for wrong foreach
https://github.com/dlang/dmd/pull/13551