@@ -1820,7 +1820,7 @@ merge(Compressor.prototype, {
|
|||||||
if (is_lhs(node, parent)) {
|
if (is_lhs(node, parent)) {
|
||||||
if (value_def && !hit_rhs) {
|
if (value_def && !hit_rhs) {
|
||||||
assign_used = true;
|
assign_used = true;
|
||||||
replaced++;
|
if (node.definition().last_ref === node) replaced++;
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
} else if (value_def) {
|
} else if (value_def) {
|
||||||
@@ -1946,10 +1946,9 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Replace variable when found
|
// Replace variable when found
|
||||||
if (node instanceof AST_SymbolRef
|
if (node instanceof AST_SymbolRef && node.definition() === def) {
|
||||||
&& node.name == def.name) {
|
|
||||||
if (!--replaced) abort = true;
|
|
||||||
if (is_lhs(node, multi_replacer.parent())) return node;
|
if (is_lhs(node, multi_replacer.parent())) return node;
|
||||||
|
if (!--replaced) abort = true;
|
||||||
var ref = rvalue.clone();
|
var ref = rvalue.clone();
|
||||||
ref.scope = node.scope;
|
ref.scope = node.scope;
|
||||||
ref.reference();
|
ref.reference();
|
||||||
|
|||||||
@@ -4658,6 +4658,7 @@ replace_all_var_scope: {
|
|||||||
rename = true
|
rename = true
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
mangle = {}
|
mangle = {}
|
||||||
@@ -4676,7 +4677,7 @@ replace_all_var_scope: {
|
|||||||
(function(c, o) {
|
(function(c, o) {
|
||||||
switch (~a) {
|
switch (~a) {
|
||||||
case (b += a):
|
case (b += a):
|
||||||
case o++:
|
case +o:
|
||||||
}
|
}
|
||||||
})(--b, a);
|
})(--b, a);
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
@@ -4728,7 +4729,7 @@ cascade_statement: {
|
|||||||
}
|
}
|
||||||
function f3(a, b) {
|
function f3(a, b) {
|
||||||
for (; a < b; a++)
|
for (; a < b; a++)
|
||||||
if (c = a, a && b)
|
if ((c = a) && b)
|
||||||
var c = c = b(a);
|
var c = c = b(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2625,3 +2625,25 @@ issue_4994: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5017: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = function() {};
|
||||||
|
var b = c = a;
|
||||||
|
var c = [ c ] = [ c ];
|
||||||
|
console.log(c[0] === a ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = function() {};
|
||||||
|
var b = a;
|
||||||
|
var c = [ c ] = [ c = a ];
|
||||||
|
console.log(c[0] === a ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1151,6 +1151,7 @@ replace_all_var_scope: {
|
|||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
mangle = {}
|
mangle = {}
|
||||||
@@ -1158,8 +1159,8 @@ replace_all_var_scope: {
|
|||||||
var a = 100, b = 10;
|
var a = 100, b = 10;
|
||||||
(function(r, a) {
|
(function(r, a) {
|
||||||
switch (~a) {
|
switch (~a) {
|
||||||
case (b += a):
|
case (b += a):
|
||||||
case a++:
|
case a++:
|
||||||
}
|
}
|
||||||
})(--b, a);
|
})(--b, a);
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
@@ -1168,8 +1169,8 @@ replace_all_var_scope: {
|
|||||||
var a = 100, b = 10;
|
var a = 100, b = 10;
|
||||||
(function(c) {
|
(function(c) {
|
||||||
switch (~a) {
|
switch (~a) {
|
||||||
case (b += a):
|
case (b += a):
|
||||||
case c++:
|
case +c:
|
||||||
}
|
}
|
||||||
})((--b, a));
|
})((--b, a));
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
|
|||||||
Reference in New Issue
Block a user