Repository: babel/minify (js)

Issue:
Incorrect minification within try block and destructuring
This function is incorrectly minified.  It happens when using 2 variables and not using one:

```js
async function example() {
  var foo, bar;
  try {
    [foo, bar] = await Promise.all([req(1), req(2)]);
  } catch(e) {}
  console.log(foo);
}
```

**Actual Output**
foo and bar and ignored, so the output is broken

```js
async function example() {
  var a;
  try {
    await Promise.all([req(1), req(2)]);
  } catch (c) {}
  console.log(a);
}
```


See it here:

https://babeljs.io/repl/#?babili=true&browsers=&build=&builtIns=false&code_lz=IYZwngdgxgBAZgV2gFwJYHsIwKYA9gC2ADgDbYAUAlDAN4BQMMAbsAE7zroA0MARmwG4GMZKzC1hjANpxOPfqwC6MALwxgAd2CpkMAAqt0BVCGwA6YCRLkprbAEdyARko87jgEyVFlIYwC-MFDAyFAAFuTY1DT-wlCYIOhkZiToAObksui-dP5AA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&lineWrap=false&presets=babili&prettier=true&targets=&version=6.26.0&envVersion=



Pull request description:
fix(dce): handle array and object patterns in assignment expressions
fix #871

Patch:
diff --git a/packages/babel-plugin-minify-dead-code-elimination/src/index.js b/packages/babel-plugin-minify-dead-code-elimination/src/index.js
index 207a019..0eb1d74 100644
--- a/packages/babel-plugin-minify-dead-code-elimination/src/index.js
+++ b/packages/babel-plugin-minify-dead-code-elimination/src/index.js
@@ -235,10 +235,17 @@ module.exports = ({ types: t, traverse }) => {
                 bail = true;
               }
 
-              if (p.isAssignmentExpression() && !p.get("right").isPure()) {
-                mutations.push(() => p.replaceWith(p.get("right")));
-              } else {
-                mutations.push(() => removeOrVoid(p));
+              if (p.isAssignmentExpression()) {
+                if (
+                  t.isArrayPattern(p.node.left) ||
+                  t.isObjectPattern(p.node.left)
+                ) {
+                  bail = true;
+                } else if (p.get("right").isPure()) {
+                  mutations.push(() => removeOrVoid(p));
+                } else {
+                  mutations.push(() => p.replaceWith(p.get("right")));
+                }
               }
             });
 


Test patch:
diff --git a/packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-871/actual.js b/packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-871/actual.js
new file mode 100644
index 0000000..1372c79
--- /dev/null
+++ b/packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-871/actual.js
@@ -0,0 +1,7 @@
+async function example() {
+  var foo, bar;
+  try {
+    [foo, bar] = await Promise.all([req(1), req(2)]);
+  } catch (e) {}
+  console.log(foo);
+}
diff --git a/packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-871/expected.js b/packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-871/expected.js
new file mode 100644
index 0000000..cdbc2c0
--- /dev/null
+++ b/packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-871/expected.js
@@ -0,0 +1,9 @@
+async function example() {
+  var foo, bar;
+
+  try {
+    [foo, bar] = await Promise.all([req(1), req(2)]);
+  } catch (e) {}
+
+  console.log(foo);
+}
\ No newline at end of file