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