@@ -3643,8 +3643,8 @@ merge(Compressor.prototype, {
|
||||
if (!(sym.definition().id in in_use_ids)) {
|
||||
sym.__unused = true;
|
||||
if (trim) {
|
||||
log(sym, "Dropping unused function argument {name} [{file}:{line},{col}]", template(sym));
|
||||
a.pop();
|
||||
AST_Node[sym.unreferenced() ? "warn" : "info"]("Dropping unused function argument {name} [{file}:{line},{col}]", template(sym));
|
||||
}
|
||||
} else {
|
||||
trim = false;
|
||||
@@ -3654,7 +3654,7 @@ merge(Compressor.prototype, {
|
||||
if (drop_funcs && node instanceof AST_Defun && node !== self) {
|
||||
var def = node.name.definition();
|
||||
if (!(def.id in in_use_ids)) {
|
||||
AST_Node[node.name.unreferenced() ? "warn" : "info"]("Dropping unused function {name} [{file}:{line},{col}]", template(node.name));
|
||||
log(node.name, "Dropping unused function {name} [{file}:{line},{col}]", template(node.name));
|
||||
def.eliminated++;
|
||||
return make_node(AST_EmptyStatement, node);
|
||||
}
|
||||
@@ -3742,7 +3742,7 @@ merge(Compressor.prototype, {
|
||||
AST_Node.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
side_effects.push(value);
|
||||
} else {
|
||||
AST_Node[def.name.unreferenced() ? "warn" : "info"]("Dropping unused variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
log(def.name, "Dropping unused variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
}
|
||||
sym.eliminated++;
|
||||
}
|
||||
@@ -3820,6 +3820,10 @@ merge(Compressor.prototype, {
|
||||
return node;
|
||||
}
|
||||
|
||||
function log(sym, text, props) {
|
||||
AST_Node[sym.unreferenced() ? "warn" : "info"](text, props);
|
||||
}
|
||||
|
||||
function template(sym) {
|
||||
return {
|
||||
name : sym.name,
|
||||
@@ -5202,7 +5206,7 @@ merge(Compressor.prototype, {
|
||||
if (stat instanceof AST_SimpleStatement) {
|
||||
return make_node(AST_UnaryPrefix, stat, {
|
||||
operator: "void",
|
||||
expression: stat.body.clone(true)
|
||||
expression: stat.body
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3511,7 +3511,7 @@ issue_2437_2: {
|
||||
conditionals: true,
|
||||
inline: true,
|
||||
join_vars: true,
|
||||
passes: 2,
|
||||
passes: 3,
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
sequences: true,
|
||||
|
||||
@@ -3066,7 +3066,7 @@ class_iife: {
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_3400: {
|
||||
issue_3400_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
inline: true,
|
||||
@@ -3096,16 +3096,70 @@ issue_3400: {
|
||||
});
|
||||
}
|
||||
expect: {
|
||||
void console.log(function g() {
|
||||
function e() {
|
||||
return [42].map(function(v) {
|
||||
return o = {
|
||||
p: v
|
||||
}, console.log(o[g]) , o;
|
||||
var o;
|
||||
});
|
||||
void console.log(function() {
|
||||
function g() {
|
||||
function h(u) {
|
||||
var o = {
|
||||
p: u
|
||||
};
|
||||
return console.log(o[g]), o;
|
||||
}
|
||||
function e() {
|
||||
return [ 42 ].map(function(v) {
|
||||
return h(v);
|
||||
});
|
||||
}
|
||||
return e();
|
||||
}
|
||||
return e();
|
||||
return g;
|
||||
}()()[0].p);
|
||||
}
|
||||
expect_stdout: [
|
||||
"undefined",
|
||||
"42",
|
||||
]
|
||||
}
|
||||
|
||||
issue_3400_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
inline: true,
|
||||
passes: 2,
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function(f) {
|
||||
console.log(f()()[0].p);
|
||||
})(function() {
|
||||
function g() {
|
||||
function h(u) {
|
||||
var o = {
|
||||
p: u
|
||||
};
|
||||
return console.log(o[g]), o;
|
||||
}
|
||||
function e() {
|
||||
return [ 42 ].map(function(v) {
|
||||
return h(v);
|
||||
});
|
||||
}
|
||||
return e();
|
||||
}
|
||||
return g;
|
||||
});
|
||||
}
|
||||
expect: {
|
||||
void console.log(function g() {
|
||||
return [ 42 ].map(function(v) {
|
||||
return function(u) {
|
||||
var o = {
|
||||
p: u
|
||||
};
|
||||
return console.log(o[g]), o;
|
||||
}(v);
|
||||
});
|
||||
}()[0].p);
|
||||
}
|
||||
expect_stdout: [
|
||||
@@ -3196,3 +3250,93 @@ issue_3444: {
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_3506_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = "FAIL";
|
||||
(function(b) {
|
||||
(function(b) {
|
||||
b && (a = "PASS");
|
||||
})(b);
|
||||
})(a);
|
||||
console.log(a);
|
||||
}
|
||||
expect: {
|
||||
var a = "FAIL";
|
||||
!function(b) {
|
||||
b && (a = "PASS");
|
||||
}(a);
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_3506_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = "FAIL";
|
||||
(function(b) {
|
||||
(function(c) {
|
||||
var d = 1;
|
||||
for (;c && (a = "PASS") && 0 < --d;);
|
||||
})(b);
|
||||
})(a);
|
||||
console.log(a);
|
||||
}
|
||||
expect: {
|
||||
var a = "FAIL";
|
||||
!function(c) {
|
||||
var d = 1;
|
||||
for (;c && (a = "PASS") && 0 < --d;);
|
||||
}(a);
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_3506_3: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
loops: true,
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = "FAIL";
|
||||
(function(b) {
|
||||
(function(c) {
|
||||
var d = 1;
|
||||
for (;c && (a = "PASS") && 0 < --d;);
|
||||
})(b);
|
||||
})(a);
|
||||
console.log(a);
|
||||
}
|
||||
expect: {
|
||||
var a = "FAIL";
|
||||
!function(c) {
|
||||
var d = 1;
|
||||
for (;c && (a = "PASS") && 0 < --d;);
|
||||
}(a);
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
@@ -1193,6 +1193,7 @@ issue_3427: {
|
||||
assignments: true,
|
||||
collapse_vars: true,
|
||||
inline: true,
|
||||
passes: 2,
|
||||
pure_getters: "strict",
|
||||
sequences: true,
|
||||
side_effects: true,
|
||||
@@ -1206,4 +1207,5 @@ issue_3427: {
|
||||
})(a || (a = {}));
|
||||
}
|
||||
expect: {}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
@@ -6609,10 +6609,10 @@ issues_3267_1: {
|
||||
}
|
||||
expect: {
|
||||
!function(i) {
|
||||
if (i)
|
||||
if (Object())
|
||||
return console.log("PASS");
|
||||
throw "FAIL";
|
||||
}(Object());
|
||||
}();
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user