Skip to content

Commit

Permalink
fix corner case in collapse_vars (#4002)
Browse files Browse the repository at this point in the history
fixes #4001
  • Loading branch information
alexlamsl committed Jun 19, 2020
1 parent 8b2cfd4 commit e61bc34
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/compress.js
Expand Up @@ -1500,7 +1500,6 @@ merge(Compressor.prototype, {
can_replace = false;
var after = stop_after;
var if_hit = stop_if_hit;
var rhs_fn = scan_rhs;
for (var i = 0; !abort && i < fn.body.length; i++) {
var stat = fn.body[i];
if (stat instanceof AST_Return) {
Expand All @@ -1509,7 +1508,6 @@ merge(Compressor.prototype, {
}
stat.transform(scanner);
}
scan_rhs = rhs_fn;
stop_if_hit = if_hit;
stop_after = after;
can_replace = replace;
Expand Down
34 changes: 34 additions & 0 deletions test/compress/ie8.js
Expand Up @@ -2559,3 +2559,37 @@ issue_3999: {
"1",
]
}

issue_4001: {
options = {
collapse_vars: true,
ie8: true,
inline: true,
reduce_vars: true,
sequences: true,
toplevel: true,
unused: true,
}
input: {
console.log(function(a) {
function f() {
return a;
var b;
}
var c = f();
(function g() {
c[42];
f;
})();
(function a() {});
}(42));
}
expect: {
function f() {
return a;
}
var a;
console.log((a = 42, void f()[42], void function a() {}));
}
expect_stdout: "undefined"
}

0 comments on commit e61bc34

Please sign in to comment.