Thread overview | |||||
---|---|---|---|---|---|
|
August 20, 2006 [Issue 297] New: Shadowing declarations allowed in foreach type lists | ||||
---|---|---|---|---|
| ||||
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@digitalmars.com ReportedBy: deewiant@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> -- |
September 19, 2006 [Issue 297] Shadowing declarations allowed in foreach type lists | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=297 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- |
October 02, 2006 Re: [Issue 297] New: Shadowing declarations allowed in foreach type lists | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail Attachments: | d-bugmail@puremagic.com schrieb am 2006-08-20: > http://d.puremagic.com/issues/show_bug.cgi?id=297 > 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> Added to DStress as http://dstress.kuehne.cn/nocompile/f/foreach_37_A.d http://dstress.kuehne.cn/nocompile/f/foreach_37_B.d http://dstress.kuehne.cn/nocompile/f/foreach_37_C.d http://dstress.kuehne.cn/nocompile/f/foreach_37_D.d Thomas |
Copyright © 1999-2021 by the D Language Foundation