@@ -786,7 +786,10 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
var d = sym.definition();
|
var d = sym.definition();
|
||||||
d.assignments++;
|
d.assignments++;
|
||||||
if (fixed && !is_modified(compressor, tw, node, node.right, 0) && safe_to_assign(tw, d)) {
|
if (fixed
|
||||||
|
&& !is_modified(compressor, tw, node, node.right, 0)
|
||||||
|
&& !sym.in_arg
|
||||||
|
&& safe_to_assign(tw, d)) {
|
||||||
push_ref(d, sym);
|
push_ref(d, sym);
|
||||||
mark(tw, d);
|
mark(tw, d);
|
||||||
if (d.single_use && left instanceof AST_Destructured) d.single_use = false;
|
if (d.single_use && left instanceof AST_Destructured) d.single_use = false;
|
||||||
@@ -809,7 +812,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
var safe = safe_to_read(tw, d);
|
var safe = safe_to_read(tw, d);
|
||||||
node.right.walk(tw);
|
node.right.walk(tw);
|
||||||
if (safe && safe_to_assign(tw, d)) {
|
if (safe && !left.in_arg && safe_to_assign(tw, d)) {
|
||||||
push_ref(d, left);
|
push_ref(d, left);
|
||||||
mark(tw, d);
|
mark(tw, d);
|
||||||
if (d.single_use) d.single_use = false;
|
if (d.single_use) d.single_use = false;
|
||||||
@@ -1117,7 +1120,7 @@ merge(Compressor.prototype, {
|
|||||||
var d = exp.definition();
|
var d = exp.definition();
|
||||||
d.assignments++;
|
d.assignments++;
|
||||||
var fixed = d.fixed;
|
var fixed = d.fixed;
|
||||||
if (safe_to_read(tw, d) && safe_to_assign(tw, d)) {
|
if (safe_to_read(tw, d) && !exp.in_arg && safe_to_assign(tw, d)) {
|
||||||
push_ref(d, exp);
|
push_ref(d, exp);
|
||||||
mark(tw, d);
|
mark(tw, d);
|
||||||
if (d.single_use) d.single_use = false;
|
if (d.single_use) d.single_use = false;
|
||||||
|
|||||||
@@ -2487,3 +2487,30 @@ issue_4554: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4584: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
try {
|
||||||
|
(function f({
|
||||||
|
[console.log(a = "FAIL")]: a,
|
||||||
|
}) {})(0);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
try {
|
||||||
|
(function f({
|
||||||
|
[console.log(a = "FAIL")]: a,
|
||||||
|
}) {})(0);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -431,12 +431,18 @@ function createAssignmentPairs(recurmax, stmtDepth, canThrow, nameLenBefore, was
|
|||||||
unique_vars.length = len;
|
unique_vars.length = len;
|
||||||
return pairs;
|
return pairs;
|
||||||
|
|
||||||
function mapShuffled(array, fn) {
|
function mapShuffled(values, fn) {
|
||||||
var result = [];
|
var ordered = [];
|
||||||
for (var i = array.length; --i >= 0;) {
|
var shuffled = [];
|
||||||
result.splice(rng(result.length + 1), 0, fn(array[i], i));
|
values.forEach(function(value, index) {
|
||||||
}
|
value = fn(value, index);
|
||||||
return result;
|
if (/]:/.test(value) ? canThrow && rng(10) == 0 : rng(5)) {
|
||||||
|
shuffled.splice(rng(shuffled.length + 1), 0, value);
|
||||||
|
} else {
|
||||||
|
ordered.push(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return shuffled.concat(ordered);
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertToRest(names) {
|
function convertToRest(names) {
|
||||||
|
|||||||
Reference in New Issue
Block a user