@@ -752,14 +752,18 @@ merge(Compressor.prototype, {
|
|||||||
def(AST_Call, function(tw, descend) {
|
def(AST_Call, function(tw, descend) {
|
||||||
tw.find_parent(AST_Scope).may_call_this();
|
tw.find_parent(AST_Scope).may_call_this();
|
||||||
var exp = this.expression;
|
var exp = this.expression;
|
||||||
if (exp instanceof AST_Function) {
|
var tail = exp.tail_node();
|
||||||
|
if (tail instanceof AST_Function) {
|
||||||
|
if (exp !== tail) exp.expressions.slice(0, -1).forEach(function(node) {
|
||||||
|
node.walk(tw);
|
||||||
|
});
|
||||||
this.args.forEach(function(arg) {
|
this.args.forEach(function(arg) {
|
||||||
arg.walk(tw);
|
arg.walk(tw);
|
||||||
});
|
});
|
||||||
exp.walk(tw);
|
tail.walk(tw);
|
||||||
return true;
|
return true;
|
||||||
} else if (exp instanceof AST_SymbolRef) {
|
} else if (tail instanceof AST_SymbolRef) {
|
||||||
var def = exp.definition();
|
var def = tail.definition();
|
||||||
if (this.TYPE == "Call" && tw.in_boolean_context()) def.bool_fn++;
|
if (this.TYPE == "Call" && tw.in_boolean_context()) def.bool_fn++;
|
||||||
if (!(def.fixed instanceof AST_Defun)) return;
|
if (!(def.fixed instanceof AST_Defun)) return;
|
||||||
var defun = mark_defun(tw, def);
|
var defun = mark_defun(tw, def);
|
||||||
@@ -768,11 +772,11 @@ merge(Compressor.prototype, {
|
|||||||
defun.walk(tw);
|
defun.walk(tw);
|
||||||
return true;
|
return true;
|
||||||
} else if (this.TYPE == "Call"
|
} else if (this.TYPE == "Call"
|
||||||
&& exp instanceof AST_Assign
|
&& tail instanceof AST_Assign
|
||||||
&& exp.operator == "="
|
&& tail.operator == "="
|
||||||
&& exp.left instanceof AST_SymbolRef
|
&& tail.left instanceof AST_SymbolRef
|
||||||
&& tw.in_boolean_context()) {
|
&& tw.in_boolean_context()) {
|
||||||
exp.left.definition().bool_fn++;
|
tail.left.definition().bool_fn++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
def(AST_Conditional, function(tw) {
|
def(AST_Conditional, function(tw) {
|
||||||
@@ -4681,6 +4685,19 @@ merge(Compressor.prototype, {
|
|||||||
if (!(target instanceof AST_IterationStatement)) insert(target);
|
if (!(target instanceof AST_IterationStatement)) insert(target);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (node instanceof AST_Call) {
|
||||||
|
var exp = node.expression;
|
||||||
|
var tail = exp.tail_node();
|
||||||
|
if (!(tail instanceof AST_Function)) return;
|
||||||
|
if (exp !== tail) exp.expressions.slice(0, -1).forEach(function(node) {
|
||||||
|
node.walk(tw);
|
||||||
|
});
|
||||||
|
node.args.forEach(function(arg) {
|
||||||
|
arg.walk(tw);
|
||||||
|
});
|
||||||
|
tail.walk(tw);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (node instanceof AST_Conditional) {
|
if (node instanceof AST_Conditional) {
|
||||||
node.condition.walk(tw);
|
node.condition.walk(tw);
|
||||||
push();
|
push();
|
||||||
|
|||||||
@@ -1616,3 +1616,34 @@ issue_4308: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4312: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
inline: true,
|
||||||
|
merge_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
(function f(b, c) {
|
||||||
|
return function({
|
||||||
|
[a = b]: d,
|
||||||
|
}) {}(c && c);
|
||||||
|
})("PASS", "FAIL");
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a;
|
||||||
|
b = "PASS",
|
||||||
|
(function({
|
||||||
|
[a = b]: d,
|
||||||
|
}){})((c = "FAIL") && c);
|
||||||
|
var b, c;
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -521,7 +521,7 @@ issue_2531_2: {
|
|||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 3,
|
passes: 2,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -556,9 +556,10 @@ issue_2531_3: {
|
|||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 3,
|
passes: 2,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user