Bug 420 : Unexpected parsing, semicolon after a for()
Last modified: 2006-10-16 18:55




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
REAS
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2006-10-16 11:04
The following code:

int i;
for (i=0; i<400; i=i+4); {
println(i);
}

Prints "400" to the console. The ";" at the end of the for() is having a
strange effect. No error is reported.
Additional Comment #1 From fry 2006-10-16 18:55
that's perfectly legal syntax but nasty. it's like doing:

while (waitingForSomething) { }

and this would be the same:

while (waitingForSomething) ;

and it works identically with for(). this is something that we might
consider to explicitly disallow in the future. then again, with better
warnings, a compiler should warn you about this sort of thing (i.e. eclipse
does).