fix corner case in dead_code (#4984)
This commit is contained in:
@@ -11085,9 +11085,7 @@ merge(Compressor.prototype, {
|
|||||||
]).optimize(compressor);
|
]).optimize(compressor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (self.left instanceof AST_SymbolRef && all(self.left.definition().orig, function(sym) {
|
} else if (self.left instanceof AST_SymbolRef && can_drop_symbol(self.left, compressor)) {
|
||||||
return !(sym instanceof AST_SymbolConst);
|
|
||||||
})) {
|
|
||||||
var parent;
|
var parent;
|
||||||
if (self.operator == "=" && self.left.equivalent_to(self.right)
|
if (self.operator == "=" && self.left.equivalent_to(self.right)
|
||||||
&& !((parent = compressor.parent()) instanceof AST_UnaryPrefix && parent.operator == "delete")) {
|
&& !((parent = compressor.parent()) instanceof AST_UnaryPrefix && parent.operator == "delete")) {
|
||||||
|
|||||||
@@ -20,6 +20,39 @@ retain_block: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retain_assignment: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
function f() {
|
||||||
|
return a = 0;
|
||||||
|
let a;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
f();
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
function f() {
|
||||||
|
return a = 0;
|
||||||
|
let a;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
f();
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
retain_catch: {
|
retain_catch: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
@@ -897,6 +930,7 @@ issue_4210: {
|
|||||||
issue_4212_1: {
|
issue_4212_1: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
reduce_vars: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|||||||
Reference in New Issue
Block a user