[Issue 297] New: Shadowing declarations allowed in foreach type lists
Thomas Kuehne
thomas-dloop at kuehne.cn
Mon Oct 2 01:11:03 PDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
d-bugmail at 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
-----BEGIN PGP SIGNATURE-----
iD8DBQFFINYhLK5blCcjpWoRAn3vAJ9i9VvntyfjLU3yDDpaCeqlU5ZA8gCePKZ5
xiQ4maye+EgY+rZgVOL8k+A=
=nr+N
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-bugs
mailing list