Added case to verify invalid syntax when using private field on object destructuring

This commit is contained in:
Caio Lima 2019-02-08 13:07:30 -02:00 committed by Rick Waldron
parent 185e590880
commit b8e92c2341
3 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// Copyright (C) 2019 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Acessing private field from object destructuring pattern is not a valid syntax
info: |
Updated Productions
ObjectAssignmentPattern[Yield, Await]:
{}
{AssignmentRestProperty[?Yield, ?Await]}
{AssignmentPropertyList[?Yield, ?Await]}
{AssignmentPropertyList[?Yield, ?Await],AssignmentRestProperty[?Yield, ?Await]opt}
template: syntax/invalid
features: [class-fields-private]
---*/
//- elements
#x = 1;
destructureX() {
const { #x: x } = this;
return x;
}

View File

@ -0,0 +1,33 @@
// This file was procedurally generated from the following sources:
// - src/class-elements/grammar-private-field-on-object-destructuring.case
// - src/class-elements/syntax/invalid/cls-expr-elements-invalid-syntax.template
/*---
description: Acessing private field from object destructuring pattern is not a valid syntax (class expression)
esid: prod-ClassElement
features: [class-fields-private, class]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Updated Productions
ObjectAssignmentPattern[Yield, Await]:
{}
{AssignmentRestProperty[?Yield, ?Await]}
{AssignmentPropertyList[?Yield, ?Await]}
{AssignmentPropertyList[?Yield, ?Await],AssignmentRestProperty[?Yield, ?Await]opt}
---*/
$DONOTEVALUATE();
var C = class {
#x = 1;
destructureX() {
const { #x: x } = this;
return x;
}
};

View File

@ -0,0 +1,33 @@
// This file was procedurally generated from the following sources:
// - src/class-elements/grammar-private-field-on-object-destructuring.case
// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template
/*---
description: Acessing private field from object destructuring pattern is not a valid syntax (class declaration)
esid: prod-ClassElement
features: [class-fields-private, class]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Updated Productions
ObjectAssignmentPattern[Yield, Await]:
{}
{AssignmentRestProperty[?Yield, ?Await]}
{AssignmentPropertyList[?Yield, ?Await]}
{AssignmentPropertyList[?Yield, ?Await],AssignmentRestProperty[?Yield, ?Await]opt}
---*/
$DONOTEVALUATE();
class C {
#x = 1;
destructureX() {
const { #x: x } = this;
return x;
}
}