scan RHS of dropped assignments (#1581)
- similar case as #1578 but against #1450 instead - fix `this` binding in #1450 as well closes #1580
This commit is contained in:
@@ -1901,17 +1901,15 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
if (drop_vars && assign_as_unused) {
|
if (drop_vars && assign_as_unused
|
||||||
var n = node;
|
&& node instanceof AST_Assign
|
||||||
while (n instanceof AST_Assign
|
&& node.operator == "="
|
||||||
&& n.operator == "="
|
&& node.left instanceof AST_SymbolRef) {
|
||||||
&& n.left instanceof AST_SymbolRef) {
|
var def = node.left.definition();
|
||||||
var def = n.left.definition();
|
if (!(def.id in in_use_ids)
|
||||||
if (def.id in in_use_ids
|
&& self.variables.get(def.name) === def) {
|
||||||
|| self.variables.get(def.name) !== def) break;
|
return maintain_this_binding(tt.parent(), node, node.right.transform(tt));
|
||||||
n = n.right;
|
|
||||||
}
|
}
|
||||||
if (n !== node) return n;
|
|
||||||
}
|
}
|
||||||
if (node instanceof AST_For) {
|
if (node instanceof AST_For) {
|
||||||
descend(node, this);
|
descend(node, this);
|
||||||
|
|||||||
@@ -725,3 +725,39 @@ vardef_value: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assign_binding: {
|
||||||
|
options = {
|
||||||
|
cascade: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
var a;
|
||||||
|
a = f.g, a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
(0, f.g)();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assign_chain: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
var a, b;
|
||||||
|
x = a = y = b = 42;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
x = y = 42;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user