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

for (let a = b => b in c; ;); #838

Closed
mdjermanovic opened this issue Jun 16, 2019 · 2 comments
Closed

for (let a = b => b in c; ;); #838

mdjermanovic opened this issue Jun 16, 2019 · 2 comments

Comments

@mdjermanovic
Copy link

The following code:

for (let a = b => b in c; ;);

produces a SyntaxError in Node/Chrome/Firefox, as it is viewed as an invalid for-in loop.

However, it's a valid ForStatement in Acorn, so there is a difference. I'm not sure who is right.

@pvdz
Copy link

pvdz commented Sep 12, 2019

This example is a syntax error because the binding cannot have an initialization. Web compat / AnnexB does allow for inits for var in this case. But that rule does not apply to let.

https://tc39.es/ecma262/#sec-iteration-statements
(Note that all cases starting with for (let require a LeftHandSideExpression production, which does not include assignments)
https://tc39.es/ecma262/#sec-initializers-in-forin-statement-heads

marijnh added a commit that referenced this issue Aug 24, 2021
FIX: Fix an issue where arrow function bodies in for loop context would inappropriately
consume `in` operators.

Issue #1058
Issue #838
Issue #922
marijnh added a commit that referenced this issue Aug 24, 2021
FIX: Fix an issue where arrow function bodies in for loop context would inappropriately
consume `in` operators.

Issue #1058
Issue #838
Issue #922
@marijnh
Copy link
Member

marijnh commented Aug 24, 2021

Should be solved by attached patch.

@marijnh marijnh closed this as completed Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants