fix corner case in evaluate (#4120)

fixes #4119
This commit is contained in:
Alex Lam S.L
2020-09-17 14:20:31 +01:00
committed by GitHub
parent dd1374aa8a
commit 09d93cc6c8
2 changed files with 57 additions and 0 deletions

View File

@@ -3362,6 +3362,7 @@ merge(Compressor.prototype, {
cached.forEach(function(node) {
delete node._eval;
});
if (cached.unsafe) return this;
if (ignore_side_effects) return val;
if (!val || val instanceof RegExp) return val;
if (typeof val == "function" || typeof val == "object") return this;
@@ -3430,6 +3431,10 @@ merge(Compressor.prototype, {
var value = node._eval(compressor, ignore_side_effects, cached, depth);
if (value === node) return this;
modified(lhs);
if (Array.isArray(value)) value.toString = function() {
cached.unsafe = true;
return "[]";
};
return value;
});
def(AST_Sequence, function(compressor, ignore_side_effects, cached, depth) {