fix corner case in collapse_vars (#5494)

fixes #5493
This commit is contained in:
Alex Lam S.L
2022-06-06 16:36:19 +01:00
committed by GitHub
parent 0c7b016fa7
commit be53c4838b
2 changed files with 22 additions and 0 deletions

View File

@@ -2831,6 +2831,7 @@ Compressor.prototype.compress = function(node) {
}
return find_stop_logical(parent, op, level);
}
if (parent instanceof AST_Await) return find_stop_value(parent, level + 1);
if (parent instanceof AST_Binary) {
var op;
if (parent.left === node || !lazy_op[op = parent.operator]) {

View File

@@ -2961,3 +2961,24 @@ issue_5478: {
expect_stdout: "PASS"
node_version: ">=8"
}
issue_5493: {
options = {
collapse_vars: true,
reduce_vars: true,
}
input: {
(async function(a) {
var b = await [ 42 || b, a = b ];
console.log(a);
})();
}
expect: {
(async function(a) {
var b = await [ 42 || b, a = b ];
console.log(a);
})();
}
expect_stdout: "undefined"
node_version: ">=8"
}