Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when private id in array assignment #53665

Merged
merged 1 commit into from Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/compiler/transformers/classFields.ts
Expand Up @@ -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) {
Expand Down
@@ -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

@@ -0,0 +1 @@
[#abc]=