fix corner case in side_effects (#5299)

fixes #5298
This commit is contained in:
Alex Lam S.L
2022-01-15 18:33:14 +00:00
committed by GitHub
parent dfd6418878
commit d96c59f9e6
2 changed files with 26 additions and 1 deletions

View File

@@ -5541,7 +5541,9 @@ Compressor.prototype.compress = function(node) {
});
def(AST_ForEnumeration, function(compressor) {
if (this.init.may_throw(compressor)) return true;
var obj = this.object.tail_node();
var obj = this.object;
if (obj.may_throw(compressor)) return true;
obj = obj.tail_node();
if (!(obj instanceof AST_Array || obj.is_string(compressor))) return true;
return this.body.may_throw(compressor);
});

View File

@@ -2676,3 +2676,26 @@ issue_5258_2: {
expect_stdout: "PASS"
node_version: ">=8"
}
issue_5298: {
options = {
awaits: true,
side_effects: true,
}
input: {
var a = "PASS";
(async function() {
for (a in [ 42 in null ]);
})();
console.log(a);
}
expect: {
var a = "PASS";
(async function() {
for (a in [ 42 in null ]);
})();
console.log(a);
}
expect_stdout: "PASS"
node_version: ">=8"
}