minor clean-ups (#5604)
This commit is contained in:
180
lib/compress.js
180
lib/compress.js
@@ -2057,12 +2057,7 @@ Compressor.prototype.compress = function(node) {
|
||||
&& node instanceof AST_Assign && node.operator != "=" && node.left.equals(lhs)) {
|
||||
replaced++;
|
||||
changed = true;
|
||||
AST_Node.info("Cascading {node} [{file}:{line},{col}]", {
|
||||
node: node,
|
||||
file: node.start.file,
|
||||
line: node.start.line,
|
||||
col: node.start.col,
|
||||
});
|
||||
AST_Node.info("Cascading {this} [{start}]", node);
|
||||
can_replace = false;
|
||||
lvalues = get_lvalues(lhs);
|
||||
node.right.transform(scanner);
|
||||
@@ -2119,12 +2114,7 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
replaced++;
|
||||
changed = abort = true;
|
||||
AST_Node.info("Collapsing {node} [{file}:{line},{col}]", {
|
||||
node: node,
|
||||
file: node.start.file,
|
||||
line: node.start.line,
|
||||
col: node.start.col,
|
||||
});
|
||||
AST_Node.info("Collapsing {this} [{start}]", node);
|
||||
if (candidate.TYPE == "Binary") {
|
||||
update_symbols(candidate, node);
|
||||
return make_node(AST_Assign, candidate, {
|
||||
@@ -2252,12 +2242,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (node instanceof AST_SymbolRef && node.definition() === def) {
|
||||
if (is_lhs(node, multi_replacer.parent())) return node;
|
||||
if (!--replaced) abort = true;
|
||||
AST_Node.info("Replacing {node} [{file}:{line},{col}]", {
|
||||
node: node,
|
||||
file: node.start.file,
|
||||
line: node.start.line,
|
||||
col: node.start.col,
|
||||
});
|
||||
AST_Node.info("Replacing {this} [{start}]", node);
|
||||
var ref = rvalue.clone();
|
||||
ref.scope = node.scope;
|
||||
ref.reference();
|
||||
@@ -4282,7 +4267,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (node instanceof AST_Definitions) {
|
||||
var defns = [];
|
||||
if (node.remove_initializers(compressor, defns)) {
|
||||
AST_Node.warn("Dropping initialization in unreachable code [{file}:{line},{col}]", node.start);
|
||||
AST_Node.warn("Dropping initialization in unreachable code [{start}]", node);
|
||||
}
|
||||
if (defns.length > 0) {
|
||||
node.definitions = defns;
|
||||
@@ -4309,7 +4294,7 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
if (!(node instanceof AST_LoopControl)) dropped = true;
|
||||
}));
|
||||
if (dropped) AST_Node.warn("Dropping unreachable code [{file}:{line},{col}]", stat.start);
|
||||
if (dropped) AST_Node.warn("Dropping unreachable code [{start}]", stat);
|
||||
|
||||
function push(node) {
|
||||
if (block) {
|
||||
@@ -4785,12 +4770,7 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
|
||||
function warn(node) {
|
||||
AST_Node.warn("global_defs {node} redefined [{file}:{line},{col}]", {
|
||||
node: node,
|
||||
file: node.start.file,
|
||||
line: node.start.line,
|
||||
col: node.start.col,
|
||||
});
|
||||
AST_Node.warn("global_defs {this} redefined [{start}]", node);
|
||||
}
|
||||
|
||||
AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
|
||||
@@ -5042,7 +5022,7 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
}
|
||||
def(AST_Statement, function() {
|
||||
throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
|
||||
throw new Error(string_template("Cannot evaluate a statement [{start}]", this));
|
||||
});
|
||||
def(AST_Accessor, return_this);
|
||||
def(AST_BigInt, return_this);
|
||||
@@ -5468,12 +5448,7 @@ Compressor.prototype.compress = function(node) {
|
||||
try {
|
||||
return val[key].apply(val, args);
|
||||
} catch (ex) {
|
||||
AST_Node.warn("Error evaluating {code} [{file}:{line},{col}]", {
|
||||
code: this,
|
||||
file: this.start.file,
|
||||
line: this.start.line,
|
||||
col: this.start.col,
|
||||
});
|
||||
AST_Node.warn("Error evaluating {this} [{start}]", this);
|
||||
} finally {
|
||||
if (val instanceof RegExp) val.lastIndex = 0;
|
||||
}
|
||||
@@ -7291,7 +7266,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (value && ((index = indexOf_assign(sym, def)) < 0 || self_assign(value.tail_node()))) {
|
||||
def = def.clone();
|
||||
value = value.drop_side_effect_free(compressor);
|
||||
if (value) AST_Node.warn("Side effects in definition of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
if (value) AST_Node.warn("Side effects in definition of variable {name} [{start}]", def.name);
|
||||
if (node instanceof AST_Const) {
|
||||
def.value = value || make_node(AST_Number, def, { value: 0 });
|
||||
} else {
|
||||
@@ -7306,7 +7281,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (parent instanceof AST_ExportDeclaration) {
|
||||
flush();
|
||||
} else if (drop_sym && var_defs[sym.id] > 1) {
|
||||
AST_Node.info("Dropping declaration of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
AST_Node.info("Dropping declaration of variable {name} [{start}]", def.name);
|
||||
var_defs[sym.id]--;
|
||||
sym.eliminated++;
|
||||
} else {
|
||||
@@ -7324,7 +7299,7 @@ Compressor.prototype.compress = function(node) {
|
||||
&& assigned_once(fn, sym.references)
|
||||
&& can_declare_defun(fn)
|
||||
&& (old_def = rename_def(fn, def.name.name)) !== false) {
|
||||
AST_Node.warn("Declaring {name} as function [{file}:{line},{col}]", template(def.name));
|
||||
AST_Node.warn("Declaring {name} as function [{start}]", def.name);
|
||||
var ctor;
|
||||
switch (fn.CTOR) {
|
||||
case AST_AsyncFunction:
|
||||
@@ -7364,7 +7339,7 @@ Compressor.prototype.compress = function(node) {
|
||||
value = value && value.drop_side_effect_free(compressor);
|
||||
if (value) side_effects.push(value);
|
||||
if (var_defs[sym.id] > 1) {
|
||||
AST_Node.warn("Dropping duplicated declaration of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
AST_Node.warn("Dropping duplicated declaration of variable {name} [{start}]", def.name);
|
||||
var_defs[sym.id]--;
|
||||
sym.eliminated++;
|
||||
} else {
|
||||
@@ -7374,7 +7349,7 @@ Compressor.prototype.compress = function(node) {
|
||||
} else {
|
||||
value = value && value.drop_side_effect_free(compressor);
|
||||
if (value) {
|
||||
AST_Node.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
AST_Node.warn("Side effects in initialization of unused variable {name} [{start}]", def.name);
|
||||
side_effects.push(value);
|
||||
} else {
|
||||
log(def.name, "Dropping unused variable {name}");
|
||||
@@ -7459,7 +7434,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (tail.length == 0) break;
|
||||
if (tail.length == duplicated) {
|
||||
[].unshift.apply(side_effects, tail.map(function(def) {
|
||||
AST_Node.info("Dropping duplicated definition of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
AST_Node.info("Dropping duplicated definition of variable {name} [{start}]", def.name);
|
||||
var sym = def.name.definition();
|
||||
var ref = make_node(AST_SymbolRef, def.name, def.name);
|
||||
sym.references.push(ref);
|
||||
@@ -7566,7 +7541,7 @@ Compressor.prototype.compress = function(node) {
|
||||
var body = [];
|
||||
var value = node.object.drop_side_effect_free(compressor);
|
||||
if (value) {
|
||||
AST_Node.warn("Side effects in object of for-in loop [{file}:{line},{col}]", value.start);
|
||||
AST_Node.warn("Side effects in object of for-in loop [{start}]", value);
|
||||
body.push(make_node(AST_SimpleStatement, node, {
|
||||
body: value
|
||||
}));
|
||||
@@ -7599,31 +7574,17 @@ Compressor.prototype.compress = function(node) {
|
||||
});
|
||||
|
||||
function log(sym, text) {
|
||||
AST_Node[sym.definition().references.length > 0 ? "info" : "warn"](text + " [{file}:{line},{col}]", template(sym));
|
||||
AST_Node[sym.definition().references.length > 0 ? "info" : "warn"](text + " [{start}]", sym);
|
||||
}
|
||||
|
||||
function log_default(node, text) {
|
||||
if (node.name instanceof AST_SymbolFunarg) {
|
||||
log(node.name, text);
|
||||
} else {
|
||||
AST_Node.info(text + " [{file}:{line},{col}]", {
|
||||
name: node,
|
||||
file: node.start.file,
|
||||
line: node.start.line,
|
||||
col : node.start.col,
|
||||
});
|
||||
AST_Node.info(text + " [{start}]", node);
|
||||
}
|
||||
}
|
||||
|
||||
function template(sym) {
|
||||
return {
|
||||
name: sym.name,
|
||||
file: sym.start.file,
|
||||
line: sym.start.line,
|
||||
col : sym.start.col,
|
||||
};
|
||||
}
|
||||
|
||||
function get_rvalue(expr) {
|
||||
return expr[expr instanceof AST_Assign ? "right" : "value"];
|
||||
}
|
||||
@@ -8797,7 +8758,7 @@ Compressor.prototype.compress = function(node) {
|
||||
def(AST_Call, function(compressor, first_in_statement) {
|
||||
var self = this;
|
||||
if (self.is_expr_pure(compressor)) {
|
||||
if (self.pure) AST_Node.warn("Dropping __PURE__ call [{file}:{line},{col}]", self.start);
|
||||
if (self.pure) AST_Node.warn("Dropping __PURE__ call [{start}]", self);
|
||||
var args = trim(self.args, compressor, first_in_statement, array_spread);
|
||||
return args && make_sequence(self, args.map(convert_spread));
|
||||
}
|
||||
@@ -9074,7 +9035,7 @@ Compressor.prototype.compress = function(node) {
|
||||
var body = self.body;
|
||||
var node = body.drop_side_effect_free(compressor, true);
|
||||
if (!node) {
|
||||
AST_Node.warn("Dropping side-effect-free statement [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Dropping side-effect-free statement [{start}]", self);
|
||||
return make_node(AST_EmptyStatement, self);
|
||||
}
|
||||
if (node !== body) {
|
||||
@@ -9531,7 +9492,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (compressor.option("dead_code")) {
|
||||
var cond = fuzzy_eval(compressor, self.condition);
|
||||
if (!cond) {
|
||||
AST_Node.warn("Condition always false [{file}:{line},{col}]", self.condition.start);
|
||||
AST_Node.warn("Condition always false [{start}]", self.condition);
|
||||
var body = [
|
||||
make_node(AST_SimpleStatement, self.condition, { body: self.condition }).transform(compressor),
|
||||
];
|
||||
@@ -9539,7 +9500,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (self.alternative) body.push(self.alternative);
|
||||
return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
|
||||
} else if (!(cond instanceof AST_Node)) {
|
||||
AST_Node.warn("Condition always true [{file}:{line},{col}]", self.condition.start);
|
||||
AST_Node.warn("Condition always true [{start}]", self.condition);
|
||||
var body = [
|
||||
make_node(AST_SimpleStatement, self.condition, { body: self.condition }).transform(compressor),
|
||||
self.body,
|
||||
@@ -10318,11 +10279,9 @@ Compressor.prototype.compress = function(node) {
|
||||
for (var i = 0; i < length; i++) elements[i] = make_node(AST_Hole, self);
|
||||
return make_node(AST_Array, self, { elements: elements });
|
||||
} catch (ex) {
|
||||
AST_Node.warn("Invalid array length: {length} [{file}:{line},{col}]", {
|
||||
AST_Node.warn("Invalid array length: {length} [{start}]", {
|
||||
length: length,
|
||||
file: self.start.file,
|
||||
line: self.start.line,
|
||||
col: self.start.col,
|
||||
start: self.start,
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -10381,12 +10340,7 @@ Compressor.prototype.compress = function(node) {
|
||||
value: RegExp.apply(RegExp, params),
|
||||
}));
|
||||
} catch (ex) {
|
||||
AST_Node.warn("Error converting {expr} [{file}:{line},{col}]", {
|
||||
expr: self,
|
||||
file: self.start.file,
|
||||
line: self.start.line,
|
||||
col: self.start.col,
|
||||
});
|
||||
AST_Node.warn("Error converting {this} [{start}]", self);
|
||||
}
|
||||
break;
|
||||
} else if (exp instanceof AST_Dot) switch (exp.property) {
|
||||
@@ -10585,7 +10539,7 @@ Compressor.prototype.compress = function(node) {
|
||||
return self;
|
||||
} catch (ex) {
|
||||
if (ex instanceof JS_Parse_Error) {
|
||||
AST_Node.warn("Error parsing code passed to new Function [{file}:{line},{col}]", self.args[self.args.length - 1].start);
|
||||
AST_Node.warn("Error parsing code passed to new Function [{start}]", self.args[self.args.length - 1]);
|
||||
AST_Node.warn(ex.toString());
|
||||
} else {
|
||||
throw ex;
|
||||
@@ -11341,7 +11295,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (!compressor.option("booleans")) break;
|
||||
if (!compressor.in_boolean_context()) break;
|
||||
// typeof always returns a non-empty string, thus always truthy
|
||||
AST_Node.warn("Boolean expression always true [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Boolean expression always true [{start}]", self);
|
||||
var exprs = [ make_node(AST_True, self) ];
|
||||
if (!(exp instanceof AST_SymbolRef && can_drop_symbol(exp, compressor))) exprs.unshift(exp);
|
||||
return make_sequence(self, exprs).optimize(compressor);
|
||||
@@ -11587,7 +11541,7 @@ Compressor.prototype.compress = function(node) {
|
||||
case "===":
|
||||
case "!==":
|
||||
if (is_undefined(self.left, compressor) && self.right.is_defined(compressor)) {
|
||||
AST_Node.warn("Expression always defined [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Expression always defined [{start}]", self);
|
||||
return make_sequence(self, [
|
||||
self.right,
|
||||
make_node(self.operator == "===" ? AST_False : AST_True, self)
|
||||
@@ -11667,7 +11621,7 @@ Compressor.prototype.compress = function(node) {
|
||||
case "+":
|
||||
var ev = self.left.evaluate(compressor, true);
|
||||
if (ev && typeof ev == "string" || (ev = self.right.evaluate(compressor, true)) && typeof ev == "string") {
|
||||
AST_Node.warn("+ in boolean context always true [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("+ in boolean context always true [{start}]", self);
|
||||
var exprs = [];
|
||||
if (self.left.evaluate(compressor) instanceof AST_Node) exprs.push(self.left);
|
||||
if (self.right.evaluate(compressor) instanceof AST_Node) exprs.push(self.right);
|
||||
@@ -11752,20 +11706,20 @@ Compressor.prototype.compress = function(node) {
|
||||
case "&&":
|
||||
var ll = fuzzy_eval(compressor, self.left);
|
||||
if (!ll) {
|
||||
AST_Node.warn("Condition left of && always false [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Condition left of && always false [{start}]", self);
|
||||
return maintain_this_binding(parent, compressor.self(), self.left).optimize(compressor);
|
||||
} else if (!(ll instanceof AST_Node)) {
|
||||
AST_Node.warn("Condition left of && always true [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Condition left of && always true [{start}]", self);
|
||||
return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
|
||||
}
|
||||
if (!self.right.evaluate(compressor, true)) {
|
||||
if (in_bool && !(self.right.evaluate(compressor) instanceof AST_Node)) {
|
||||
AST_Node.warn("Boolean && always false [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Boolean && always false [{start}]", self);
|
||||
return make_sequence(self, [ self.left, make_node(AST_False, self) ]).optimize(compressor);
|
||||
} else self.falsy = true;
|
||||
} else if ((in_bool || parent.operator == "&&" && parent.left === compressor.self())
|
||||
&& !(self.right.evaluate(compressor) instanceof AST_Node)) {
|
||||
AST_Node.warn("Dropping side-effect-free && [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Dropping side-effect-free && [{start}]", self);
|
||||
return self.left.optimize(compressor);
|
||||
}
|
||||
// (x || false) && y ---> x ? y : false
|
||||
@@ -11774,7 +11728,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (!lr) return make_node(AST_Conditional, self, {
|
||||
condition: self.left.left,
|
||||
consequent: self.right,
|
||||
alternative: self.left.right
|
||||
alternative: self.left.right,
|
||||
}).optimize(compressor);
|
||||
}
|
||||
break;
|
||||
@@ -11783,38 +11737,29 @@ Compressor.prototype.compress = function(node) {
|
||||
case "||":
|
||||
var ll = fuzzy_eval(compressor, self.left, nullish);
|
||||
if (nullish ? ll == null : !ll) {
|
||||
AST_Node.warn("Condition left of {operator} always {value} [{file}:{line},{col}]", {
|
||||
AST_Node.warn("Condition left of {operator} always {value} [{start}]", {
|
||||
operator: self.operator,
|
||||
value: nullish ? "nulish" : "false",
|
||||
file: self.start.file,
|
||||
line: self.start.line,
|
||||
col: self.start.col,
|
||||
start: self.start,
|
||||
});
|
||||
return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
|
||||
} else if (!(ll instanceof AST_Node)) {
|
||||
AST_Node.warn("Condition left of {operator} always {value} [{file}:{line},{col}]", {
|
||||
AST_Node.warn("Condition left of {operator} always {value} [{start}]", {
|
||||
operator: self.operator,
|
||||
value: nullish ? "defined" : "true",
|
||||
file: self.start.file,
|
||||
line: self.start.line,
|
||||
col: self.start.col,
|
||||
start: self.start,
|
||||
});
|
||||
return maintain_this_binding(parent, compressor.self(), self.left).optimize(compressor);
|
||||
}
|
||||
var rr;
|
||||
if (!nullish && (rr = self.right.evaluate(compressor, true)) && !(rr instanceof AST_Node)) {
|
||||
if (in_bool && !(self.right.evaluate(compressor) instanceof AST_Node)) {
|
||||
AST_Node.warn("Boolean || always true [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Boolean || always true [{start}]", self);
|
||||
return make_sequence(self, [ self.left, make_node(AST_True, self) ]).optimize(compressor);
|
||||
} else self.truthy = true;
|
||||
} else if ((in_bool || parent.operator == "||" && parent.left === compressor.self())
|
||||
&& !self.right.evaluate(compressor)) {
|
||||
AST_Node.warn("Dropping side-effect-free {operator} [{file}:{line},{col}]", {
|
||||
operator: self.operator,
|
||||
file: self.start.file,
|
||||
line: self.start.line,
|
||||
col: self.start.col,
|
||||
});
|
||||
AST_Node.warn("Dropping side-effect-free {operator} [{start}]", self);
|
||||
return self.left.optimize(compressor);
|
||||
}
|
||||
// x && true || y ---> x ? true : y
|
||||
@@ -11823,7 +11768,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
|
||||
condition: self.left.left,
|
||||
consequent: self.left.right,
|
||||
alternative: self.right
|
||||
alternative: self.right,
|
||||
}).optimize(compressor);
|
||||
}
|
||||
break;
|
||||
@@ -11839,9 +11784,9 @@ Compressor.prototype.compress = function(node) {
|
||||
left: make_node(AST_String, self.left, {
|
||||
value: "" + self.left.value + self.right.left.value,
|
||||
start: self.left.start,
|
||||
end: self.right.left.end
|
||||
end: self.right.left.end,
|
||||
}),
|
||||
right: self.right.right
|
||||
right: self.right.right,
|
||||
});
|
||||
}
|
||||
// (x + "foo") + "bar" ---> x + "foobar"
|
||||
@@ -11856,8 +11801,8 @@ Compressor.prototype.compress = function(node) {
|
||||
right: make_node(AST_String, self.right, {
|
||||
value: "" + self.left.right.value + self.right.value,
|
||||
start: self.left.right.start,
|
||||
end: self.right.end
|
||||
})
|
||||
end: self.right.end,
|
||||
}),
|
||||
});
|
||||
}
|
||||
// a + -b ---> a - b
|
||||
@@ -11867,7 +11812,7 @@ Compressor.prototype.compress = function(node) {
|
||||
self = make_node(AST_Binary, self, {
|
||||
operator: "-",
|
||||
left: self.left,
|
||||
right: self.right.expression
|
||||
right: self.right.expression,
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -11879,7 +11824,7 @@ Compressor.prototype.compress = function(node) {
|
||||
self = make_node(AST_Binary, self, {
|
||||
operator: "-",
|
||||
left: self.right,
|
||||
right: self.left.expression
|
||||
right: self.left.expression,
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -11897,9 +11842,9 @@ Compressor.prototype.compress = function(node) {
|
||||
left: make_node(AST_Binary, self, {
|
||||
operator: self.operator,
|
||||
left: self.right,
|
||||
right: self.left.left
|
||||
right: self.left.left,
|
||||
}),
|
||||
right: self.left.right
|
||||
right: self.left.right,
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -11912,7 +11857,7 @@ Compressor.prototype.compress = function(node) {
|
||||
self = make_node(AST_Binary, self, {
|
||||
operator: "+",
|
||||
left: self.left,
|
||||
right: self.right.expression
|
||||
right: self.right.expression,
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -11968,16 +11913,16 @@ Compressor.prototype.compress = function(node) {
|
||||
left: self.left,
|
||||
right: self.right.left,
|
||||
start: self.left.start,
|
||||
end: self.right.left.end
|
||||
end: self.right.left.end,
|
||||
}),
|
||||
right: self.right.right
|
||||
right: self.right.right,
|
||||
});
|
||||
if (self.operator == "+"
|
||||
&& !self.right.is_boolean(compressor)
|
||||
&& !self.right.is_number(compressor)) {
|
||||
self.right = make_node(AST_UnaryPrefix, self.right, {
|
||||
operator: "+",
|
||||
expression: self.right
|
||||
expression: self.right,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -12783,10 +12728,10 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
condition = fuzzy_eval(compressor, condition);
|
||||
if (!condition) {
|
||||
AST_Node.warn("Condition always false [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Condition always false [{start}]", self);
|
||||
return make_sequence(self, [ self.condition, self.alternative ]).optimize(compressor);
|
||||
} else if (!(condition instanceof AST_Node)) {
|
||||
AST_Node.warn("Condition always true [{file}:{line},{col}]", self.start);
|
||||
AST_Node.warn("Condition always true [{start}]", self);
|
||||
return make_sequence(self, [ self.condition, self.consequent ]).optimize(compressor);
|
||||
}
|
||||
var first = first_in_statement(compressor);
|
||||
@@ -13158,12 +13103,10 @@ Compressor.prototype.compress = function(node) {
|
||||
if (compressor.in_boolean_context()) return make_node(AST_Number, self, { value: +self.value });
|
||||
var p = compressor.parent();
|
||||
if (p instanceof AST_Binary && (p.operator == "==" || p.operator == "!=")) {
|
||||
AST_Node.warn("Non-strict equality against boolean: {operator} {value} [{file}:{line},{col}]", {
|
||||
operator : p.operator,
|
||||
value : self.value,
|
||||
file : p.start.file,
|
||||
line : p.start.line,
|
||||
col : p.start.col,
|
||||
AST_Node.warn("Non-strict equality against boolean: {operator} {value} [{start}]", {
|
||||
operator: p.operator,
|
||||
value: self.value,
|
||||
start: p.start,
|
||||
});
|
||||
return make_node(AST_Number, self, { value: +self.value });
|
||||
}
|
||||
@@ -13440,12 +13383,7 @@ Compressor.prototype.compress = function(node) {
|
||||
|
||||
OPT(AST_Dot, function(self, compressor) {
|
||||
if (self.property == "arguments" || self.property == "caller") {
|
||||
AST_Node.warn("Function.prototype.{prop} not supported [{file}:{line},{col}]", {
|
||||
prop: self.property,
|
||||
file: self.start.file,
|
||||
line: self.start.line,
|
||||
col: self.start.col,
|
||||
});
|
||||
AST_Node.warn("Function.prototype.{property} not supported [{start}]", self);
|
||||
}
|
||||
var parent = compressor.parent();
|
||||
if (is_lhs(compressor.self(), parent)) return self;
|
||||
|
||||
Reference in New Issue
Block a user