fix corner case in evaluate (#3883)

fixes #3882
This commit is contained in:
Alex Lam S.L
2020-05-11 20:24:44 +01:00
committed by GitHub
parent e8a7956b6f
commit bd2f53bc8b
2 changed files with 34 additions and 3 deletions

View File

@@ -3268,9 +3268,14 @@ merge(Compressor.prototype, {
});
def(AST_Sequence, function(compressor, ignore_side_effects, cached, depth) {
if (!ignore_side_effects) return this;
var node = this.tail_node();
var value = node._eval(compressor, ignore_side_effects, cached, depth);
return value === node ? this : value;
var tail = this.tail_node();
this.walk(new TreeWalker(function(node) {
if (node === tail) return true;
if (node instanceof AST_Assign) modified(node.left);
if (node instanceof AST_Unary && unary_arithmetic[node.operator]) modified(node.expression);
}));
var value = tail._eval(compressor, ignore_side_effects, cached, depth);
return value === tail ? this : value;
});
def(AST_Lambda, function(compressor) {
if (compressor.option("unsafe")) {