fix infinite loop triggered by #3347 (#3354)

fixes #3353
This commit is contained in:
Alex Lam S.L
2019-03-23 14:21:54 +08:00
committed by GitHub
parent e3c565b46f
commit 7436977aa5

View File

@@ -2246,7 +2246,11 @@ merge(Compressor.prototype, {
}); });
def(AST_SymbolRef, function() { def(AST_SymbolRef, function() {
var fixed = this.fixed_value(); var fixed = this.fixed_value();
return fixed && fixed.is_truthy(); if (!fixed) return false;
this.is_truthy = return_false;
var result = fixed.is_truthy();
delete this.is_truthy;
return result;
}); });
})(function(node, func) { })(function(node, func) {
node.DEFMETHOD("is_truthy", func); node.DEFMETHOD("is_truthy", func);
@@ -2300,7 +2304,11 @@ merge(Compressor.prototype, {
if (is_undeclared_ref(this) && this.is_declared(compressor)) return false; if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
if (this.is_immutable()) return false; if (this.is_immutable()) return false;
var fixed = this.fixed_value(); var fixed = this.fixed_value();
return !fixed || fixed._dot_throw(compressor); if (!fixed) return true;
this._dot_throw = return_true;
var result = fixed._dot_throw(compressor);
delete this._dot_throw;
return result;
}); });
def(AST_UnaryPrefix, function() { def(AST_UnaryPrefix, function() {
return this.operator == "void"; return this.operator == "void";
@@ -2342,7 +2350,11 @@ merge(Compressor.prototype, {
}); });
def(AST_SymbolRef, function(compressor) { def(AST_SymbolRef, function(compressor) {
var fixed = this.fixed_value(); var fixed = this.fixed_value();
return fixed && fixed.is_boolean(compressor); if (!fixed) return false;
this.is_boolean = return_false;
var result = fixed.is_boolean(compressor);
delete this.is_boolean;
return result;
}); });
var unary = makePredicate("! delete"); var unary = makePredicate("! delete");
def(AST_UnaryPrefix, function() { def(AST_UnaryPrefix, function() {
@@ -2427,7 +2439,11 @@ merge(Compressor.prototype, {
}); });
def(AST_SymbolRef, function(compressor) { def(AST_SymbolRef, function(compressor) {
var fixed = this.fixed_value(); var fixed = this.fixed_value();
return fixed && fixed.is_number(compressor); if (!fixed) return false;
this.is_number = return_false;
var result = fixed.is_number(compressor);
delete this.is_number;
return result;
}); });
var unary = makePredicate("+ - ~ ++ --"); var unary = makePredicate("+ - ~ ++ --");
def(AST_Unary, function() { def(AST_Unary, function() {
@@ -2456,7 +2472,11 @@ merge(Compressor.prototype, {
def(AST_String, return_true); def(AST_String, return_true);
def(AST_SymbolRef, function(compressor) { def(AST_SymbolRef, function(compressor) {
var fixed = this.fixed_value(); var fixed = this.fixed_value();
return fixed && fixed.is_string(compressor); if (!fixed) return false;
this.is_string = return_false;
var result = fixed.is_string(compressor);
delete this.is_string;
return result;
}); });
def(AST_UnaryPrefix, function() { def(AST_UnaryPrefix, function() {
return this.operator == "typeof"; return this.operator == "typeof";