Repository: swc-project/swc (rust)

Issue:
'arguments' is only allowed in functions and class methods
### Describe the bug

arguments are wrong in nested class

### Input code

```typescript
class T {
    f() { arguments }

    static f = class extends T {
        x() { arguments }
    }
}
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}
```


### Playground link

https://play.swc.rs/?version=1.3.59&code=H4sIAAAAAAAAA0vOSSwuVghRqOblUgCCNA1NhWqFxKL00tzUvJJihVpeLohEcUliSWayQpqCrUIyWEtqRUlqXgqSVhCowNQOEgZStQDBQSfBaQAAAA%3D%3D&config=H4sIAAAAAAAAA1WPSw7CMAxE9z1F5DUL1AUL7sAhouBWQfkpdiWqqncnf2AXv5nJ2MckBLxIwV0c6ZmGICNhHHMitDuW70SA94Ckog4Ml64yZYnjhoWcVQCWcUXOIaT5Os8tAMZ7woQXaQgbs9rpZf%2BtVN6GiET%2FxmyVbjUjXxun1grWP7citlPyunWDG3xNvWx8DJoePVnuOD9fu6hdFgEAAA%3D%3D

### Expected behavior

No error

### Actual behavior

```

  x 'arguments' is only allowed in functions and class methods
   ,-[input.tsx:2:1]
 2 |     f() { arguments }
 3 | 
 4 |     static f = class extends T {
 5 |         x() { arguments }
   :               ^^^^^^^^^
 6 |     }
 7 | }
   `----


Caused by:
    0: failed to process js file
    1: Syntax Error
