@@ -6560,16 +6560,19 @@ Compressor.prototype.compress = function(node) {
|
||||
if (node instanceof AST_SymbolVar) {
|
||||
mark(node);
|
||||
} else {
|
||||
references[node.definition().id] = false;
|
||||
node.walk(tw);
|
||||
}
|
||||
} : function(node) {
|
||||
var id = node.definition().id;
|
||||
if (!(node instanceof AST_SymbolVar)) {
|
||||
references[id] = false;
|
||||
} else if (!(id in references)) {
|
||||
declarations.add(id, node);
|
||||
} else if (references[id]) {
|
||||
references[id].push(node);
|
||||
if (node instanceof AST_SymbolVar) {
|
||||
var id = node.definition().id;
|
||||
var refs = references[id];
|
||||
if (refs) {
|
||||
refs.push(node);
|
||||
} else if (!(id in references)) {
|
||||
declarations.add(id, node);
|
||||
}
|
||||
} else {
|
||||
node.walk(tw);
|
||||
}
|
||||
}, node.name);
|
||||
return true;
|
||||
@@ -6650,8 +6653,8 @@ Compressor.prototype.compress = function(node) {
|
||||
|| (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs)
|
||||
|| compressor.option("webkit") && is_funarg(def) !== is_funarg(head.definition)
|
||||
|| head.definition.const_redefs
|
||||
|| !all(head_refs, function(sym) {
|
||||
return sym.scope.find_variable(def.name) === def;
|
||||
|| !all(head_refs.scopes, function(scope) {
|
||||
return scope.find_variable(def.name) === def;
|
||||
})) {
|
||||
skipped.push(head);
|
||||
continue;
|
||||
@@ -6733,8 +6736,7 @@ Compressor.prototype.compress = function(node) {
|
||||
var refs = references[def.id];
|
||||
if (!refs) return;
|
||||
if (refs.start.block !== seg.block) return references[def.id] = false;
|
||||
sym.scope = find_scope(tw);
|
||||
refs.push(sym);
|
||||
push_ref(sym);
|
||||
refs.end = seg;
|
||||
if (def.id in prev) {
|
||||
last[prev[def.id]] = null;
|
||||
@@ -6748,8 +6750,8 @@ Compressor.prototype.compress = function(node) {
|
||||
return references[def.id] = false;
|
||||
} else {
|
||||
var refs = declarations.get(def.id) || [];
|
||||
sym.scope = find_scope(tw);
|
||||
refs.push(sym);
|
||||
refs.scopes = [];
|
||||
push_ref(sym);
|
||||
references[def.id] = refs;
|
||||
if (!read) {
|
||||
refs.start = seg;
|
||||
@@ -6766,6 +6768,13 @@ Compressor.prototype.compress = function(node) {
|
||||
index: index++,
|
||||
definition: def,
|
||||
});
|
||||
|
||||
function push_ref(sym) {
|
||||
refs.push(sym);
|
||||
push_uniq(refs.scopes, sym.scope);
|
||||
var scope = find_scope(tw);
|
||||
if (scope !== sym.scope) push_uniq(refs.scopes, scope);
|
||||
}
|
||||
}
|
||||
|
||||
function insert(target) {
|
||||
|
||||
@@ -2169,3 +2169,38 @@ issue_5656: {
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
issue_5660: {
|
||||
options = {
|
||||
merge_vars: true,
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
function f() {
|
||||
try {
|
||||
a;
|
||||
var b;
|
||||
return b;
|
||||
} catch (e) {
|
||||
var a = "FAIL";
|
||||
const b = null;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
console.log(f());
|
||||
}
|
||||
expect: {
|
||||
function f() {
|
||||
try {
|
||||
var b;
|
||||
return b;
|
||||
} catch (e) {
|
||||
var a = "FAIL";
|
||||
const b = null;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
console.log(f());
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user