| // Copyright (C) 2019 Leo Balter. All rights reserved. |
| // This code is governed by the BSD license found in the LICENSE file. |
| |
| /*--- |
| esid: prod-DestructuringAssignmentTarget |
| desc: > |
| The DestructuringAssignmentTarget of an AssignmentElement can extend to LHSExpressions if |
| it is neither an ObjectLiteral nor an ArrayLiteral and its AssignmentTargetTyp is simple. |
| Using MemberExpression (ObjLiteral + identifier) with initializer. |
| info: | |
| Syntax |
| |
| AssignmentPattern : ArrayAssignmentPattern |
| ArrayAssignmentPattern : [ AssignmentElementList ] |
| AssignmentElementList : AssignmentElisionElement |
| AssignmentElisionElement : Elision_opt AssignmentElement |
| AssignmentElement : DestructuringAssignmentTarget Initializer_opt |
| DestructuringAssignmentTarget : LeftHandSideExpression |
| |
| Static Semantics: Early Errors |
| |
| DestructuringAssignmentTarget : LeftHandSideExpression |
| |
| - It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if LeftHandSideExpression is not covering an AssignmentPattern. |
| - It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and AssignmentTargetType(LeftHandSideExpression) is not simple. |
| |
| Runtime Semantics: DestructuringAssignmentEvaluation |
| ArrayAssignmentPattern : [ AssignmentElementList ] |
| |
| 1. Let iteratorRecord be ? GetIterator(value). |
| 2. Let result be IteratorDestructuringAssignmentEvaluation of AssignmentElementList with argument iteratorRecord. |
| 3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result). |
| 4. Return result. |
| |
| Runtime Semantics: IteratorDestructuringAssignmentEvaluation |
| AssignmentElement : DestructuringAssignmentTarget Initializer |
| |
| 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral, then |
| a. Let lref be the result of evaluating DestructuringAssignmentTarget. |
| ... |
| 7. Return ? PutValue(lref, v). |
| template: default |
| ---*/ |
| |
| //- setup |
| var x, setValue; |
| //- elems |
| [{ |
| get y() { |
| throw new Test262Error('The property should not be accessed.'); |
| }, |
| set y(val) { |
| setValue = val; |
| } |
| }.y = 42] |
| //- vals |
| [23] |
| //- body |
| assert.sameValue(setValue, 23); |
| |