WTF?

Koroskin Denis 2korden at gmail.com
Sun Mar 16 17:12:32 PDT 2008


On Fri, 14 Mar 2008 05:47:03 +0300, BCS <ao at pathlink.com> wrote:

> I'm not objecting but...
>
> this compiles (1.026):
>
> import std.stdio; void main()
> {
> 	int j = 3;
> 	for({ int i; if(j>2) i = 3; else i = 4; } i; i--)
> 	{
> 		writef("%d\n", i);
> 	}
> }
>
>


It clearly should not, because `i' is out of scope after initialization.  
Yet, there is a missing semicolon...

This could be ok:
for( {}; ; ) {

}

But not this:
for( {} ; ) {

}

My guess, this is just a lexer bug and was not intended.



More information about the Digitalmars-d mailing list