@@ -1884,9 +1884,17 @@ merge(Compressor.prototype, {
|
||||
&& node.name == def.name) {
|
||||
if (!--replaced) abort = true;
|
||||
if (is_lhs(node, multi_replacer.parent())) return node;
|
||||
def.replaced++;
|
||||
var ref = rvalue.clone();
|
||||
value_def.references.push(ref);
|
||||
if (abort && candidate instanceof AST_Assign
|
||||
&& def.references.length - def.replaced - (assignments[def.name] || 0) > 1) {
|
||||
return make_node(AST_Assign, candidate, {
|
||||
operator: "=",
|
||||
left: node,
|
||||
right: ref,
|
||||
});
|
||||
}
|
||||
def.replaced++;
|
||||
return ref;
|
||||
}
|
||||
// Skip (non-executed) functions and (leading) default case in switch statements
|
||||
|
||||
@@ -9057,3 +9057,31 @@ issue_4874: {
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_4891: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var a = 0, b;
|
||||
a++;
|
||||
console.log(b = a, b);
|
||||
b--;
|
||||
a.a += 0;
|
||||
console.log(b);
|
||||
}
|
||||
expect: {
|
||||
var a = 0, b;
|
||||
a++;
|
||||
console.log(a, b = a);
|
||||
b--;
|
||||
a.a += 0;
|
||||
console.log(b);
|
||||
}
|
||||
expect_stdout: [
|
||||
"1 1",
|
||||
"0",
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user