Enforce NLT restriction after 'accessor' keyword (#52763)

This commit is contained in:
Ron Buckton 2023-02-15 12:51:25 -05:00 committed by GitHub
parent d8e81bbf6e
commit 2c67c8f756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 133 additions and 1 deletions

View File

@ -2684,7 +2684,6 @@ namespace Parser {
return canFollowExportModifier();
case SyntaxKind.DefaultKeyword:
return nextTokenCanFollowDefaultKeyword();
case SyntaxKind.AccessorKeyword:
case SyntaxKind.StaticKeyword:
case SyntaxKind.GetKeyword:
case SyntaxKind.SetKeyword:

View File

@ -0,0 +1,27 @@
tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts(2,5): error TS2300: Duplicate identifier 'accessor'.
tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts(9,5): error TS2300: Duplicate identifier 'accessor'.
tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts(12,14): error TS2300: Duplicate identifier 'accessor'.
==== tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts (3 errors) ====
class C {
accessor
~~~~~~~~
!!! error TS2300: Duplicate identifier 'accessor'.
a
static accessor
b
static
accessor
~~~~~~~~
!!! error TS2300: Duplicate identifier 'accessor'.
c
accessor accessor
~~~~~~~~
!!! error TS2300: Duplicate identifier 'accessor'.
d;
}

View File

@ -0,0 +1,30 @@
//// [autoAccessor11.ts]
class C {
accessor
a
static accessor
b
static
accessor
c
accessor accessor
d;
}
//// [autoAccessor11.js]
class C {
accessor;
a;
static accessor;
b;
static accessor;
c;
#accessor_accessor_storage;
get accessor() { return this.#accessor_accessor_storage; }
set accessor(value) { this.#accessor_accessor_storage = value; }
d;
}

View File

@ -0,0 +1,30 @@
=== tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts ===
class C {
>C : Symbol(C, Decl(autoAccessor11.ts, 0, 0))
accessor
>accessor : Symbol(C.accessor, Decl(autoAccessor11.ts, 0, 9))
a
>a : Symbol(C.a, Decl(autoAccessor11.ts, 1, 12))
static accessor
>accessor : Symbol(C.accessor, Decl(autoAccessor11.ts, 2, 5), Decl(autoAccessor11.ts, 5, 5))
b
>b : Symbol(C.b, Decl(autoAccessor11.ts, 4, 19))
static
accessor
>accessor : Symbol(C.accessor, Decl(autoAccessor11.ts, 2, 5), Decl(autoAccessor11.ts, 5, 5))
c
>c : Symbol(C.c, Decl(autoAccessor11.ts, 8, 12))
accessor accessor
>accessor : Symbol(C.accessor, Decl(autoAccessor11.ts, 9, 5))
d;
>d : Symbol(C.d, Decl(autoAccessor11.ts, 11, 21))
}

View File

@ -0,0 +1,30 @@
=== tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts ===
class C {
>C : C
accessor
>accessor : any
a
>a : any
static accessor
>accessor : any
b
>b : any
static
accessor
>accessor : any
c
>c : any
accessor accessor
>accessor : any
d;
>d : any
}

View File

@ -0,0 +1,16 @@
// @target: es2022
class C {
accessor
a
static accessor
b
static
accessor
c
accessor accessor
d;
}