Disallow continue referring to a non-IterationStatement. Fix #287

Simplifies handling of labels (their definition/references can be easily
figured out at parse time, no need to do it in `figure_out_scope`).
This commit is contained in:
Mihai Bazon
2013-09-02 19:36:16 +03:00
parent 1c6efdae34
commit 85b527ba3d
4 changed files with 34 additions and 48 deletions

View File

@@ -324,7 +324,7 @@ merge(Compressor.prototype, {
|| (ab instanceof AST_Continue && self === loop_body(lct))
|| (ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct))) {
if (ab.label) {
remove(ab.label.thedef.references, ab.label);
remove(ab.label.thedef.references, ab);
}
CHANGED = true;
var body = as_statement_array(stat.body).slice(0, -1);
@@ -346,7 +346,7 @@ merge(Compressor.prototype, {
|| (ab instanceof AST_Continue && self === loop_body(lct))
|| (ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct))) {
if (ab.label) {
remove(ab.label.thedef.references, ab.label);
remove(ab.label.thedef.references, ab);
}
CHANGED = true;
stat = stat.clone();
@@ -385,7 +385,7 @@ merge(Compressor.prototype, {
&& loop_body(lct) === self) || (stat instanceof AST_Continue
&& loop_body(lct) === self)) {
if (stat.label) {
remove(stat.label.thedef.references, stat.label);
remove(stat.label.thedef.references, stat);
}
} else {
a.push(stat);