@@ -10928,9 +10928,11 @@ Compressor.prototype.compress = function(node) {
|
||||
&& (value = can_flatten_body(stat))) {
|
||||
var replacing = exp === fn || def.single_use && def.references.length - def.replaced == 1;
|
||||
if (can_substitute_directly()) {
|
||||
self._optimized = true;
|
||||
var retValue = value.optimize(compressor).clone(true);
|
||||
var args = self.args.slice();
|
||||
var refs = [];
|
||||
var retValue = value.optimize(compressor).clone(true).transform(new TreeTransformer(function(node) {
|
||||
retValue = retValue.transform(new TreeTransformer(function(node) {
|
||||
if (node instanceof AST_SymbolRef) {
|
||||
var def = node.definition();
|
||||
if (fn.variables.get(node.name) !== def) {
|
||||
|
||||
@@ -8917,3 +8917,57 @@ issue_5841_2: {
|
||||
"foo",
|
||||
]
|
||||
}
|
||||
|
||||
issue_5851_1: {
|
||||
options = {
|
||||
inline: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
console.log("PASS") && f();
|
||||
function f() {
|
||||
return f();
|
||||
}
|
||||
f;
|
||||
}
|
||||
expect: {
|
||||
console.log("PASS") && f();
|
||||
function f() {
|
||||
return f();
|
||||
}
|
||||
f;
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_5851_2: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
inline: true,
|
||||
passes: 2,
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = f();
|
||||
f();
|
||||
function f() {
|
||||
if (console.log("foo"))
|
||||
console && f();
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
f();
|
||||
f();
|
||||
function f() {
|
||||
console.log("foo") && console && f();
|
||||
}
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"foo",
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user