fix destructuring bugs in mangle and compress (#1992)

- destructuring mangle
- destructuring array default values

fixes #1335
This commit is contained in:
kzc
2017-05-22 14:53:01 -04:00
committed by Alex Lam S.L
parent a658cd84a5
commit 7bcb442e4c
3 changed files with 146 additions and 5 deletions

View File

@@ -2097,9 +2097,6 @@ merge(Compressor.prototype, {
}));
}
}
else if (node.names[i] instanceof AST_Hole) {
continue;
}
else if (node.names[i] instanceof AST_ObjectKeyVal) {
if (typeof node.names[i].key === "string") {
initializations.add(node.names[i].key, destructuring_value);
@@ -2107,7 +2104,14 @@ merge(Compressor.prototype, {
}
else if (node.names[i] instanceof AST_Symbol) {
initializations.add(node.names[i].name, destructuring_value);
} else {
}
else if (node.names[i] instanceof AST_DefaultAssign) {
continue;
}
else if (node.names[i] instanceof AST_Hole) {
continue;
}
else {
throw new Error(string_template("Unknown destructuring element of type: {type}", {
type: Object.getPrototypeOf(node.names[i]).TYPE
}));