stop at symbol redefinition
This commit is contained in:
parent
2539db09e8
commit
eb570c4661
|
|
@ -750,7 +750,7 @@ merge(Compressor.prototype, {
|
|||
|| node instanceof AST_SymbolRef
|
||||
&& (lvalues && lvalues[node.name]
|
||||
|| side_effects && !references_in_scope(node.definition()))
|
||||
|| lvalues && (sym = is_lhs(node.left, node)) && get_symbol(sym).name in lvalues
|
||||
|| lvalues && (sym = lhs_or_def(node)) && get_symbol(sym).name in lvalues
|
||||
|| parent instanceof AST_Binary
|
||||
&& (parent.operator == "&&" || parent.operator == "||")
|
||||
|| parent instanceof AST_Case
|
||||
|
|
@ -828,6 +828,11 @@ merge(Compressor.prototype, {
|
|||
return lvalues;
|
||||
}
|
||||
|
||||
function lhs_or_def(node) {
|
||||
if (node instanceof AST_VarDef) return node.value && node.name;
|
||||
return is_lhs(node.left, node);
|
||||
}
|
||||
|
||||
function remove_candidate(expr) {
|
||||
var found = false;
|
||||
return statements[stat_index].transform(new TreeTransformer(function(node, descend, in_list) {
|
||||
|
|
|
|||
|
|
@ -2146,3 +2146,24 @@ issue_315: {
|
|||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
lvalues_def: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
side_effects: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = 0, b = 1;
|
||||
var a = b++, b = +function() {}();
|
||||
a && a[a++];
|
||||
console.log(a, b);
|
||||
}
|
||||
expect: {
|
||||
var a = 0, b = 1;
|
||||
var a = b++, b = +void 0;
|
||||
a && a[a++];
|
||||
console.log(a, b);
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user