```

### Version

1.3.59

### Additional context

_No response_

Pull request description:
fix(es/parser): Reset class context
**Description:**


**Related issue:**

 - Closes #7428.

Patch:
diff --git a/crates/swc_ecma_parser/src/parser/class_and_fn.rs b/crates/swc_ecma_parser/src/parser/class_and_fn.rs
index d1fe9d395a..12a3df4fae 100644
--- a/crates/swc_ecma_parser/src/parser/class_and_fn.rs
+++ b/crates/swc_ecma_parser/src/parser/class_and_fn.rs
@@ -1435,6 +1435,7 @@ impl<I: Tokens> Parser<I> {
         let function = self
             .with_ctx(Context {
                 allow_direct_super: true,
+                in_class_field: false,
                 ..self.ctx()
             })
             .parse_with(|p| {


Test patch:
diff --git a/crates/swc_ecma_parser/tests/js/jssue-7428/1/input.js b/crates/swc_ecma_parser/tests/js/jssue-7428/1/input.js
new file mode 100644
index 0000000000..56fac83d7a
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/js/jssue-7428/1/input.js
@@ -0,0 +1,7 @@
+class T {
+    f() { arguments }
+
+    static f = class extends T {
+        x() { arguments }
+    }
+}
\ No newline at end of file
diff --git a/crates/swc_ecma_parser/tests/js/jssue-7428/1/input.js.json b/crates/swc_ecma_parser/tests/js/jssue-7428/1/input.js.json
new file mode 100644
index 0000000000..d82f019041
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/js/jssue-7428/1/input.js.json
@@ -0,0 +1,222 @@
+{
+  "type": "Script",
+  "span": {
+    "start": 1,
+    "end": 100,
+    "ctxt": 0
+  },
+  "body": [
+    {
+      "type": "ClassDeclaration",
+      "identifier": {
+        "type": "Identifier",
+        "span": {
+          "start": 7,
+          "end": 8,
+          "ctxt": 0
+        },
+        "value": "T",
+        "optional": false
+      },
+      "declare": false,
+      "span": {
+        "start": 1,
+        "end": 100,
+        "ctxt": 0
+      },
+      "decorators": [],
+      "body": [
+        {
+          "type": "ClassMethod",
+          "span": {
+            "start": 15,
+            "end": 32,
+            "ctxt": 0
+          },
+          "key": {
+            "type": "Identifier",
+            "span": {
+              "start": 15,
+              "end": 16,
+              "ctxt": 0
+            },
+            "value": "f",
+            "optional": false
+          },
+          "function": {
+            "params": [],
+            "decorators": [],
+            "span": {
+              "start": 15,
+              "end": 32,
+              "ctxt": 0
+            },
+            "body": {
+              "type": "BlockStatement",
+              "span": {
+                "start": 19,
+                "end": 32,
+                "ctxt": 0
+              },
+              "stmts": [
+                {
+                  "type": "ExpressionStatement",
+                  "span": {
+                    "start": 21,
+                    "end": 30,
+                    "ctxt": 0
+                  },
+                  "expression": {
+                    "type": "Identifier",
+                    "span": {
+                      "start": 21,
+                      "end": 30,
+                      "ctxt": 0
+                    },
+                    "value": "arguments",
+                    "optional": false
+                  }
+                }
+              ]
+            },
+            "generator": false,
+            "async": false,
+            "typeParameters": null,
+            "returnType": null
+          },
+          "kind": "method",
+          "isStatic": false,
+          "accessibility": null,
+          "isAbstract": false,
+          "isOptional": false,
+          "isOverride": false
+        },
+        {
+          "type": "ClassProperty",
+          "span": {
+            "start": 38,
+            "end": 98,
+            "ctxt": 0
+          },
+          "key": {
+            "type": "Identifier",
+            "span": {
+              "start": 45,
+              "end": 46,
+              "ctxt": 0
+            },
+            "value": "f",
+            "optional": false
+          },
+          "value": {
+            "type": "ClassExpression",
+            "identifier": null,
+            "span": {
+              "start": 49,
+              "end": 98,
+              "ctxt": 0
+            },
+            "decorators": [],
+            "body": [
+              {
+                "type": "ClassMethod",
+                "span": {
+                  "start": 75,
+                  "end": 92,
+                  "ctxt": 0
+                },
+                "key": {
+                  "type": "Identifier",
+                  "span": {
+                    "start": 75,
+                    "end": 76,
+                    "ctxt": 0
+                  },
+                  "value": "x",
+                  "optional": false
+                },
+                "function": {
+                  "params": [],
+                  "decorators": [],
+                  "span": {
+                    "start": 75,
+                    "end": 92,
+                    "ctxt": 0
+                  },
+                  "body": {
+                    "type": "BlockStatement",
+                    "span": {
+                      "start": 79,
+                      "end": 92,
+                      "ctxt": 0
+                    },
+                    "stmts": [
+                      {
+                        "type": "ExpressionStatement",
+                        "span": {
+                          "start": 81,
+                          "end": 90,
+                          "ctxt": 0
+                        },
+                        "expression": {
+                          "type": "Identifier",
+                          "span": {
+                            "start": 81,
+                            "end": 90,
+                            "ctxt": 0
+                          },
+                          "value": "arguments",
+                          "optional": false
+                        }
+                      }
+                    ]
+                  },
+                  "generator": false,
+                  "async": false,
+                  "typeParameters": null,
+                  "returnType": null
+                },
+                "kind": "method",
+                "isStatic": false,
+                "accessibility": null,
+                "isAbstract": false,
+                "isOptional": false,
+                "isOverride": false
+              }
+            ],
+            "superClass": {
+              "type": "Identifier",
+              "span": {
+                "start": 63,
+                "end": 64,
+                "ctxt": 0
+              },
+              "value": "T",
+              "optional": false
+            },
+            "isAbstract": false,
+            "typeParams": null,
+            "superTypeParams": null,
+            "implements": []
+          },
+          "typeAnnotation": null,
+          "isStatic": true,
+          "decorators": [],
+          "accessibility": null,
+          "isAbstract": false,
+          "isOptional": false,
+          "isOverride": false,
+          "readonly": false,
+          "declare": false,
+          "definite": false
+        }
+      ],
+      "superClass": null,
+      "isAbstract": false,
+      "typeParams": null,
+      "superTypeParams": null,
+      "implements": []
+    }
+  ],
+  "interpreter": null
+}
diff --git a/crates/swc_ecma_parser/tests/typescript/jssue-7428/1/input.ts b/crates/swc_ecma_parser/tests/typescript/jssue-7428/1/input.ts
new file mode 100644
index 0000000000..56fac83d7a
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/typescript/jssue-7428/1/input.ts
@@ -0,0 +1,7 @@
+class T {
+    f() { arguments }
+
+    static f = class extends T {
+        x() { arguments }
+    }
+}
\ No newline at end of file
diff --git a/crates/swc_ecma_parser/tests/typescript/jssue-7428/1/input.ts.json b/crates/swc_ecma_parser/tests/typescript/jssue-7428/1/input.ts.json
new file mode 100644
index 0000000000..d82f019041
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/typescript/jssue-7428/1/input.ts.json
@@ -0,0 +1,222 @@
+{
+  "type": "Script",
+  "span": {
+    "start": 1,
+    "end": 100,
+    "ctxt": 0
+  },
+  "body": [
+    {
+      "type": "ClassDeclaration",
+      "identifier": {
+        "type": "Identifier",
+        "span": {
+          "start": 7,
+          "end": 8,
+          "ctxt": 0
+        },
+        "value": "T",
+        "optional": false
+      },
+      "declare": false,
+      "span": {
+        "start": 1,
+        "end": 100,
+        "ctxt": 0
+      },
+      "decorators": [],
+      "body": [
+        {
+          "type": "ClassMethod",
+          "span": {
+            "start": 15,
+            "end": 32,
+            "ctxt": 0
+          },
+          "key": {
+            "type": "Identifier",
+            "span": {
+              "start": 15,
+              "end": 16,
+              "ctxt": 0
+            },
+            "value": "f",
+            "optional": false
+          },
+          "function": {
+            "params": [],
+            "decorators": [],
+            "span": {
+              "start": 15,
+              "end": 32,
+              "ctxt": 0
+            },
+            "body": {
+              "type": "BlockStatement",
+              "span": {
+                "start": 19,
+                "end": 32,
+                "ctxt": 0
+              },
+              "stmts": [
+                {
+                  "type": "ExpressionStatement",
+                  "span": {
+                    "start": 21,
+                    "end": 30,
+                    "ctxt": 0
+                  },
+                  "expression": {
+                    "type": "Identifier",
+                    "span": {
+                      "start": 21,
+                      "end": 30,
+                      "ctxt": 0
+                    },
+                    "value": "arguments",
+                    "optional": false
+                  }
+                }
+              ]
+            },
+            "generator": false,
+            "async": false,
+            "typeParameters": null,
+            "returnType": null
+          },
+          "kind": "method",
+          "isStatic": false,
+          "accessibility": null,
+          "isAbstract": false,
+          "isOptional": false,
+          "isOverride": false
+        },
+        {
+          "type": "ClassProperty",
+          "span": {
+            "start": 38,
+            "end": 98,
+            "ctxt": 0
+          },
+          "key": {
+            "type": "Identifier",
+            "span": {
+              "start": 45,
+              "end": 46,
+              "ctxt": 0
+            },
+            "value": "f",
+            "optional": false
+          },
+          "value": {
+            "type": "ClassExpression",
+            "identifier": null,
+            "span": {
+              "start": 49,
+              "end": 98,
+              "ctxt": 0
+            },
+            "decorators": [],
+            "body": [
+              {
+                "type": "ClassMethod",
+                "span": {
+                  "start": 75,
+                  "end": 92,
+                  "ctxt": 0
+                },
+                "key": {
+                  "type": "Identifier",
+                  "span": {
+                    "start": 75,
+                    "end": 76,
+                    "ctxt": 0
+                  },
+                  "value": "x",
+                  "optional": false
+                },
+                "function": {
+                  "params": [],
+                  "decorators": [],
+                  "span": {
+                    "start": 75,
+                    "end": 92,
+                    "ctxt": 0
+                  },
+                  "body": {
+                    "type": "BlockStatement",
+                    "span": {
+                      "start": 79,
+                      "end": 92,
+                      "ctxt": 0
+                    },
+                    "stmts": [
+                      {
+                        "type": "ExpressionStatement",
+                        "span": {
+                          "start": 81,
+                          "end": 90,
+                          "ctxt": 0
+                        },
+                        "expression": {
+                          "type": "Identifier",
+                          "span": {
+                            "start": 81,
+                            "end": 90,
+                            "ctxt": 0
+                          },
+                          "value": "arguments",
+                          "optional": false
+                        }
+                      }
+                    ]
+                  },
+                  "generator": false,
+                  "async": false,
+                  "typeParameters": null,
+                  "returnType": null
+                },
+                "kind": "method",
+                "isStatic": false,
+                "accessibility": null,
+                "isAbstract": false,
+                "isOptional": false,
+                "isOverride": false
+              }
+            ],
+            "superClass": {
+              "type": "Identifier",
+              "span": {
+                "start": 63,
+                "end": 64,
+                "ctxt": 0
+              },
+              "value": "T",
+              "optional": false
+            },
+            "isAbstract": false,
+            "typeParams": null,
+            "superTypeParams": null,
+            "implements": []
+          },
+          "typeAnnotation": null,
+          "isStatic": true,
+          "decorators": [],
+          "accessibility": null,
+          "isAbstract": false,
+          "isOptional": false,
+          "isOverride": false,
+          "readonly": false,
+          "declare": false,
+          "definite": false
+        }
+      ],
+      "superClass": null,
+      "isAbstract": false,
+      "typeParams": null,
+      "superTypeParams": null,
+      "implements": []
+    }
+  ],
+  "interpreter": null
+}
diff --git a/crates/swc_ecma_parser/tests/typescript/jssue-7428/2/input.tsx b/crates/swc_ecma_parser/tests/typescript/jssue-7428/2/input.tsx
new file mode 100644
index 0000000000..56fac83d7a
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/typescript/jssue-7428/2/input.tsx
@@ -0,0 +1,7 @@
+class T {
+    f() { arguments }
+
+    static f = class extends T {
+        x() { arguments }
+    }
+}
\ No newline at end of file
diff --git a/crates/swc_ecma_parser/tests/typescript/jssue-7428/2/input.tsx.json b/crates/swc_ecma_parser/tests/typescript/jssue-7428/2/input.tsx.json
new file mode 100644
index 0000000000..d82f019041
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/typescript/jssue-7428/2/input.tsx.json
@@ -0,0 +1,222 @@
+{
+  "type": "Script",
+  "span": {
+    "start": 1,
+    "end": 100,
+    "ctxt": 0
+  },
+  "body": [
+    {
+      "type": "ClassDeclaration",
+      "identifier": {
+        "type": "Identifier",
+        "span": {
+          "start": 7,
+          "end": 8,
+          "ctxt": 0
+        },
+        "value": "T",
+        "optional": false
+      },
+      "declare": false,
+      "span": {
+        "start": 1,
+        "end": 100,
+        "ctxt": 0
+      },
+      "decorators": [],
+      "body": [
+        {
+          "type": "ClassMethod",
+          "span": {
+            "start": 15,
+            "end": 32,
+            "ctxt": 0
+          },
+          "key": {
+            "type": "Identifier",
+            "span": {
+              "start": 15,
+              "end": 16,
+              "ctxt": 0
+            },
+            "value": "f",
+            "optional": false
+          },
+          "function": {
+            "params": [],
+            "decorators": [],
+            "span": {
+              "start": 15,
+              "end": 32,
+              "ctxt": 0
+            },
+            "body": {
+              "type": "BlockStatement",
+              "span": {
+                "start": 19,
+                "end": 32,
+                "ctxt": 0
+              },
+              "stmts": [
+                {
+                  "type": "ExpressionStatement",
+                  "span": {
+                    "start": 21,
+                    "end": 30,
+                    "ctxt": 0
+                  },
+                  "expression": {
+                    "type": "Identifier",
+                    "span": {
+                      "start": 21,
+                      "end": 30,
+                      "ctxt": 0
+                    },
+                    "value": "arguments",
+                    "optional": false
+                  }
+                }
+              ]
+            },
+            "generator": false,
+            "async": false,
+            "typeParameters": null,
+            "returnType": null
+          },
+          "kind": "method",
+          "isStatic": false,
+          "accessibility": null,
+          "isAbstract": false,
+          "isOptional": false,
+          "isOverride": false
+        },
+        {
+          "type": "ClassProperty",
+          "span": {
+            "start": 38,
+            "end": 98,
+            "ctxt": 0
+          },
+          "key": {
+            "type": "Identifier",
+            "span": {
+              "start": 45,
+              "end": 46,
+              "ctxt": 0
+            },
+            "value": "f",
+            "optional": false
+          },
+          "value": {
+            "type": "ClassExpression",
+            "identifier": null,
+            "span": {
+              "start": 49,
+              "end": 98,
+              "ctxt": 0
+            },
+            "decorators": [],
+            "body": [
+              {
+                "type": "ClassMethod",
+                "span": {
+                  "start": 75,
+                  "end": 92,
+                  "ctxt": 0
+                },
+                "key": {
+                  "type": "Identifier",
+                  "span": {
+                    "start": 75,
+                    "end": 76,
+                    "ctxt": 0
+                  },
+                  "value": "x",
+                  "optional": false
+                },
+                "function": {
+                  "params": [],
+                  "decorators": [],
+                  "span": {
+                    "start": 75,
+                    "end": 92,
+                    "ctxt": 0
+                  },
+                  "body": {
+                    "type": "BlockStatement",
+                    "span": {
+                      "start": 79,
+                      "end": 92,
+                      "ctxt": 0
+                    },
+                    "stmts": [
+                      {
+                        "type": "ExpressionStatement",
+                        "span": {
+                          "start": 81,
+                          "end": 90,
+                          "ctxt": 0
+                        },
+                        "expression": {
+                          "type": "Identifier",
+                          "span": {
+                            "start": 81,
+                            "end": 90,
+                            "ctxt": 0
+                          },
+                          "value": "arguments",
+                          "optional": false
+                        }
+                      }
+                    ]
+                  },
+                  "generator": false,
+                  "async": false,
+                  "typeParameters": null,
+                  "returnType": null
+                },
+                "kind": "method",
+                "isStatic": false,
+                "accessibility": null,
+                "isAbstract": false,
+                "isOptional": false,
+                "isOverride": false
+              }
+            ],
+            "superClass": {
+              "type": "Identifier",
+              "span": {
+                "start": 63,
+                "end": 64,
+                "ctxt": 0
+              },
+              "value": "T",
+              "optional": false
+            },
+            "isAbstract": false,
+            "typeParams": null,
+            "superTypeParams": null,
+            "implements": []
+          },
+          "typeAnnotation": null,
+          "isStatic": true,
+          "decorators": [],
+          "accessibility": null,
+          "isAbstract": false,
+          "isOptional": false,
+          "isOverride": false,
+          "readonly": false,
+          "declare": false,
+          "definite": false
+        }
+      ],
+      "superClass": null,
+      "isAbstract": false,
+      "typeParams": null,
+      "superTypeParams": null,
+      "implements": []
+    }
+  ],
+  "interpreter": null
+}