Skip to content

Commit

Permalink
Parse using[foo] as computed member expression (#15225)
Browse files Browse the repository at this point in the history
Fixes #15221
  • Loading branch information
JLHwung committed Nov 28, 2022
1 parent 65c8496 commit 4369b33
Show file tree
Hide file tree
Showing 48 changed files with 1,453 additions and 483 deletions.
13 changes: 4 additions & 9 deletions packages/babel-parser/src/parser/expression.ts
Expand Up @@ -1304,10 +1304,8 @@ export default abstract class ExpressionParser extends LValParser {
if (type === tt._function) {
this.resetPreviousNodeTrailingComments(id);
this.next();
return this.parseFunction(
return this.parseAsyncFunctionExpression(
this.startNodeAtNode(id),
undefined,
true,
);
} else if (tokenIsIdentifier(type)) {
// If the next token begins with "=", commit to parsing an async
Expand Down Expand Up @@ -2407,13 +2405,10 @@ export default abstract class ExpressionParser extends LValParser {

// Initialize empty function node.

initFunction(
node: N.BodilessFunctionOrMethodBase,
isAsync?: boolean | null,
): void {
initFunction(node: N.BodilessFunctionOrMethodBase, isAsync: boolean): void {
node.id = null;
node.generator = false;
node.async = !!isAsync;
node.async = isAsync;
}

// Parse object or class method.
Expand All @@ -2429,7 +2424,7 @@ export default abstract class ExpressionParser extends LValParser {
inClassScope: boolean = false,
): T {
this.initFunction(node, isAsync);
node.generator = !!isGenerator;
node.generator = isGenerator;
const allowModifiers = isConstructor; // For TypeScript parameter properties
this.scope.enter(
SCOPE_FUNCTION |
Expand Down

0 comments on commit 4369b33

Please sign in to comment.