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

clarify what are the "circumstances" for refining the interpretation of LeftHandSideExpression #3323

Open
ltcmelo opened this issue May 9, 2024 · 3 comments
Labels

Comments

@ltcmelo
Copy link

ltcmelo commented May 9, 2024

In 13.15.5 Destructuring Assignment, we have:

"In certain circumstances when processing an instance of the production AssignmentExpression : LeftHandSideExpression = AssignmentExpression the interpretation of LeftHandSideExpression is refined using the following grammar: ..."

But I couldn't find where these circumstances are explained. Have I missed it?

If my understand is correct, then in a context like the one below, the refinement should apply:

let o = { x: "s", y: 0 };
({x: v, y: w} = o);

In one case or another, the spec should clarify — if isn't yet doing so — what the circumstances in question are; if this is already clarified and I've missed it, it might be worth to link the clarification in section 13.15.5.

@jmdyck
Copy link
Collaborator

jmdyck commented May 9, 2024

See 13.15.1 Static Semantics: Early Errors.

The circumstance is when the LeftHandSideExpression (of the AssignmentExpression) is either an ObjectLiteral or an ArrayLiteral.

And the 'refinement' is that the LeftHandSideExpression must cover an AssignmentPattern.

@jmdyck
Copy link
Collaborator

jmdyck commented May 9, 2024

If my understand is correct, then in a context like the one below, the refinement should apply:

let o = { x: "s", y: 0 };
({x: v, y: w} = o);

Yes, I think so. {x: v, y: w} is initially parsed as a LeftHandSideExpression (consisting of an ObjectLiteral), and then as an AssignmentPattern (consisting of an ObjectAssignmentPattern).

@ltcmelo
Copy link
Author

ltcmelo commented May 13, 2024

Thanks for clarifying @jmdyck! I'm leaving this open nevertheless in case the editors would consider an explicit pointer for the explanation of the circumstances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants