Repository: swc-project/swc (rust)

Issue:
Unexpected initializer in for in/of loop
### Describe the bug

When I transpile the poc.js, I get the error
```shell
Unexpected initializer in for in/of loop
```
As far as I know, the syntax error “for in loop head declarations may not have initializers”  only appears in strict mode. And in non strict mode, this variable declaration in the loop header is silently ignored

### Input code

```typescript
var v3 = 3 + 2 - 5;
for (var v1 = 1 in v3) {
}
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es5",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "commonjs"
  },
  "minify": false,
  "isModule": false
}
```


### Playground link

https://play.swc.rs/?version=1.2.204&code=H4sIAAAAAAAAAytLLFIoM1awVTBW0FYwUtBVMLXmSssvUtAoA0kYAiUMFTLzgEo0Faq5arkAH8oRNC8AAAA%3D&config=H4sIAAAAAAAAA0WMSwrDMAxE76K1t93kDj2EcJXg4B8eB2KM716ZumQlMe%2FNdDphaeuUuUDK%2FNBi5Zs2EhsYtrhcyaim0c4eMgxVLofUqeClzKcEWdRQcNHtbS7ZFHIR4EEcD%2F83hw6F9Llm0Km2rHdWQoonaDxDq%2BzwXvav%2FgXU82csuwAAAA%3D%3D

### Expected behavior

I hope swc can silently ignore this variable declaration in the loop header.

### Actual behavior

_No response_

### Version

1.2.204

### Additional context

_No response_

Pull request description:
fix(es/parser): allow for-in loop init with non-strict mode
<!-- Note: CI script will automatically rebase your PR so please do not rebase unless required -->

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. -->

**Description:**

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

**BREAKING CHANGE:**

<!--
If this PR introduces a breaking change, it must contain a notice for it to be included in the CHANGELOG. Add description or remove entirely if not breaking.

You may need to update `MIGRATION.md` for the breaking changes.
-->

**Related issue (if exists):**
- fix #5020 

Patch:
diff --git a/crates/swc_ecma_parser/src/parser/stmt.rs b/crates/swc_ecma_parser/src/parser/stmt.rs
index b0d1b1fbb0..f73c2b39e6 100644
--- a/crates/swc_ecma_parser/src/parser/stmt.rs
+++ b/crates/swc_ecma_parser/src/parser/stmt.rs
@@ -1130,7 +1130,7 @@ impl<'a, I: Tokens> Parser<I> {
                         self.emit_err(d.name.span(), SyntaxError::TooManyVarInForInHead);
                     }
                 } else {
-                    if decl.decls[0].init.is_some() {
+                    if (self.ctx().strict || is!(self, "of")) && decl.decls[0].init.is_some() {
                         self.emit_err(
                             decl.decls[0].name.span(),
                             SyntaxError::VarInitializerInForInHead,


Test patch:
diff --git a/crates/swc_ecma_parser/src/parser/tests.rs b/crates/swc_ecma_parser/src/parser/tests.rs
index 42b00d99c7..ae58886bae 100644
--- a/crates/swc_ecma_parser/src/parser/tests.rs
+++ b/crates/swc_ecma_parser/src/parser/tests.rs
@@ -353,3 +353,8 @@ fn illegal_language_mode_directive2() {
         },
     );
 }
+
+#[test]
+fn parse_non_strict_for_loop() {
+    script("for (var v1 = 1 in v3) {}");
+}
diff --git a/crates/swc_ecma_parser/tests/test262.rs b/crates/swc_ecma_parser/tests/test262.rs
index e98bde5d55..3fbe9857eb 100644
--- a/crates/swc_ecma_parser/tests/test262.rs
+++ b/crates/swc_ecma_parser/tests/test262.rs
@@ -104,6 +104,8 @@ fn add_test<F: FnOnce() + Send + 'static>(
 #[cfg(feature = "verify")]
 fn error_tests(tests: &mut Vec<TestDescAndFn>) -> Result<(), io::Error> {
     const IGNORED_ERROR_TESTS: &[&str] = &[
+        // pass in script. error in module.
+        "e3fbcf63d7e43ead.js",
         // Old (wrong) tests
         "569a2c1bad3beeb2.js",
         "3b6f737a4ac948a8.js",