@@ -6096,7 +6096,7 @@ merge(Compressor.prototype, {
|
||||
return !compressor.exposed(def) && def.references.length == def.replaced;
|
||||
} : function(def) {
|
||||
if (!(def.id in in_use_ids)) return true;
|
||||
if (def.orig.length < 2) return false;
|
||||
if (def.orig.length - def.eliminated < 2) return false;
|
||||
// function argument will always overshadow its name
|
||||
if (def.orig[1] instanceof AST_SymbolFunarg) return true;
|
||||
// retain if referenced within destructured object of argument
|
||||
@@ -8551,7 +8551,7 @@ merge(Compressor.prototype, {
|
||||
def.scope = scope;
|
||||
scope.variables.set(def.name, def);
|
||||
}),
|
||||
value: defn.value
|
||||
value: defn.value,
|
||||
});
|
||||
})
|
||||
});
|
||||
@@ -10672,6 +10672,14 @@ merge(Compressor.prototype, {
|
||||
lambda_def.recursive_refs = def.recursive_refs;
|
||||
}
|
||||
value.walk(new TreeWalker(function(node) {
|
||||
if (node instanceof AST_SymbolDeclaration) {
|
||||
if (node !== name) {
|
||||
var def = node.definition();
|
||||
def.orig.push(node);
|
||||
def.eliminated++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!(node instanceof AST_SymbolRef)) return;
|
||||
var def = node.definition();
|
||||
if (def === defun_def) {
|
||||
|
||||
@@ -523,3 +523,55 @@ default_init: {
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
issue_4933_1: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
varify: true,
|
||||
}
|
||||
input: {
|
||||
console.log(f());
|
||||
function f() {
|
||||
var a;
|
||||
for (console in a = [ f ]) {
|
||||
const b = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
console.log(function f() {
|
||||
var a;
|
||||
for (console in a = [ f ]) {
|
||||
const b = a;
|
||||
}
|
||||
}());
|
||||
}
|
||||
expect_stdout: "undefined"
|
||||
}
|
||||
|
||||
issue_4933_2: {
|
||||
options = {
|
||||
passes: 2,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
varify: true,
|
||||
}
|
||||
input: {
|
||||
console.log(f());
|
||||
function f() {
|
||||
var a;
|
||||
for (console in a = [ f ]) {
|
||||
const b = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
console.log(function f() {
|
||||
for (console in [ f ]);
|
||||
}());
|
||||
}
|
||||
expect_stdout: "undefined"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user