Repository: babel/minify (js)
Issue: minify-infinity not doing anything
**Describe the bug**

The minify-infinity pass doesn't do anything.

**To Reproduce**

```js
const infinities = [Infinity, 1/0, true/false, !0/!1, true/(true/(true/false))];
const zeroes = [1/Infinity, 1/(1/0), false/true, !1/!0, true/(true/false)];
const justone = Infinity;
alert(Infinity);
```

**Actual Output**

```js
"use strict";var infinities=[Infinity,1/0,!0/!1,!0/!1,!0/0],zeroes=[1/Infinity,0,0,0,0],justone=Infinity;alert(Infinity);
```

**Expected Output**

```js
"use strict";var infinities=[1/0,1/0,1/0,1/0,1/0],zeroes=[0,0,0,0,0],justone=1/0;alert(1/0);
```

**Additional context**

It returns here, and therefore doesn't do the substitution:
```js
        if (path.isLVal() && !path.parentPath.isExpressionStatement()) {
          return;
        }
```
The `path.parentPath.type` is `"ArrayExpression"`, `"BinaryExpression"`, `"VariableDeclarator"` and `"CallExpression"`, respectively.

I couldn't find any documentation on what `.isExpressionStatement()` is actually supposed to do, so I don't know whether the bug is in minify-infinity or in babel itself.
Pull request description: fix: minify infinity in expressions
Fix #839 

Patch:
diff --git a/packages/babel-plugin-minify-infinity/src/index.js b/packages/babel-plugin-minify-infinity/src/index.js
index 2c04d31..4359310 100644
--- a/packages/babel-plugin-minify-infinity/src/index.js
+++ b/packages/babel-plugin-minify-infinity/src/index.js
@@ -28,7 +28,14 @@ module.exports = function({ types: t }) {
           return;
         }
 
-        if (path.isLVal() && !path.parentPath.isExpressionStatement()) {
+        const bindingIds = path.parentPath.getBindingIdentifierPaths();
+
+        if (
+          bindingIds["Infinity"] === path &&
+          // ObjectProperty is common for ObjectExpression and ObjectPattern and only
+          // one of them is a Binding, the other is simply a reference
+          !path.parentPath.parentPath.isObjectExpression()
+        ) {
           return;
         }
 


Test patch:
diff --git a/packages/babel-plugin-minify-infinity/__tests__/fixtures/bindings/actual.js b/packages/babel-plugin-minify-infinity/__tests__/fixtures/bindings/actual.js
new file mode 100644
index 0000000..f9dbe91
--- /dev/null
+++ b/packages/babel-plugin-minify-infinity/__tests__/fixtures/bindings/actual.js
@@ -0,0 +1,12 @@
+function foo() {
+  let [Infinity] = some();
+  return Infinity;
+}
+
+function bar() {
+  let [...Infinity] = some();
+}
+
+function baz() {
+  let { inf = Infinity } = some();
+}
diff --git a/packages/babel-plugin-minify-infinity/__tests__/fixtures/bindings/expected.js b/packages/babel-plugin-minify-infinity/__tests__/fixtures/bindings/expected.js
new file mode 100644
index 0000000..11f54d2
--- /dev/null
+++ b/packages/babel-plugin-minify-infinity/__tests__/fixtures/bindings/expected.js
@@ -0,0 +1,14 @@
+function foo() {
+  let [Infinity] = some();
+  return Infinity;
+}
+
+function bar() {
+  let [...Infinity] = some();
+}
+
+function baz() {
+  let {
+    inf = 1 / 0
+  } = some();
+}
\ No newline at end of file
diff --git a/packages/babel-plugin-minify-infinity/__tests__/fixtures/expressions/actual.js b/packages/babel-plugin-minify-infinity/__tests__/fixtures/expressions/actual.js
new file mode 100644
index 0000000..09e479c
--- /dev/null
+++ b/packages/babel-plugin-minify-infinity/__tests__/fixtures/expressions/actual.js
@@ -0,0 +1,10 @@
+let x = [Infinity, Infinity];
+
+let y = [
+  {
+    a: Infinity
+  },
+  {
+    a: Infinity
+  }
+];
diff --git a/packages/babel-plugin-minify-infinity/__tests__/fixtures/expressions/expected.js b/packages/babel-plugin-minify-infinity/__tests__/fixtures/expressions/expected.js
new file mode 100644
index 0000000..cd701ed
--- /dev/null
+++ b/packages/babel-plugin-minify-infinity/__tests__/fixtures/expressions/expected.js
@@ -0,0 +1,6 @@
+let x = [1 / 0, 1 / 0];
+let y = [{
+  a: 1 / 0
+}, {
+  a: 1 / 0
+}];
\ No newline at end of file