fix corner case in reduce_vars (#4095)
This commit is contained in:
@@ -7779,7 +7779,7 @@ merge(Compressor.prototype, {
|
||||
single_use = false;
|
||||
} else if (recursive_ref(compressor, def)) {
|
||||
single_use = false;
|
||||
} else if (compressor.option("ie8") && fixed.name && def !== fixed.name.definition()) {
|
||||
} else if (fixed.name && fixed.name.definition() !== def) {
|
||||
single_use = false;
|
||||
} else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
|
||||
single_use = fixed.is_constant_expression(self.scope);
|
||||
|
||||
@@ -1624,7 +1624,7 @@ defun_label: {
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
double_reference: {
|
||||
double_reference_1: {
|
||||
options = {
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
@@ -1638,6 +1638,32 @@ double_reference: {
|
||||
g();
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
function f() {
|
||||
var g = function g() {
|
||||
g();
|
||||
};
|
||||
g();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double_reference_2: {
|
||||
options = {
|
||||
functions: true,
|
||||
passes: 2,
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function f() {
|
||||
var g = function g() {
|
||||
g();
|
||||
};
|
||||
g();
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
function f() {
|
||||
(function g() {
|
||||
@@ -1647,6 +1673,60 @@ double_reference: {
|
||||
}
|
||||
}
|
||||
|
||||
double_reference_3: {
|
||||
options = {
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var x = function f() {
|
||||
return f;
|
||||
};
|
||||
function g() {
|
||||
return x();
|
||||
}
|
||||
console.log(g() === g());
|
||||
}
|
||||
expect: {
|
||||
var x = function f() {
|
||||
return f;
|
||||
};
|
||||
function g() {
|
||||
return x();
|
||||
}
|
||||
console.log(g() === g());
|
||||
}
|
||||
expect_stdout: "true"
|
||||
}
|
||||
|
||||
double_reference_4: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
functions: true,
|
||||
inline: true,
|
||||
passes: 2,
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var x = function f() {
|
||||
return f;
|
||||
};
|
||||
function g() {
|
||||
return x();
|
||||
}
|
||||
console.log(g() === g());
|
||||
}
|
||||
expect: {
|
||||
console.log(true);
|
||||
}
|
||||
expect_stdout: "true"
|
||||
}
|
||||
|
||||
iife_arguments_1: {
|
||||
options = {
|
||||
reduce_funcs: true,
|
||||
@@ -1686,8 +1766,35 @@ iife_arguments_2: {
|
||||
}
|
||||
expect: {
|
||||
(function() {
|
||||
console.log(function f() {
|
||||
var x = function f() {
|
||||
return f;
|
||||
};
|
||||
console.log(x() === arguments[0]);
|
||||
})();
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
iife_arguments_3: {
|
||||
options = {
|
||||
functions: true,
|
||||
passes: 2,
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function() {
|
||||
var x = function f() {
|
||||
return f;
|
||||
};
|
||||
console.log(x() === arguments[0]);
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
(function() {
|
||||
console.log(function x() {
|
||||
return x;
|
||||
}() === arguments[0]);
|
||||
})();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user