digitalmars.D.bugs - [Issue 297] New: Shadowing declarations allowed in foreach type lists
- d-bugmail puremagic.com (28/28) Aug 20 2006 http://d.puremagic.com/issues/show_bug.cgi?id=297
- d-bugmail puremagic.com (7/7) Sep 19 2006 http://d.puremagic.com/issues/show_bug.cgi?id=297
- Thomas Kuehne (14/29) Oct 02 2006 -----BEGIN PGP SIGNED MESSAGE-----
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>
--
Aug 20 2006
http://d.puremagic.com/issues/show_bug.cgi?id=297
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--
Sep 19 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail puremagic.com schrieb am 2006-08-20:http://d.puremagic.com/issues/show_bug.cgi?id=297void 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 -----BEGIN PGP SIGNATURE----- iD8DBQFFINYhLK5blCcjpWoRAn3vAJ9i9VvntyfjLU3yDDpaCeqlU5ZA8gCePKZ5 xiQ4maye+EgY+rZgVOL8k+A= =nr+N -----END PGP SIGNATURE-----
Oct 02 2006









d-bugmail puremagic.com 