Skip to content

Commit

Permalink
fix corner case in collapse_vars (#3701)
Browse files Browse the repository at this point in the history
fixes #3700
  • Loading branch information
alexlamsl committed Jan 30, 2020
1 parent a375406 commit 79c6003
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -1395,7 +1395,7 @@ merge(Compressor.prototype, {
var rhs_fn = scan_rhs;
for (var i = 0; !abort && i < fn.body.length; i++) {
var stat = fn.body[i];
if (stat instanceof AST_Exit) {
if (stat instanceof AST_Return) {
if (stat.value) stat.value.transform(scanner);
break;
}
Expand Down
31 changes: 31 additions & 0 deletions test/compress/collapse_vars.js
Expand Up @@ -7734,3 +7734,34 @@ issue_3698_3: {
}
expect_stdout: "2"
}

issue_3700: {
options = {
collapse_vars: true,
}
input: {
var a = "FAIL";
try {
a = "PASS";
(function() {
throw 0;
})();
a = 1 + a;
} catch (e) {
}
console.log(a);
}
expect: {
var a = "FAIL";
try {
a = "PASS";
(function() {
throw 0;
})();
a = 1 + a;
} catch (e) {
}
console.log(a);
}
expect_stdout: "PASS"
}

0 comments on commit 79c6003

Please sign in to comment.