@@ -1194,11 +1194,20 @@ merge(Compressor.prototype, {
|
||||
def(AST_SymbolRef, function(tw, descend, compressor) {
|
||||
var d = this.definition();
|
||||
push_ref(d, this);
|
||||
if (d.references.length == 1
|
||||
&& !d.fixed
|
||||
&& d.orig[0] instanceof AST_SymbolDefun) {
|
||||
if (d.references.length == 1 && !d.fixed && d.orig[0] instanceof AST_SymbolDefun) {
|
||||
tw.loop_ids[d.id] = tw.in_loop;
|
||||
}
|
||||
var recursive = recursive_ref(tw, d);
|
||||
if (recursive) recursive.enclosed.forEach(function(def) {
|
||||
if (d === def) return;
|
||||
if (def.scope === recursive) return;
|
||||
var assigns = def.fixed && def.fixed.assigns;
|
||||
if (!assigns) return;
|
||||
if (assigns[assigns.length - 1] instanceof AST_VarDef) return;
|
||||
var safe = tw.safe_ids[def.id];
|
||||
if (!safe) return;
|
||||
safe.assign = true;
|
||||
});
|
||||
if (d.fixed === false) {
|
||||
var redef = d.redefined();
|
||||
if (redef && cross_scope(d.scope, this.scope)) redef.single_use = false;
|
||||
@@ -1207,7 +1216,6 @@ merge(Compressor.prototype, {
|
||||
} else if (d.fixed) {
|
||||
if (this.in_arg && d.orig[0] instanceof AST_SymbolLambda) this.fixed = d.scope;
|
||||
var value = this.fixed_value();
|
||||
var recursive = recursive_ref(tw, d);
|
||||
if (recursive) {
|
||||
d.recursive_refs++;
|
||||
} else if (value && ref_once(compressor, d)) {
|
||||
@@ -1228,9 +1236,7 @@ merge(Compressor.prototype, {
|
||||
d.fixed = false;
|
||||
}
|
||||
}
|
||||
if (d.fixed && tw.loop_ids[d.id] !== tw.in_loop) {
|
||||
d.cross_loop = true;
|
||||
}
|
||||
if (d.fixed && tw.loop_ids[d.id] !== tw.in_loop) d.cross_loop = true;
|
||||
mark_escaped(tw, d, this.scope, this, value, 0, 1);
|
||||
}
|
||||
if (!this.fixed) this.fixed = d.fixed;
|
||||
|
||||
@@ -7662,3 +7662,63 @@ issue_4937: {
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_4943_1: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var a, b = 1;
|
||||
(function f() {
|
||||
a = "foo";
|
||||
b-- && f();
|
||||
console.log(a);
|
||||
a = "bar";
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
var a, b = 1;
|
||||
(function f() {
|
||||
a = "foo";
|
||||
b-- && f();
|
||||
console.log(a);
|
||||
a = "bar";
|
||||
})();
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar",
|
||||
]
|
||||
}
|
||||
|
||||
issue_4943_2: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a, b = 1;
|
||||
(function f() {
|
||||
a = "foo";
|
||||
b-- && f();
|
||||
console.log(a);
|
||||
a = "bar";
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
var a, b = 1;
|
||||
(function f() {
|
||||
a = "foo";
|
||||
b-- && f();
|
||||
console.log(a);
|
||||
a = "bar";
|
||||
})();
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar",
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user