ecma262 icon indicating copy to clipboard operation
ecma262 copied to clipboard

clarify what are the "circumstances" for refining the interpretation of `LeftHandSideExpression`

Open ltcmelo opened this issue 1 year ago • 3 comments

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.

ltcmelo avatar May 09 '24 17:05 ltcmelo

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 avatar May 09 '24 18:05 jmdyck

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).

jmdyck avatar May 09 '24 19:05 jmdyck

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.

ltcmelo avatar May 13 '24 18:05 ltcmelo