Skip to content

Commit 4369b33

Browse files
authored
Parse using[foo] as computed member expression (#15225)
Fixes #15221
1 parent 65c8496 commit 4369b33

48 files changed

Lines changed: 1453 additions & 483 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/babel-parser/src/parser/expression.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,10 +1304,8 @@ export default abstract class ExpressionParser extends LValParser {
13041304
if (type === tt._function) {
13051305
this.resetPreviousNodeTrailingComments(id);
13061306
this.next();
1307-
return this.parseFunction(
1307+
return this.parseAsyncFunctionExpression(
13081308
this.startNodeAtNode(id),
1309-
undefined,
1310-
true,
13111309
);
13121310
} else if (tokenIsIdentifier(type)) {
13131311
// If the next token begins with "=", commit to parsing an async
@@ -2407,13 +2405,10 @@ export default abstract class ExpressionParser extends LValParser {
24072405

24082406
// Initialize empty function node.
24092407

2410-
initFunction(
2411-
node: N.BodilessFunctionOrMethodBase,
2412-
isAsync?: boolean | null,
2413-
): void {
2408+
initFunction(node: N.BodilessFunctionOrMethodBase, isAsync: boolean): void {
24142409
node.id = null;
24152410
node.generator = false;
2416-
node.async = !!isAsync;
2411+
node.async = isAsync;
24172412
}
24182413

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

0 commit comments

Comments
 (0)