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

Parse using[foo] as computed member expression #15225

Merged
merged 13 commits into from Nov 28, 2022
Merged
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