enhance dead_code (#3849)
This commit is contained in:
@@ -7670,6 +7670,11 @@ merge(Compressor.prototype, {
|
|||||||
if (is_reachable(scope, [ def ])) break;
|
if (is_reachable(scope, [ def ])) break;
|
||||||
def.fixed = false;
|
def.fixed = false;
|
||||||
return strip_assignment();
|
return strip_assignment();
|
||||||
|
} else if (parent instanceof AST_VarDef) {
|
||||||
|
if (parent.name.definition() !== def) continue;
|
||||||
|
if (in_try(level, parent)) break;
|
||||||
|
def.fixed = false;
|
||||||
|
return strip_assignment();
|
||||||
}
|
}
|
||||||
} while (parent instanceof AST_Binary && parent.right === node
|
} while (parent instanceof AST_Binary && parent.right === node
|
||||||
|| parent instanceof AST_Sequence && parent.tail_node() === node
|
|| parent instanceof AST_Sequence && parent.tail_node() === node
|
||||||
|
|||||||
@@ -1151,3 +1151,20 @@ issue_3830_6: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redundant_assignments: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = a = "PASS", b = "FAIL";
|
||||||
|
b = b = "PASS";
|
||||||
|
console.log(a, b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS", b = "FAIL";
|
||||||
|
b = "PASS";
|
||||||
|
console.log(a, b);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user