fix corner case in reduce_vars (#5624)

fixes #5623
This commit is contained in:
Alex Lam S.L
2022-08-18 19:31:48 +01:00
committed by GitHub
parent 9eea3a673a
commit ac002b6338
2 changed files with 31 additions and 0 deletions

View File

@@ -1016,6 +1016,7 @@ Compressor.prototype.compress = function(node) {
} }
function walk_prop(lhs) { function walk_prop(lhs) {
reset_flags(lhs);
if (lhs instanceof AST_Dot) { if (lhs instanceof AST_Dot) {
walk_prop(lhs.expression); walk_prop(lhs.expression);
} else if (lhs instanceof AST_Sub) { } else if (lhs instanceof AST_Sub) {

View File

@@ -7896,3 +7896,33 @@ issue_5434: {
} }
expect_stdout: "PASS" expect_stdout: "PASS"
} }
issue_5623: {
options = {
collapse_vars: true,
evaluate: true,
passes: 2,
reduce_vars: true,
side_effects: true,
toplevel: true,
}
input: {
var a = 0;
function f() {
var b = a;
a = b;
}
f && f((a++ && a).toString());
console.log(a);
}
expect: {
var a = 0;
function f() {
var b;
a = a;
}
f((a++ && a).toString());
console.log(a);
}
expect_stdout: "1"
}