@@ -620,7 +620,7 @@ merge(Compressor.prototype, {
|
|||||||
var save = fixed;
|
var save = fixed;
|
||||||
if (save) fixed = function() {
|
if (save) fixed = function() {
|
||||||
var value = save();
|
var value = save();
|
||||||
return is_undefined(value) ? make_sequence(node, [ value, node.value ]) : node.name;
|
return is_undefined(value) ? make_sequence(node, [ value, node.value ]) : node;
|
||||||
};
|
};
|
||||||
node.name.walk(scanner);
|
node.name.walk(scanner);
|
||||||
fixed = save;
|
fixed = save;
|
||||||
@@ -646,7 +646,7 @@ merge(Compressor.prototype, {
|
|||||||
var value = save();
|
var value = save();
|
||||||
return value instanceof AST_Array ? make_node(AST_Array, node, {
|
return value instanceof AST_Array ? make_node(AST_Array, node, {
|
||||||
elements: value.elements.slice(node.elements.length),
|
elements: value.elements.slice(node.elements.length),
|
||||||
}) : node.rest;
|
}) : node;
|
||||||
};
|
};
|
||||||
node.rest.walk(scanner);
|
node.rest.walk(scanner);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -646,3 +646,20 @@ issue_4544_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4562: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
rests: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log((([ ...[ a ] ]) => a)("foo"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log((([ a ]) => a)("foo"));
|
||||||
|
}
|
||||||
|
expect_stdout: "f"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
// (beautified)
|
// (beautified)
|
||||||
try {
|
try {
|
||||||
1 in 0;
|
1 in 0;
|
||||||
} catch ({
|
} catch (message) {
|
||||||
message: message
|
|
||||||
}) {
|
|
||||||
console.log(message);
|
console.log(message);
|
||||||
}
|
}
|
||||||
// output: Cannot use 'in' operator to search for '1' in 0
|
// output: TypeError: Cannot use 'in' operator to search for '1' in 0
|
||||||
//
|
//
|
||||||
// minify: Cannot use 'in' operator to search for '0' in 0
|
// minify: TypeError: Cannot use 'in' operator to search for '0' in 0
|
||||||
//
|
//
|
||||||
// options: {
|
// options: {
|
||||||
// "mangle": false
|
// "mangle": false
|
||||||
|
|||||||
@@ -104,15 +104,14 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
|
|
||||||
// quick ignores
|
// quick ignores
|
||||||
if (node instanceof U.AST_Accessor) return;
|
if (node instanceof U.AST_Accessor) return;
|
||||||
if (node instanceof U.AST_Destructured) return;
|
|
||||||
if (node instanceof U.AST_Directive) return;
|
if (node instanceof U.AST_Directive) return;
|
||||||
if (!in_list && node instanceof U.AST_EmptyStatement) return;
|
if (!in_list && node instanceof U.AST_EmptyStatement) return;
|
||||||
if (node instanceof U.AST_Label) return;
|
if (node instanceof U.AST_Label) return;
|
||||||
if (node instanceof U.AST_LabelRef) return;
|
if (node instanceof U.AST_LabelRef) return;
|
||||||
if (!in_list && node instanceof U.AST_SymbolDeclaration) return;
|
|
||||||
if (node instanceof U.AST_Toplevel) return;
|
if (node instanceof U.AST_Toplevel) return;
|
||||||
var parent = tt.parent();
|
var parent = tt.parent();
|
||||||
if (node instanceof U.AST_SymbolFunarg && parent instanceof U.AST_Accessor) return;
|
if (node instanceof U.AST_SymbolFunarg && parent instanceof U.AST_Accessor) return;
|
||||||
|
if (!in_list && parent.rest !== node && node instanceof U.AST_SymbolDeclaration) return;
|
||||||
|
|
||||||
// ensure that the _permute prop is a number.
|
// ensure that the _permute prop is a number.
|
||||||
// can not use `node.start._permute |= 0;` as it will erase fractional part.
|
// can not use `node.start._permute |= 0;` as it will erase fractional part.
|
||||||
@@ -124,6 +123,7 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
|
|
||||||
// ignore lvalues
|
// ignore lvalues
|
||||||
if (parent instanceof U.AST_Assign && parent.left === node) return;
|
if (parent instanceof U.AST_Assign && parent.left === node) return;
|
||||||
|
if (parent instanceof U.AST_DefaultValue && parent.name === node) return;
|
||||||
if (parent instanceof U.AST_DestructuredKeyVal && parent.value === node) return;
|
if (parent instanceof U.AST_DestructuredKeyVal && parent.value === node) return;
|
||||||
if (parent instanceof U.AST_Unary && parent.expression === node) switch (parent.operator) {
|
if (parent instanceof U.AST_Unary && parent.expression === node) switch (parent.operator) {
|
||||||
case "++":
|
case "++":
|
||||||
@@ -229,6 +229,23 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
return node.name;
|
return node.name;
|
||||||
}
|
}
|
||||||
|
else if (node instanceof U.AST_DestructuredArray) {
|
||||||
|
var expr = node.elements[0];
|
||||||
|
if (expr && !(expr instanceof U.AST_Hole)) {
|
||||||
|
node.start._permute++;
|
||||||
|
CHANGED = true;
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (node instanceof U.AST_DestructuredObject) {
|
||||||
|
// first property's value
|
||||||
|
var expr = node.properties[0];
|
||||||
|
if (expr) {
|
||||||
|
node.start._permute++;
|
||||||
|
CHANGED = true;
|
||||||
|
return expr.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (node instanceof U.AST_Defun) {
|
else if (node instanceof U.AST_Defun) {
|
||||||
switch (((node.start._permute += step) * steps | 0) % 2) {
|
switch (((node.start._permute += step) * steps | 0) % 2) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -443,15 +460,6 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
return List.skip;
|
return List.skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip element/property from (destructured) array/object
|
|
||||||
if (parent instanceof U.AST_Array
|
|
||||||
|| parent instanceof U.AST_Destructured
|
|
||||||
|| parent instanceof U.AST_Object) {
|
|
||||||
node.start._permute++;
|
|
||||||
CHANGED = true;
|
|
||||||
return List.skip;
|
|
||||||
}
|
|
||||||
} else if (parent.rest === node) {
|
} else if (parent.rest === node) {
|
||||||
node.start._permute++;
|
node.start._permute++;
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user