mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fix crash when private id in array assignment (#53665)
This commit is contained in:
parent
e83d61398e
commit
a720ba921f
@ -2981,11 +2981,11 @@ export function transformClassFields(context: TransformationContext): (x: Source
|
||||
}
|
||||
|
||||
function visitArrayAssignmentElement(node: Expression): Expression {
|
||||
Debug.assertNode(node, isArrayBindingOrAssignmentElement);
|
||||
if (isSpreadElement(node)) return visitAssignmentRestElement(node);
|
||||
if (!isOmittedExpression(node)) return visitAssignmentElement(node);
|
||||
if (isArrayBindingOrAssignmentElement(node)) {
|
||||
if (isSpreadElement(node)) return visitAssignmentRestElement(node);
|
||||
if (!isOmittedExpression(node)) return visitAssignmentElement(node);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
|
||||
}
|
||||
|
||||
function visitAssignmentProperty(node: PropertyAssignment) {
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts(1,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts(1,8): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts (2 errors) ====
|
||||
[#abc]=
|
||||
~~~~
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
//// [parserPrivateIdentifierInArrayAssignment.ts]
|
||||
[#abc]=
|
||||
|
||||
|
||||
//// [parserPrivateIdentifierInArrayAssignment.js]
|
||||
#abc = [0];
|
||||
@ -0,0 +1,4 @@
|
||||
=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts ===
|
||||
|
||||
[#abc]=
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts ===
|
||||
[#abc]=
|
||||
>[#abc]= : any
|
||||
>[#abc] : [any]
|
||||
|
||||
> : any
|
||||
|
||||
1
tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts
Executable file
1
tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts
Executable file
@ -0,0 +1 @@
|
||||
[#abc]=
|
||||
Loading…
x
Reference in New Issue
Block a user