minor clean-up (#5210)

This commit is contained in:
Alex Lam S.L
2021-12-09 20:48:06 +00:00
committed by GitHub
parent d11c82f8ca
commit 9e4c4c995c

View File

@@ -6659,7 +6659,7 @@ Compressor.prototype.compress = function(node) {
if (value && indexOf_assign(sym, def) < 0) { if (value && indexOf_assign(sym, def) < 0) {
value = value.drop_side_effect_free(compressor); value = value.drop_side_effect_free(compressor);
if (value) { if (value) {
AST_Node.warn("Side effects in last use of variable {name} [{file}:{line},{col}]", template(def.name)); AST_Node.warn("Side effects in definition of variable {name} [{file}:{line},{col}]", template(def.name));
side_effects.push(value); side_effects.push(value);
} }
value = null; value = null;
@@ -6823,7 +6823,7 @@ Compressor.prototype.compress = function(node) {
var assign = make_node(AST_Assign, def, { var assign = make_node(AST_Assign, def, {
operator: "=", operator: "=",
left: ref, left: ref,
right: def.value right: def.value,
}); });
var index = indexOf_assign(sym, def); var index = indexOf_assign(sym, def);
if (index >= 0) assign_in_use[sym.id][index] = assign; if (index >= 0) assign_in_use[sym.id][index] = assign;
@@ -12391,7 +12391,7 @@ Compressor.prototype.compress = function(node) {
}); });
AST_LambdaExpression.DEFMETHOD("contains_super", function() { AST_LambdaExpression.DEFMETHOD("contains_super", function() {
var result; var result = false;
var self = this; var self = this;
self.walk(new TreeWalker(function(node) { self.walk(new TreeWalker(function(node) {
if (result) return true; if (result) return true;
@@ -12401,10 +12401,15 @@ Compressor.prototype.compress = function(node) {
return result; return result;
}); });
AST_Arrow.DEFMETHOD("contains_this", return_false); // contains_this()
AST_AsyncArrow.DEFMETHOD("contains_this", return_false); // returns false only if context bound by the specified scope (or scope
AST_Node.DEFMETHOD("contains_this", function() { // containing the specified expression) is not referenced by `this`
var result; (function(def) {
// scope of arrow function cannot bind to any context
def(AST_Arrow, return_false);
def(AST_AsyncArrow, return_false);
def(AST_Node, function() {
var result = false;
var self = this; var self = this;
self.walk(new TreeWalker(function(node) { self.walk(new TreeWalker(function(node) {
if (result) return true; if (result) return true;
@@ -12413,6 +12418,9 @@ Compressor.prototype.compress = function(node) {
})); }));
return result; return result;
}); });
})(function(node, func) {
node.DEFMETHOD("contains_this", func);
});
function can_hoist_property(prop) { function can_hoist_property(prop) {
return prop instanceof AST_ObjectKeyVal return prop instanceof AST_ObjectKeyVal