Can anyone shed some lights on automatic semicolon insertion (ASI) and
the do-while statement?
Consider this function declaration:
function foo () {do {} while(0)(0)}
I'd expect a syntax error, because ASI does not apply in this case (cf.
7.9 ECMAScript3/5), but all major browsers I've tested with (Firefox,
Opera, Safari, IE) accept that function. Compiling the function
declaration with the Flex compiler generated a syntax error just as
expected. Note: I've used the plain html- resp. as-file for testing. Our
parser accepts the declaration, too, but it will also generate
non-ambiguous code, therefore I wanted to use plain files to verify our
parser works correctly.
Generated code from our compiler:
function foo () {
/* -*- file: #3 -*- */
do {
} while (0);
/* -*- file: #3 -*- */
0
}
<canvas>
<script when="immediate">
function foo () {do {} while(0)(0)}
</script>
</canvas>
package {
import flash.display.*;
public class asi_dowhile extends Sprite {
public function asi_dowhile () {
super();
function foo () {do {} while(0)(0)}
}
}
}