fix corner case in evaluate (#3388)

fixes #3387
This commit is contained in:
Alex Lam S.L
2019-04-29 08:55:46 +08:00
committed by GitHub
parent 34075fc4c4
commit 413bbe0480
3 changed files with 55 additions and 33 deletions

View File

@@ -2553,9 +2553,6 @@ merge(Compressor.prototype, {
return this.tail_node().is_string(compressor);
});
def(AST_String, return_true);
def(AST_Sub, function(compressor) {
return this.expression.is_string(compressor) && this.property instanceof AST_Number;
});
def(AST_SymbolRef, function(compressor) {
var fixed = this.fixed_value();
if (!fixed) return false;
@@ -2994,7 +2991,8 @@ merge(Compressor.prototype, {
val = global_objs[exp.name];
} else {
val = exp._eval(compressor, cached, depth + 1);
if (!val || val === exp || !HOP(val, key)) return this;
if (!val || val === exp) return this;
if (typeof val == "object" && !HOP(val, key)) return this;
if (typeof val == "function") switch (key) {
case "name":
return val.node.name ? val.node.name.name : "";