Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing init on destructuring not flagged as syntax error when inside for loop #8220

Closed
marvinhagemeister opened this issue Jan 2, 2025 · 0 comments · Fixed by #8222
Closed
Assignees
Labels
C-bug Category - Bug

Comments

@marvinhagemeister
Copy link

This code should be a syntax error, but is parsed successfully in OXC. Other parsers like Babel and SWC throw a syntax error as expected.

for (let { x };;);

Interestingly, OXC seems to be able to detect the missing initializer properly when it's outside of the for loop:

// throws: Error: Missing initializer in destructuring declaration
let { x }

Babel:

Missing initializer in destructuring declaration. (1:14)

> 1 | for (let { x };;);
    |               ^

SWC:

  x Destructuring bindings require initializers
   ,-[input.tsx:1:1]
 1 | for (let { x };;);
   :          ^^^^^
   `----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants