Repository: swc-project/swc (rust)

Issue:
Function param override gets incorrectly inlined
### Describe the bug

SWC compress seems to be inlining values for a param override, even when there are paths where the override might not happen. This does not happen for local variables (e.g. `let output = 'a output'`), only for variables which come from function params. 

### Input code

```ts
function run(flag: 'a' | 'b', output = 'a output') {
  if (flag === 'b') {
    output = 'b output'
  }

  console.log(output)
}

run('a')
run('b')
```

### Config

_No response_

### Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.79&code=H4sIAAAAAAAAA02NUQqAIBBE%2Fz3F%2FK1CdIDAw2hkBOJG6Vd199Ys6GcZ3szshJLGvHDCVpIO0c0DyBFOkKcOXPJaMqywV5PBoYAl4EnDWlujjeJX8F9B%2BKXkjJx2jlMfedbNMkqMuiuLpgn5pG7xOwn0kwAAAA%3D%3D&config=H4sIAAAAAAAAA4VWO2%2FbMBDe8ysCzS4cZOjQqWiDoF26dCwKgSaP8iV8COQxsRDkv%2FdIKZZtUe5m8%2Ft4j%2B8e1NvN7W3zFGXz5faNf%2FIfOBAEJ8wPMD2EyIAWJsKmoIz3IkQIR345i4MjceCzhoYeogzYU7OZcYoZpJDg5FANTliUP23vA1VgkD4I8iWEjE3Q%2B0kktI%2FngQQQkj4pb7d98BoNuo4Jf44EpmxffXiOvZAQtx3SPu22zitorVfJ8NnXksL2aKk5Xv67iOAZoP9uRIy%2FhIV4kUNDInSQM2sg3t%2Fd3zUzEoSL2gd7Hn2K8AAaHTz6UMw%2BIhi1KAEzDXRCDg8fEi3VK%2BGfWedDLFL%2F9ilIyGGNpM0pJSRHaAsqEnkrCOU5g4P8ltAQuovCsDALgSw61MN5ltLbPkCMl9GxWsmCo0q%2BBQ3%2B9VLiguy8NyDcVawVsUVH0FU6egrKGNFHaF9EqFrKUYuA0dcdZTgRqJb7rl9hOIWEnkeriisQqpXciVUQA0jCl0WTjSj75KsucrLV7ApBwS51HSybJQ%2F9izBJUNU3HEq5OPKq7b3HSK1Ori7sCK%2BqMsKT6MvbqNsAlIKr3X3y6FbrlUezlXmI3DSbS%2BuFo7nv1i3o%2F9xGx%2FOKNFQZxq9k7Xh8CVpEXVU8qwWBsF7tACpJyIrLemATYVXUiLzuQGvuqKqD%2BIok93XneTl6XYW4A4Su998ItccZXmXkMbpKeOSsaa0VJw4vrf01PA52581VNxZo72ubd6ZwkchfIwTeNof%2BGiM5Vda9WiHxqlUrq4SHhnxrYPlwlv7hoWK7bWf8bl43854%2BeSiscN28NT4W%2BM1EasZXcf46yPUfX7TPzUz62PKjjfd%2FTAene1UIAAA%3D

### SWC Info output

_No response_

### Expected behavior

In the code above, `flag` can be either `a` or `b`. I would expect the `flag === 'b'` check to remain in the output:

```js
function run(flag, output = 'a output') {
    'b' === flag && (output = 'b output'), console.log(output);
}
run('a'), run('b');
```

### Actual behavior

With SWC compress turned on, it appears to assume that `flag === 'b'` is _always_ true and inlines the `output` override value.

```js
function run(flag, output = 'a output') {
    console.log('b output');
}
run('a'), run('b');
```

### Version

1.3.79+

### Additional context

In the playground I was able to confirm correct behavior in `1.3.78`, with `1.3.79+` having issues. I looked through the [changelog](https://github.com/swc-project/swc/blob/main/CHANGELOG.md#1379---2023-08-25) for `1.3.79` but nothing immediately jumped out to me as a definite cause. Maybe https://github.com/swc-project/swc/pull/7839?

Pull request description:
fix(es/minifier): Always consider `reassigned` when inlining
**Related issue:**

 - Closes #8161.

Patch:
diff --git a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs
index c3c7634a8a..fa64b9897c 100644
--- a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs
+++ b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs
@@ -175,7 +175,7 @@ impl Optimizer<'_> {
             if is_inline_enabled
                 && usage.declared_count == 1
                 && usage.assign_count == 1
-                && (!usage.has_property_mutation || !usage.reassigned)
+                && !usage.reassigned
                 && match init {
                     Expr::Ident(Ident { sym, .. }) if &**sym == "eval" => false,
 


Test patch:
diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/8161/input.js b/crates/swc_ecma_minifier/tests/fixture/issues/8161/input.js
new file mode 100644
index 0000000000..5d9bdb50da
--- /dev/null
+++ b/crates/swc_ecma_minifier/tests/fixture/issues/8161/input.js
@@ -0,0 +1,10 @@
+function run(flag, output = "a output") {
+    if (flag === "b") {
+        output = "b output";
+    }
+
+    console.log(output);
+}
+
+run("a");
+run("b");
diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/8161/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/8161/output.js
new file mode 100644
index 0000000000..9519378411
--- /dev/null
+++ b/crates/swc_ecma_minifier/tests/fixture/issues/8161/output.js
@@ -0,0 +1,4 @@
+function run(flag, output = "a output") {
+    "b" === flag && (output = "b output"), console.log(output);
+}
+run("a"), run("b");