enhance unused (#4129)
This commit is contained in:
@@ -4747,6 +4747,13 @@ merge(Compressor.prototype, {
|
||||
}));
|
||||
}
|
||||
}
|
||||
} else if (node instanceof AST_UnaryPostfix
|
||||
&& node.expression instanceof AST_SymbolRef
|
||||
&& indexOf_assign(node.expression.definition(), node) < 0) {
|
||||
return make_node(AST_UnaryPrefix, node, {
|
||||
operator: "+",
|
||||
expression: node.expression
|
||||
});
|
||||
}
|
||||
}
|
||||
if (node instanceof AST_Call) calls_to_drop_args.push(node);
|
||||
|
||||
@@ -62,18 +62,18 @@ collapse_vars_side_effects_1: {
|
||||
expect: {
|
||||
function f1() {
|
||||
var s = "abcdef", i = 2;
|
||||
console.log.bind(console)(s.charAt(i++), s.charAt(i++), s.charAt(4), 7);
|
||||
console.log.bind(console)(s.charAt(i++), s.charAt(+i), s.charAt(4), 7);
|
||||
}
|
||||
function f2() {
|
||||
var s = "abcdef", i = 2;
|
||||
console.log.bind(console)(s.charAt(i++), 5, s.charAt(i++), s.charAt(i++), 7);
|
||||
console.log.bind(console)(s.charAt(i++), 5, s.charAt(i++), s.charAt(+i), 7);
|
||||
}
|
||||
function f3() {
|
||||
var s = "abcdef",
|
||||
i = 2,
|
||||
log = console.log.bind(console),
|
||||
x = s.charAt(i++),
|
||||
y = s.charAt(i++);
|
||||
y = s.charAt(+i);
|
||||
log(x, s.charAt(4), y, 7);
|
||||
}
|
||||
function f4() {
|
||||
@@ -3073,7 +3073,6 @@ issue_2298: {
|
||||
expect: {
|
||||
!function() {
|
||||
(function() {
|
||||
0;
|
||||
try {
|
||||
!function(b) {
|
||||
(void 0)[1] = "foo";
|
||||
|
||||
@@ -1730,7 +1730,7 @@ chained_3: {
|
||||
expect: {
|
||||
console.log(function(a, b) {
|
||||
var c = b;
|
||||
b++;
|
||||
+b;
|
||||
return c;
|
||||
}(0, 2));
|
||||
}
|
||||
@@ -2737,7 +2737,7 @@ issue_3962_1: {
|
||||
0..toString();
|
||||
} while (0);
|
||||
if (c) console.log("PASS");
|
||||
}((a--, 1)), 0);
|
||||
}(1), 0);
|
||||
void 0;
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
@@ -2770,7 +2770,7 @@ issue_3962_2: {
|
||||
0..toString();
|
||||
} while (0);
|
||||
if (c) console.log("PASS");
|
||||
}((a--, 1)), 0);
|
||||
}(1), 0);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
@@ -2853,11 +2853,11 @@ issue_4025: {
|
||||
console.log(a, b, d);
|
||||
}
|
||||
expect: {
|
||||
var d, c = 0;
|
||||
var c = 0;
|
||||
try {
|
||||
console.log(c);
|
||||
} finally {
|
||||
d = c + 1;
|
||||
var d = c + 1;
|
||||
c = 0;
|
||||
}
|
||||
console.log(1, 1, d);
|
||||
|
||||
@@ -306,7 +306,6 @@ issue_2298: {
|
||||
expect: {
|
||||
!function() {
|
||||
(function() {
|
||||
0;
|
||||
try {
|
||||
!function() {
|
||||
(void 0)[1] = "foo";
|
||||
|
||||
@@ -120,7 +120,7 @@ modified: {
|
||||
expect: {
|
||||
function f0() {
|
||||
var b = 2;
|
||||
b++;
|
||||
+b;
|
||||
console.log(2);
|
||||
console.log(4);
|
||||
}
|
||||
@@ -5590,7 +5590,7 @@ lvalues_def_1: {
|
||||
}
|
||||
expect: {
|
||||
var b = 1;
|
||||
var a = b++, b = NaN;
|
||||
var a = +b, b = NaN;
|
||||
console.log(a, b);
|
||||
}
|
||||
expect_stdout: "1 NaN"
|
||||
|
||||
Reference in New Issue
Block a user