@@ -381,7 +381,10 @@ merge(Compressor.prototype, {
|
|||||||
&& node.operator == "="
|
&& node.operator == "="
|
||||||
&& node.left instanceof AST_SymbolRef) {
|
&& node.left instanceof AST_SymbolRef) {
|
||||||
var d = node.left.definition();
|
var d = node.left.definition();
|
||||||
if (safe_to_assign(d, node.right)) {
|
if (safe_to_assign(d, node.right)
|
||||||
|
|| d.fixed === undefined && all(d.orig, function(sym) {
|
||||||
|
return sym instanceof AST_SymbolVar;
|
||||||
|
})) {
|
||||||
d.references.push(node.left);
|
d.references.push(node.left);
|
||||||
d.fixed = function() {
|
d.fixed = function() {
|
||||||
return node.right;
|
return node.right;
|
||||||
@@ -561,9 +564,9 @@ merge(Compressor.prototype, {
|
|||||||
if (!safe_to_read(def)) return false;
|
if (!safe_to_read(def)) return false;
|
||||||
if (def.fixed === false) return false;
|
if (def.fixed === false) return false;
|
||||||
if (def.fixed != null && (!value || def.references.length > 0)) return false;
|
if (def.fixed != null && (!value || def.references.length > 0)) return false;
|
||||||
return !def.orig.some(function(sym) {
|
return all(def.orig, function(sym) {
|
||||||
return sym instanceof AST_SymbolDefun
|
return !(sym instanceof AST_SymbolDefun
|
||||||
|| sym instanceof AST_SymbolLambda;
|
|| sym instanceof AST_SymbolLambda);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4784,3 +4784,57 @@ escape_local_throw: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inverted_var: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 3,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
var a = 1;
|
||||||
|
return a;
|
||||||
|
}(), function() {
|
||||||
|
var b;
|
||||||
|
b = 2;
|
||||||
|
return b;
|
||||||
|
}(), function() {
|
||||||
|
c = 3;
|
||||||
|
return c;
|
||||||
|
var c;
|
||||||
|
}(), function(c) {
|
||||||
|
c = 4;
|
||||||
|
return c;
|
||||||
|
}(), function (c) {
|
||||||
|
c = 5;
|
||||||
|
return c;
|
||||||
|
var c;
|
||||||
|
}(), function c() {
|
||||||
|
c = 6;
|
||||||
|
return c;
|
||||||
|
}(), function c() {
|
||||||
|
c = 7;
|
||||||
|
return c;
|
||||||
|
var c;
|
||||||
|
}(), function() {
|
||||||
|
c = 8;
|
||||||
|
return c;
|
||||||
|
var c = "foo";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(1, 2, 3, 4, 5, function c() {
|
||||||
|
c = 6;
|
||||||
|
return c;
|
||||||
|
}(), 7, function() {
|
||||||
|
c = 8;
|
||||||
|
return c;
|
||||||
|
var c = "foo";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user