Skip to content

Commit e61bc34

Browse files
authored
fix corner case in collapse_vars (#4002)
fixes #4001
1 parent 8b2cfd4 commit e61bc34

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/compress.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,6 @@ merge(Compressor.prototype, {
15001500
can_replace = false;
15011501
var after = stop_after;
15021502
var if_hit = stop_if_hit;
1503-
var rhs_fn = scan_rhs;
15041503
for (var i = 0; !abort && i < fn.body.length; i++) {
15051504
var stat = fn.body[i];
15061505
if (stat instanceof AST_Return) {
@@ -1509,7 +1508,6 @@ merge(Compressor.prototype, {
15091508
}
15101509
stat.transform(scanner);
15111510
}
1512-
scan_rhs = rhs_fn;
15131511
stop_if_hit = if_hit;
15141512
stop_after = after;
15151513
can_replace = replace;

test/compress/ie8.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,3 +2559,37 @@ issue_3999: {
25592559
"1",
25602560
]
25612561
}
2562+
2563+
issue_4001: {
2564+
options = {
2565+
collapse_vars: true,
2566+
ie8: true,
2567+
inline: true,
2568+
reduce_vars: true,
2569+
sequences: true,
2570+
toplevel: true,
2571+
unused: true,
2572+
}
2573+
input: {
2574+
console.log(function(a) {
2575+
function f() {
2576+
return a;
2577+
var b;
2578+
}
2579+
var c = f();
2580+
(function g() {
2581+
c[42];
2582+
f;
2583+
})();
2584+
(function a() {});
2585+
}(42));
2586+
}
2587+
expect: {
2588+
function f() {
2589+
return a;
2590+
}
2591+
var a;
2592+
console.log((a = 42, void f()[42], void function a() {}));
2593+
}
2594+
expect_stdout: "undefined"
2595+
}

0 commit comments

Comments
 (0)