[Issue 297] New: Shadowing declarations allowed in foreach type lists
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 20 05:25:28 PDT 2006
http://d.puremagic.com/issues/show_bug.cgi?id=297
Summary: Shadowing declarations allowed in foreach type lists
Product: D
Version: 0.164
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: accepts-invalid
Severity: minor
Priority: P3
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: deewiant at gmail.com
void main() {
int i;
int[] a;
foreach (i; a) {}
foreach (i, n; a) {}
// this fails, the above don't
for (int i;;) {}
}
I don't think this should be allowed, but I'm not entirely certain. Foreaches
are, in a way, functions in their own right, passed to the container's opApply,
and shadowing in nested functions or function/delegate literals _is_ allowed.
I just still tend to think of foreach loops as only the better way of writing
for loops, and since you can't do it with for loops you shouldn't be able to do
it with it foreach loops. <g>
--
More information about the Digitalmars-d-bugs
mailing list