fix reduce_vars within try-block (#1818)
Possible partial execution due to exceptions.
This commit is contained in:
@@ -359,7 +359,19 @@ merge(Compressor.prototype, {
|
|||||||
pop();
|
pop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_Catch || node instanceof AST_SwitchBranch) {
|
if (node instanceof AST_Try) {
|
||||||
|
push();
|
||||||
|
walk_body(node, tw);
|
||||||
|
pop();
|
||||||
|
if (node.bcatch) {
|
||||||
|
push();
|
||||||
|
node.bcatch.walk(tw);
|
||||||
|
pop();
|
||||||
|
}
|
||||||
|
if (node.bfinally) node.bfinally.walk(tw);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (node instanceof AST_SwitchBranch) {
|
||||||
push();
|
push();
|
||||||
descend();
|
descend();
|
||||||
pop();
|
pop();
|
||||||
|
|||||||
@@ -2047,3 +2047,34 @@ issue_1814_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "0 '321'"
|
expect_stdout: "0 '321'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try_abort: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
!function() {
|
||||||
|
try {
|
||||||
|
var a = 1;
|
||||||
|
throw "";
|
||||||
|
var b = 2;
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
console.log(a, b);
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
!function() {
|
||||||
|
try {
|
||||||
|
var a = 1;
|
||||||
|
throw "";
|
||||||
|
var b = 2;
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
console.log(a, b);
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect_stdout: "1 undefined"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user