diff options
Diffstat (limited to 'js/src/tests/test262/language/statements/for-in/dstr')
35 files changed, 1250 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-init-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-init-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..d58f1a9e2b --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-init-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-init-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the Initializer of an AssignmentElement outside of a generator function body, it behaves as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([ x = yield ] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-array-invalid.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-array-invalid.js new file mode 100644 index 0000000000..17f34e04c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-array-invalid.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-nested-array-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if the lexical token sequence matched by LeftHandSideExpression cannot be parsed with no tokens left over using AssignmentPattern as the goal symbol. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([[(x, y)]] in [[[]]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-array-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-array-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..4f3e87dab4 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-array-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-nested-array-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment outside of strict mode, it behaves as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([[x[yield]]] in [[[]]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-memberexpr-optchain-prop-ref-init.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-memberexpr-optchain-prop-ref-init.js new file mode 100644 index 0000000000..f07643b8f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-memberexpr-optchain-prop-ref-init.js @@ -0,0 +1,66 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-nested-memberexpr-optchain-prop-ref-init.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression of an DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral and AssignmentTargetType(LeftHandSideExpression) is not simple Using Object (MemberExpression OptionalChain .IdentifierName Initializer) (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [optional-chaining, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + Syntax + + AssignmentElement : DestructuringAssignmentTarget Initializer_opt + DestructuringAssignmentTarget : LeftHandSideExpression + + Static Semantics: Early Errors + + OptionalExpression: + MemberExpression OptionalChain + CallExpression OptionalChain + OptionalExpression OptionalChain + + OptionalChain: + ?. [ Expression ] + ?. IdentifierName + ?. Arguments + ?. TemplateLiteral + OptionalChain [ Expression ] + OptionalChain .IdentifierName + OptionalChain Arguments + OptionalChain TemplateLiteral + + DestructuringAssignmentTarget : LeftHandSideExpression + + - It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget(LeftHandSideExpression) is not true. + + Static Semantics: IsValidSimpleAssignmentTarget + + LeftHandSideExpression : OptionalExpression + 1. Return false. + +---*/ +$DONOTEVALUATE(); +var x = {}; + +for ([x?.y = 42] in [[23]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-obj-invalid.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-obj-invalid.js new file mode 100644 index 0000000000..d12f86f553 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-obj-invalid.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-nested-obj-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if the lexical token sequence matched by LeftHandSideExpression cannot be parsed with no tokens left over using AssignmentPattern as the goal symbol. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([{ get x() {} }] in [[{}]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-obj-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-obj-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..709a3fa9f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-nested-obj-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-nested-obj-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the Initializer of a nested destructuring assignment outside of a generator function body, it behaves as a IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([{ x = yield }] in [[{}]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-put-obj-literal-optchain-prop-ref-init.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-put-obj-literal-optchain-prop-ref-init.js new file mode 100644 index 0000000000..1b05d6fd99 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-put-obj-literal-optchain-prop-ref-init.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-put-obj-literal-optchain-prop-ref-init.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression of an DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral and AssignmentTargetType(LeftHandSideExpression) is not simple Using Object (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [optional-chaining, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + Syntax + + AssignmentElement : DestructuringAssignmentTarget Initializer_opt + DestructuringAssignmentTarget : LeftHandSideExpression + + Static Semantics: Early Errors + + OptionalExpression: + MemberExpression OptionalChain + CallExpression OptionalChain + OptionalExpression OptionalChain + + OptionalChain: + ?. [ Expression ] + ?. IdentifierName + ?. Arguments + ?. TemplateLiteral + OptionalChain [ Expression ] + OptionalChain .IdentifierName + OptionalChain Arguments + OptionalChain TemplateLiteral + + DestructuringAssignmentTarget : LeftHandSideExpression + + - It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget(LeftHandSideExpression) is not true. + + Static Semantics: IsValidSimpleAssignmentTarget + + LeftHandSideExpression : OptionalExpression + 1. Return false. + +---*/ +$DONOTEVALUATE(); + +for ([{ + set y(val) { + throw new Test262Error('The property should not be accessed.'); + } +}?.y = 42] in [[23]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-target-simple-strict-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-target-simple-strict-strict.js new file mode 100644 index 0000000000..f5a4747f93 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-target-simple-strict-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-target-simple-strict.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget(LeftHandSideExpression) is false. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([arguments] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-elem-target-yield-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-target-yield-invalid-strict.js new file mode 100644 index 0000000000..d0e58a5b06 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-elem-target-yield-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-elem-target-yield-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement and outside of a generator function body, it behaves as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([ x[yield] ] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-element.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-element.js new file mode 100644 index 0000000000..cc0e130b32 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-element.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-before-element.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: An AssignmentElement may not follow an AssignmentRestElement in an AssignmentElementList. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([...x, y] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-elision.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-elision.js new file mode 100644 index 0000000000..5679bae445 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-elision.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-before-elision.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: An elision may not follow an AssignmentRestElement in an AssignmentElementList. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([...x,] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-rest.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-rest.js new file mode 100644 index 0000000000..d4f66dfce2 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-before-rest.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-before-rest.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: An AssignmentRestElement may not follow another AssignmentRestElement in an AssignmentElementList. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([...x, ...y] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-elision-invalid.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-elision-invalid.js new file mode 100644 index 0000000000..a8ecd55db9 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-elision-invalid.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-elision-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: ArrayAssignmentPattern may not include elisions following an AssignmentRestElement in a AssignmentElementList. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([...x,] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-init.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-init.js new file mode 100644 index 0000000000..b36cfaa08b --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-init.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-init.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: The AssignmentRestElement does not support an initializer. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); +var x; + +for ([...x = 1] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-array-invalid.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-array-invalid.js new file mode 100644 index 0000000000..a15928fdad --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-array-invalid.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-nested-array-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if the lexical token sequence matched by LeftHandSideExpression cannot be parsed with no tokens left over using AssignmentPattern as the goal symbol. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([...[(x, y)]] in [[[]]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-array-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-array-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..471ffd5816 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-array-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-nested-array-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment and outside of a generator function body, it should behave as an IdentifierExpression. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([...[x[yield]]] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-obj-invalid.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-obj-invalid.js new file mode 100644 index 0000000000..6e9f02e7f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-obj-invalid.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-nested-obj-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if the lexical token sequence matched by LeftHandSideExpression cannot be parsed with no tokens left over using AssignmentPattern as the goal symbol. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([...{ get x() {} }] in [[[]]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-obj-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-obj-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..9bef5247c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-nested-obj-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-nested-obj-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the Initializer of a nested destructuring assignment and outside of a generator function body, it should behave as an IdentifierExpression. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ([...{ x = yield }] in [[{}]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/array-rest-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..8eb174f956 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/array-rest-yield-ident-invalid-strict.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/array-rest-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentRestElement and outside of a generator function body, it should behave as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); +var x = {}; + +for ([...x[yield]] in [[]]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/browser.js b/js/src/tests/test262/language/statements/for-in/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/browser.js diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-id-identifier-yield-expr.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-identifier-yield-expr.js new file mode 100644 index 0000000000..e25d88f3e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-identifier-yield-expr.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-id-identifier-yield-expr.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: yield is not a valid IdentifierReference in an AssignmentProperty within generator function bodies. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding] +flags: [generated, noStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); +(function*() { + +for ({ yield } in [{}]) ; + +}); diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-id-identifier-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-identifier-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..ad47dfa927 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-identifier-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-id-identifier-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: yield is not a valid IdentifierReference in an AssignmentProperty within strict mode code. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ yield } in [{}]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-id-init-simple-strict-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-init-simple-strict-strict.js new file mode 100644 index 0000000000..df621510c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-init-simple-strict-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-id-init-simple-strict.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if IsValidSimpleAssignmentTarget of IdentifierReference is false. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ eval = 0 } in [{}]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-id-init-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-init-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..f58aecb243 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-init-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-id-init-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the Initializer of an AssignmentProperty and outside of a generator function body, it should behave as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ x = yield } in [{}]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-id-simple-strict-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-simple-strict-strict.js new file mode 100644 index 0000000000..96b86c86d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-id-simple-strict-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-id-simple-strict.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if IsValidSimpleAssignmentTarget of IdentifierReference is false. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ eval } in [{}]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-init-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-init-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..4047197760 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-init-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-prop-elem-init-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the Initializer of an AssignmentElement and outside of a generator function body, it should behave as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ x: x = yield } in [{}]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-memberexpr-optchain-prop-ref-init.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-memberexpr-optchain-prop-ref-init.js new file mode 100644 index 0000000000..91c8913af4 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-memberexpr-optchain-prop-ref-init.js @@ -0,0 +1,66 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-prop-elem-target-memberexpr-optchain-prop-ref-init.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression of an DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral and AssignmentTargetType(LeftHandSideExpression) is not simple Using Object (MemberExpression OptionalChain .IdentifierName Initializer) (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [optional-chaining, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + Syntax + + AssignmentElement : DestructuringAssignmentTarget Initializer_opt + DestructuringAssignmentTarget : LeftHandSideExpression + + Static Semantics: Early Errors + + OptionalExpression: + MemberExpression OptionalChain + CallExpression OptionalChain + OptionalExpression OptionalChain + + OptionalChain: + ?. [ Expression ] + ?. IdentifierName + ?. Arguments + ?. TemplateLiteral + OptionalChain [ Expression ] + OptionalChain .IdentifierName + OptionalChain Arguments + OptionalChain TemplateLiteral + + DestructuringAssignmentTarget : LeftHandSideExpression + + - It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget(LeftHandSideExpression) is not true. + + Static Semantics: IsValidSimpleAssignmentTarget + + LeftHandSideExpression : OptionalExpression + 1. Return false. + +---*/ +$DONOTEVALUATE(); +var y = {}; + +for ({ x: y?.z = 42 } in [{ x: 23 }]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-obj-literal-optchain-prop-ref-init.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-obj-literal-optchain-prop-ref-init.js new file mode 100644 index 0000000000..ba16f696e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-obj-literal-optchain-prop-ref-init.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-prop-elem-target-obj-literal-optchain-prop-ref-init.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression of an DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral and AssignmentTargetType(LeftHandSideExpression) is not simple Using Object (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [optional-chaining, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + Syntax + + AssignmentElement : DestructuringAssignmentTarget Initializer_opt + DestructuringAssignmentTarget : LeftHandSideExpression + + Static Semantics: Early Errors + + OptionalExpression: + MemberExpression OptionalChain + CallExpression OptionalChain + OptionalExpression OptionalChain + + OptionalChain: + ?. [ Expression ] + ?. IdentifierName + ?. Arguments + ?. TemplateLiteral + OptionalChain [ Expression ] + OptionalChain .IdentifierName + OptionalChain Arguments + OptionalChain TemplateLiteral + + DestructuringAssignmentTarget : LeftHandSideExpression + + - It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget(LeftHandSideExpression) is not true. + + Static Semantics: IsValidSimpleAssignmentTarget + + LeftHandSideExpression : OptionalExpression + 1. Return false. + +---*/ +$DONOTEVALUATE(); + +for ({ x: { + set y(val) { + throw new Test262Error('The property should not be accessed.'); + } +}?.y = 42} in [{x: 42}]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..c900a5c99e --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-elem-target-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-prop-elem-target-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement and outside of a generator function body, it should behave as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ x: x[yield] } in [{}]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-array-invalid.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-array-invalid.js new file mode 100644 index 0000000000..d7a6a95084 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-array-invalid.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-prop-nested-array-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if the lexical token sequence matched by LeftHandSideExpression cannot be parsed with no tokens left over using AssignmentPattern as the goal symbol. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ x: [(x, y)] } in [{ x: [] }]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-array-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-array-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..30d93ebabb --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-array-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-prop-nested-array-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the Initializer of a nested destructuring assignment and outside of a generator function body, it should behave as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ x: [x = yield] } in [{ x: [] }]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-obj-invalid.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-obj-invalid.js new file mode 100644 index 0000000000..bdb012fc97 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-obj-invalid.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-prop-nested-obj-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if the lexical token sequence matched by LeftHandSideExpression cannot be parsed with no tokens left over using AssignmentPattern as the goal symbol. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ x: { get x() {} } } in [{ x: {} }]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-obj-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-obj-yield-ident-invalid-strict.js new file mode 100644 index 0000000000..cb77a9348f --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-prop-nested-obj-yield-ident-invalid-strict.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-prop-nested-obj-yield-ident-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: When a `yield` token appears within the Initializer of a nested destructuring assignment and outside of a generator function body, it should behave as an IdentifierReference. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); + +for ({ x: { x = yield } } in [{ x: {} }]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/obj-rest-not-last-element-invalid.js b/js/src/tests/test262/language/statements/for-in/dstr/obj-rest-not-last-element-invalid.js new file mode 100644 index 0000000000..dc532f4d5b --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/obj-rest-not-last-element-invalid.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-not-last-element-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: Object rest element needs to be the last AssignmenProperty in ObjectAssignmentPattern. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +$DONOTEVALUATE(); +var rest, b; + +for ({...rest, b} in [{} +]) ; diff --git a/js/src/tests/test262/language/statements/for-in/dstr/shell.js b/js/src/tests/test262/language/statements/for-in/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/for-in/dstr/shell.js |