« first day (3 days earlier)    last day (15 days later) » 

2:08 PM
I meant examples of errors. Can you show them?
 
have you tried any? what object/array literals did you think of that could cause such an error?
 
 
3 hours later…
5:36 PM
Honestly, I do not know what to imagine. That's why I'm asking you. The only example I think about is this: (({})=0) or (([])=0) but I am not sure about this.
 
Those LeftHandSideExpression are not even Object/Arrayliterals because they are wrapped in parenthesis.
Try a normal and non-empty object literal.
 
@Bergi I dont understand. How can a normal or non-empty object cause an error?
 
5:58 PM
Because it's not suitable for an assignment. Take any usual object literal. What does it look like?
 
@Bergi it's look as blockstatement. Yeah {}=0 - cause an error. But If we write ({}=0) - no error here, why?
 
I said non-empty. Give it some values.
(that you have to wrap assignment statements in parenthesis has absolutely nothing to do with the early error rule you're asking about)
 
yeah, you're right code: `{a:0,b:1}=0` cause an `SyntaxError: Unexpected token : `

Why when I wrap in parentheses - does not apply to an early error?
 
You always have to wrap it in parenthesis if you want to use an assignment statement! var {a:0,b:1}=0 or ({a:0,b:1}=0).
And then you get the early syntax error that you were looking for: Invalid destructuring assignment target
Because that object literal is not covered by the AssignmentPattern grammar
 
6:16 PM
@Bergi I understood everything about this. But you have not explained to me why ({}=0) does not apply to an early error?
 
Because {} is covered by AssignmentPattern?
 
@Bergi That is, ({}=0) is the correct syntax for AssignmentPattern, right?
 
Only the {} part is relevant for the AssignmentPattern grammar
 
@Bergi of course. Then I do not quite understand the analysis of this expression: (({})=0) It is not entirely clear why AssignmentPattern is used here.
 
6:32 PM
Why do you think AssignmentPattern is used there? Where?
how (({}) = 0) is a syntax error was covered by
1
A: SyntaxError: Invalid destructuring assignment target or ReferenceError: invalid assignment left-hand side?

BergiWell, it's simply invalid syntax. You are not allowed to put a destructuring pattern in parentheses[1]: It is an early Reference Error[2] if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget of LeftHandSideExpression is false. You proba...

 
@Bergi yeah, but honestly I'm confused
@Bergi About the error: it is the same as in the expression ({a:0,b:1}=0)
 
Yeah well both errors are invalid assignment targets so it makes sense that they share a common error message (which is implementation-defined anyway!), but they are described by different early semantics rules in the spec.
 
7:00 PM
I correctly understand that this expression (({}) = 0) understands how:

AssignmentExpression: LeftHandSideExpression = AssignmentExpression
AssignmentExpression: ParenthesizedExpression = AssignmentExpression
AssignmentExpression: ({}) = 0
 
yes. so far, correct.
 
@Bergi I correct understand what expressions: (({})=0) and ((1+"h")=0) causes same errors?
 
Yes, in both of them "LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget of LeftHandSideExpression is false"
 
@Bergi why? In first case we have object literal in ()
 
Yes, in (), the LeftHandSideExpression is a ParenthesizedExpression as you showed. Not an ObjectLiteral.
 
7:18 PM
Hmm, I apparently miss something when parsing non-terminals. I correctly understand that if it is impossible to reach the target non-terminal without lowering additional characters, then the last non-terminal will be the one that contains the all characters.
@Bergi
That explains a lot in this case. Now I fully understood what I was asking. Thanks for the help.
 
Yes, the difference is between "is" and "contains"
glad to have helped!
 
@Bergi I think it’s worth adding an amendment to your answer that clarifies that ({}) is not ObjectLiteral. Question: stackoverflow.com/questions/54962846/…
 

« first day (3 days earlier)    last day (15 days later) »