Skip to content

Commit 2c67c8f

Browse files
authored
Enforce NLT restriction after 'accessor' keyword (#52763)
1 parent d8e81bb commit 2c67c8f

File tree

6 files changed

+133
-1
lines changed

6 files changed

+133
-1
lines changed

src/compiler/parser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2684,7 +2684,6 @@ namespace Parser {
26842684
return canFollowExportModifier();
26852685
case SyntaxKind.DefaultKeyword:
26862686
return nextTokenCanFollowDefaultKeyword();
2687-
case SyntaxKind.AccessorKeyword:
26882687
case SyntaxKind.StaticKeyword:
26892688
case SyntaxKind.GetKeyword:
26902689
case SyntaxKind.SetKeyword:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts(2,5): error TS2300: Duplicate identifier 'accessor'.
2+
tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts(9,5): error TS2300: Duplicate identifier 'accessor'.
3+
tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts(12,14): error TS2300: Duplicate identifier 'accessor'.
4+
5+
6+
==== tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts (3 errors) ====
7+
class C {
8+
accessor
9+
~~~~~~~~
10+
!!! error TS2300: Duplicate identifier 'accessor'.
11+
a
12+
13+
static accessor
14+
b
15+
16+
static
17+
accessor
18+
~~~~~~~~
19+
!!! error TS2300: Duplicate identifier 'accessor'.
20+
c
21+
22+
accessor accessor
23+
~~~~~~~~
24+
!!! error TS2300: Duplicate identifier 'accessor'.
25+
d;
26+
}
27+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//// [autoAccessor11.ts]
2+
class C {
3+
accessor
4+
a
5+
6+
static accessor
7+
b
8+
9+
static
10+
accessor
11+
c
12+
13+
accessor accessor
14+
d;
15+
}
16+
17+
18+
//// [autoAccessor11.js]
19+
class C {
20+
accessor;
21+
a;
22+
static accessor;
23+
b;
24+
static accessor;
25+
c;
26+
#accessor_accessor_storage;
27+
get accessor() { return this.#accessor_accessor_storage; }
28+
set accessor(value) { this.#accessor_accessor_storage = value; }
29+
d;
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=== tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts ===
2+
class C {
3+
>C : Symbol(C, Decl(autoAccessor11.ts, 0, 0))
4+
5+
accessor
6+
>accessor : Symbol(C.accessor, Decl(autoAccessor11.ts, 0, 9))
7+
8+
a
9+
>a : Symbol(C.a, Decl(autoAccessor11.ts, 1, 12))
10+
11+
static accessor
12+
>accessor : Symbol(C.accessor, Decl(autoAccessor11.ts, 2, 5), Decl(autoAccessor11.ts, 5, 5))
13+
14+
b
15+
>b : Symbol(C.b, Decl(autoAccessor11.ts, 4, 19))
16+
17+
static
18+
accessor
19+
>accessor : Symbol(C.accessor, Decl(autoAccessor11.ts, 2, 5), Decl(autoAccessor11.ts, 5, 5))
20+
21+
c
22+
>c : Symbol(C.c, Decl(autoAccessor11.ts, 8, 12))
23+
24+
accessor accessor
25+
>accessor : Symbol(C.accessor, Decl(autoAccessor11.ts, 9, 5))
26+
27+
d;
28+
>d : Symbol(C.d, Decl(autoAccessor11.ts, 11, 21))
29+
}
30+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=== tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor11.ts ===
2+
class C {
3+
>C : C
4+
5+
accessor
6+
>accessor : any
7+
8+
a
9+
>a : any
10+
11+
static accessor
12+
>accessor : any
13+
14+
b
15+
>b : any
16+
17+
static
18+
accessor
19+
>accessor : any
20+
21+
c
22+
>c : any
23+
24+
accessor accessor
25+
>accessor : any
26+
27+
d;
28+
>d : any
29+
}
30+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @target: es2022
2+
3+
class C {
4+
accessor
5+
a
6+
7+
static accessor
8+
b
9+
10+
static
11+
accessor
12+
c
13+
14+
accessor accessor
15+
d;
16+
}

0 commit comments

Comments
 (0)