@@ -2303,7 +2303,14 @@ merge(Compressor.prototype, {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
def(AST_Binary, function(compressor) {
|
def(AST_Binary, function(compressor) {
|
||||||
return lazy_op[this.operator] && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
|
switch (this.operator) {
|
||||||
|
case "&&":
|
||||||
|
return this.left._dot_throw(compressor) || this.right._dot_throw(compressor);
|
||||||
|
case "||":
|
||||||
|
return this.right._dot_throw(compressor);
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
def(AST_Conditional, function(compressor) {
|
def(AST_Conditional, function(compressor) {
|
||||||
return this.consequent._dot_throw(compressor) || this.alternative._dot_throw(compressor);
|
return this.consequent._dot_throw(compressor) || this.alternative._dot_throw(compressor);
|
||||||
@@ -3528,10 +3535,10 @@ merge(Compressor.prototype, {
|
|||||||
var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
|
var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
|
||||||
var assign_as_unused = /keep_assign/.test(compressor.option("unused")) ? return_false : function(node, props) {
|
var assign_as_unused = /keep_assign/.test(compressor.option("unused")) ? return_false : function(node, props) {
|
||||||
var sym;
|
var sym;
|
||||||
if (node instanceof AST_Assign && (node.write_only || node.operator == "=")) {
|
if (node instanceof AST_Assign) {
|
||||||
sym = node.left;
|
if (node.write_only || node.operator == "=") sym = node.left;
|
||||||
} else if (node instanceof AST_Unary && node.write_only) {
|
} else if (node instanceof AST_Unary) {
|
||||||
sym = node.expression;
|
if (node.write_only) sym = node.expression;
|
||||||
}
|
}
|
||||||
if (!/strict/.test(compressor.option("pure_getters"))) return sym instanceof AST_SymbolRef && sym;
|
if (!/strict/.test(compressor.option("pure_getters"))) return sym instanceof AST_SymbolRef && sym;
|
||||||
while (sym instanceof AST_PropAccess && !sym.expression.may_throw_on_access(compressor)) {
|
while (sym instanceof AST_PropAccess && !sym.expression.may_throw_on_access(compressor)) {
|
||||||
@@ -3637,7 +3644,7 @@ merge(Compressor.prototype, {
|
|||||||
if (sym) {
|
if (sym) {
|
||||||
var def = sym.definition();
|
var def = sym.definition();
|
||||||
var in_use = def.id in in_use_ids;
|
var in_use = def.id in in_use_ids;
|
||||||
var value = null;
|
var value;
|
||||||
if (node instanceof AST_Assign) {
|
if (node instanceof AST_Assign) {
|
||||||
if (!in_use || node.left === sym && def.id in fixed_ids && fixed_ids[def.id] !== node) {
|
if (!in_use || node.left === sym && def.id in fixed_ids && fixed_ids[def.id] !== node) {
|
||||||
value = get_rhs(node);
|
value = get_rhs(node);
|
||||||
@@ -3885,6 +3892,7 @@ merge(Compressor.prototype, {
|
|||||||
prop.walk(tw);
|
prop.walk(tw);
|
||||||
});
|
});
|
||||||
if (node instanceof AST_Assign) {
|
if (node instanceof AST_Assign) {
|
||||||
|
if (node.write_only === "p" && node.right.may_throw_on_access(compressor)) return;
|
||||||
var right = get_rhs(node);
|
var right = get_rhs(node);
|
||||||
right.walk(tw);
|
right.walk(tw);
|
||||||
if (node.left === sym) {
|
if (node.left === sym) {
|
||||||
@@ -4215,7 +4223,7 @@ merge(Compressor.prototype, {
|
|||||||
if (left instanceof AST_PropAccess) {
|
if (left instanceof AST_PropAccess) {
|
||||||
var expr = left.expression;
|
var expr = left.expression;
|
||||||
if (expr instanceof AST_Assign && !expr.may_throw_on_access(compressor)) {
|
if (expr instanceof AST_Assign && !expr.may_throw_on_access(compressor)) {
|
||||||
expr.write_only = true;
|
expr.write_only = "p";
|
||||||
}
|
}
|
||||||
if (compressor.has_directive("use strict") && expr.is_constant()) return this;
|
if (compressor.has_directive("use strict") && expr.is_constant()) return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2081,3 +2081,24 @@ issue_3495: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3497: {
|
||||||
|
options = {
|
||||||
|
pure_getters: "strict",
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
console.log(function(b) {
|
||||||
|
(b += a).p = 0;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a;
|
||||||
|
console.log(function(b) {
|
||||||
|
(b += a).p = 0;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user