enhance reduce_vars (#4479)
This commit is contained in:
@@ -771,8 +771,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
var d = sym.definition();
|
var d = sym.definition();
|
||||||
d.assignments++;
|
d.assignments++;
|
||||||
if (!is_modified(compressor, tw, node, node.right, 0)
|
if (!is_modified(compressor, tw, node, node.right, 0) && safe_to_assign(tw, d)) {
|
||||||
&& can_drop_symbol(sym) && safe_to_assign(tw, d)) {
|
|
||||||
push_ref(d, sym);
|
push_ref(d, sym);
|
||||||
mark(tw, d);
|
mark(tw, d);
|
||||||
if (d.single_use && left instanceof AST_Destructured) d.single_use = false;
|
if (d.single_use && left instanceof AST_Destructured) d.single_use = false;
|
||||||
|
|||||||
@@ -359,6 +359,28 @@ reduce_block_2_toplevel: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reduce_vars: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
let a = "PASS";
|
||||||
|
console.log(a);
|
||||||
|
a = "FAIL";
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
console.log("PASS");
|
||||||
|
"FAIL";
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
hoist_props: {
|
hoist_props: {
|
||||||
options = {
|
options = {
|
||||||
hoist_props: true,
|
hoist_props: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user