@@ -526,7 +526,7 @@ merge(Compressor.prototype, {
|
||||
if (fn.parent_scope.resolve().may_call_this === return_true) return;
|
||||
if (marker) {
|
||||
var visited = member(fn, tw.fn_visited);
|
||||
if (marker === tw.safe_ids) return !visited && fn;
|
||||
if (marker === tw.safe_ids) return !visited && walk_fn_def(tw, fn);
|
||||
if (visited) {
|
||||
fn.enclosed.forEach(function(d) {
|
||||
if (fn.variables.get(d.name) === d) return;
|
||||
@@ -539,7 +539,7 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
} else if (!tw.in_loop && !(tw.fn_scanning && tw.fn_scanning !== def.scope.resolve())) {
|
||||
fn.safe_ids = tw.safe_ids;
|
||||
return fn;
|
||||
return walk_fn_def(tw, fn);
|
||||
}
|
||||
fn.safe_ids = false;
|
||||
}
|
||||
@@ -1013,21 +1013,18 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
}
|
||||
exp.walk(tw);
|
||||
var fixed = exp instanceof AST_SymbolRef && exp.fixed_value();
|
||||
var optional = node.optional;
|
||||
var fn;
|
||||
if (fixed instanceof AST_Lambda) {
|
||||
fn = mark_fn_def(tw, exp.definition(), fixed);
|
||||
optional = false;
|
||||
} else {
|
||||
tw.find_parent(AST_Scope).may_call_this();
|
||||
}
|
||||
if (optional) push(tw);
|
||||
node.args.forEach(function(arg) {
|
||||
arg.walk(tw);
|
||||
});
|
||||
if (optional) pop(tw);
|
||||
if (fn) walk_fn_def(tw, fn);
|
||||
var fixed = exp instanceof AST_SymbolRef && exp.fixed_value();
|
||||
if (fixed instanceof AST_Lambda) {
|
||||
mark_fn_def(tw, exp.definition(), fixed);
|
||||
} else {
|
||||
tw.find_parent(AST_Scope).may_call_this();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
def(AST_Class, function(tw, descend, compressor) {
|
||||
@@ -1283,8 +1280,7 @@ merge(Compressor.prototype, {
|
||||
var parent;
|
||||
if (value instanceof AST_Lambda
|
||||
&& !((parent = tw.parent()) instanceof AST_Call && parent.expression === this)) {
|
||||
var fn = mark_fn_def(tw, d, value);
|
||||
if (fn) walk_fn_def(tw, fn);
|
||||
mark_fn_def(tw, d, value);
|
||||
}
|
||||
});
|
||||
def(AST_Template, function(tw, descend) {
|
||||
@@ -1299,17 +1295,15 @@ merge(Compressor.prototype, {
|
||||
return true;
|
||||
}
|
||||
tag.walk(tw);
|
||||
var fixed = tag instanceof AST_SymbolRef && tag.fixed_value();
|
||||
var fn;
|
||||
if (fixed instanceof AST_Lambda) {
|
||||
fn = mark_fn_def(tw, tag.definition(), fixed);
|
||||
} else {
|
||||
tw.find_parent(AST_Scope).may_call_this();
|
||||
}
|
||||
node.expressions.forEach(function(exp) {
|
||||
exp.walk(tw);
|
||||
});
|
||||
if (fn) walk_fn_def(tw, fn);
|
||||
var fixed = tag instanceof AST_SymbolRef && tag.fixed_value();
|
||||
if (fixed instanceof AST_Lambda) {
|
||||
mark_fn_def(tw, tag.definition(), fixed);
|
||||
} else {
|
||||
tw.find_parent(AST_Scope).may_call_this();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
def(AST_Toplevel, function(tw, descend, compressor) {
|
||||
|
||||
@@ -7696,3 +7696,32 @@ issue_5048: {
|
||||
}
|
||||
expect_stdout: "undefined"
|
||||
}
|
||||
|
||||
issue_5050: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
function f() {
|
||||
console.log(a);
|
||||
}
|
||||
this;
|
||||
var a = 1;
|
||||
f(console.log(2), f(), a = 3);
|
||||
}
|
||||
expect: {
|
||||
function f() {
|
||||
console.log(a);
|
||||
}
|
||||
this;
|
||||
var a = 1;
|
||||
f(console.log(2), f(), a = 3);
|
||||
}
|
||||
expect_stdout: [
|
||||
"2",
|
||||
"1",
|
||||
"3",
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user