@@ -6662,15 +6662,15 @@ Compressor.prototype.compress = function(node) {
|
|||||||
do {
|
do {
|
||||||
var head = first.shift();
|
var head = first.shift();
|
||||||
if (tail.index > head.index) continue;
|
if (tail.index > head.index) continue;
|
||||||
var id = head.definition.id;
|
var prev_def = head.definition;
|
||||||
if (!(id in prev)) continue;
|
if (!(prev_def.id in prev)) continue;
|
||||||
var head_refs = references[id];
|
var head_refs = references[prev_def.id];
|
||||||
if (!head_refs) continue;
|
if (!head_refs) continue;
|
||||||
if (head_refs.start.block !== tail_refs.start.block
|
if (head_refs.start.block !== tail_refs.start.block
|
||||||
|| !mergeable(head_refs, tail_refs)
|
|| !mergeable(head_refs, tail_refs)
|
||||||
|| (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs)
|
|| (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs)
|
||||||
|| compressor.option("webkit") && is_funarg(def) !== is_funarg(head.definition)
|
|| compressor.option("webkit") && is_funarg(def) !== is_funarg(prev_def)
|
||||||
|| head.definition.const_redefs
|
|| prev_def.const_redefs
|
||||||
|| !all(head_refs.scopes, function(scope) {
|
|| !all(head_refs.scopes, function(scope) {
|
||||||
return scope.find_variable(def.name) === def;
|
return scope.find_variable(def.name) === def;
|
||||||
})) {
|
})) {
|
||||||
@@ -6682,12 +6682,14 @@ Compressor.prototype.compress = function(node) {
|
|||||||
sym.name = def.name;
|
sym.name = def.name;
|
||||||
if (sym instanceof AST_SymbolRef) {
|
if (sym instanceof AST_SymbolRef) {
|
||||||
def.references.push(sym);
|
def.references.push(sym);
|
||||||
|
prev_def.replaced++;
|
||||||
} else {
|
} else {
|
||||||
def.orig.push(sym);
|
def.orig.push(sym);
|
||||||
|
prev_def.eliminated++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!head.definition.fixed) def.fixed = false;
|
if (!prev_def.fixed) def.fixed = false;
|
||||||
merged[id] = def;
|
merged[prev_def.id] = def;
|
||||||
changed = true;
|
changed = true;
|
||||||
break;
|
break;
|
||||||
} while (first.length);
|
} while (first.length);
|
||||||
|
|||||||
@@ -3845,3 +3845,47 @@ issue_5471_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5714: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
join_vars: true,
|
||||||
|
loops: true,
|
||||||
|
merge_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
console.log(function() {
|
||||||
|
var i = 1;
|
||||||
|
while (i--) {
|
||||||
|
var a = function f(b) {
|
||||||
|
console.log(b);
|
||||||
|
var c = function(d) {
|
||||||
|
console.log(typeof d);
|
||||||
|
}(console);
|
||||||
|
}();
|
||||||
|
var e = 42;
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
console.log(function() {
|
||||||
|
for (var i = 1; i--;) {
|
||||||
|
var b = void 0;
|
||||||
|
console.log(b);
|
||||||
|
b = console,
|
||||||
|
console.log(typeof b);
|
||||||
|
var e = 42;
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined",
|
||||||
|
"object",
|
||||||
|
"42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user