Repository: swc-project/swc (rust)

Issue:
minifier generates generator arrow functions
### Describe the bug

Generator arrow functions are invalid (only `function(){}` s  can be generators)

### Input code

```typescript
function bar() {
	return function* () {
		yield foo();
	};
}
console.log(bar());
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress":{
        "ecma": "2022",
        "unsafe_arrows": true
      },
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": true,
  "isModule": true
}
```


### Playground link

https://play.swc.rs/?version=1.3.60&code=H4sIAAAAAAAAA0srzUsuyczPU0hKLNLQVKjm4ixKLSktylNIg0poKUCEOSszU3NSFNLy8zU0rbk4a625armS8%2FOK83NS9XLy0zXA%2BoEyABpLAdpRAAAA&config=H4sIAAAAAAAAA1WQSw6DMAxE95wi8rqLikUX3KFnqKzUoCDykR3Uooq7N4SE0l38xuMZ5dMoBaNo6NQnPdMQkIX4mBORxUV8JwKkLYpmEyJcqjrKJvU4CWW07gpE5IFidkl7bdvigMl7oeoozBpn%2BuWcqb0NTCLQVaT2%2BO3g6VzmsxPs6YHM%2FpUcKvJMRV2PnhbdMNF%2F1aYsgPXPOYvlE%2BISaK9%2Bg99Sbbndz8TIvRpz5voFN2aRrU8BAAA%3D

### Expected behavior

Have `function* ()` in the output

### Actual behavior

Invalid JS:
```js
console.log(*()=>{yield foo()});
```

### Version

1.3.60

### Additional context

Reported in https://github.com/parcel-bundler/parcel/issues/9041

Pull request:
fix(es/minifier): Don't generate generator arrows
**Description:**

**Related issue:**

 - Closes #7457.

Patch:
diff --git a/crates/swc_ecma_minifier/src/compress/pure/arrows.rs b/crates/swc_ecma_minifier/src/compress/pure/arrows.rs
index 7ada4cb26b..8fd24e225f 100644
--- a/crates/swc_ecma_minifier/src/compress/pure/arrows.rs
+++ b/crates/swc_ecma_minifier/src/compress/pure/arrows.rs
@@ -21,7 +21,7 @@ impl Pure<'_> {
             function,
         }) = e
         {
-            if contains_this_expr(&function.body) {
+            if contains_this_expr(&function.body) || function.is_generator {
                 return;
             }
 


Test patch:
diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/config.json b/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/config.json
new file mode 100644
index 0000000000..518a9df454
--- /dev/null
+++ b/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/config.json
@@ -0,0 +1,4 @@
+{
+    "ecma": "2022",
+    "unsafe_arrows": true
+}
diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/input.js b/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/input.js
new file mode 100644
index 0000000000..3889b96537
--- /dev/null
+++ b/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/input.js
@@ -0,0 +1,6 @@
+function bar() {
+    return function* () {
+        yield foo();
+    };
+}
+console.log(bar());
\ No newline at end of file
diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/output.js
new file mode 100644
index 0000000000..07d4701478
--- /dev/null
+++ b/crates/swc_ecma_minifier/tests/fixture/issues/7457/1/output.js
@@ -0,0 +1,6 @@
+function bar() {
+    return function*() {
+        yield foo();
+    };
+}
+console.log(bar());