fix corner case in evaluate (#5381)

fixes #5380
This commit is contained in:
Alex Lam S.L
2022-03-12 05:08:29 +00:00
committed by GitHub
parent 7aba2dc5f2
commit 01b84074d7
2 changed files with 28 additions and 0 deletions

View File

@@ -4767,6 +4767,7 @@ Compressor.prototype.compress = function(node) {
});
var scan_modified = new TreeWalker(function(node) {
if (node instanceof AST_Assign) modified(node.left);
if (node instanceof AST_ForEnumeration) modified(node.init);
if (node instanceof AST_Unary && UNARY_POSTFIX[node.operator]) modified(node.expression);
});
function modified(node) {

View File

@@ -3349,3 +3349,30 @@ issue_5362_2: {
}
expect_stdout: "true"
}
issue_5380: {
options = {
evaluate: true,
keep_fnames: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var a = function f(b) {
return function g() {
for (b in { PASS: 42 });
}(), b;
}("FAIL");
console.log(a);
}
expect: {
var a = function f(b) {
return function g() {
for (b in { PASS: 42 });
}(), b;
}("FAIL");
console.log(a);
}
expect_stdout: "PASS"
}