Refactor yield await classification (#12230)
* fix: incomplete ParamKind declaration * refactor: add expression scope handler * test: update test262 allowlist * chore: cleanup * fix: push expression scope for function body * fix: push new expression scope for initializer and static block * test: add more test cases * fix flow error * refactor: remove unecessary expression scope * fix: parameter initializer error should not cross expression scope boundary * chore: cleanup outdated comments * fix: do not record async arrow error on ParameterDeclaration * Update packages/babel-parser/src/util/expression-scope.js Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> * polish: clear ancestry declaration error on validate Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import type { Options } from "../options";
|
||||
import type State from "../tokenizer/state";
|
||||
import type { PluginsMap } from "./index";
|
||||
import type ScopeHandler from "../util/scope";
|
||||
import type ExpressionScopeHandler from "../util/expression-scope";
|
||||
import type ClassScopeHandler from "../util/class-scope";
|
||||
import type ProductionParameterHandler from "../util/production-parameter";
|
||||
|
||||
@@ -14,6 +15,7 @@ export default class BaseParser {
|
||||
scope: ScopeHandler<*>;
|
||||
classScope: ClassScopeHandler;
|
||||
prodParam: ProductionParameterHandler;
|
||||
expressionScope: ExpressionScopeHandler;
|
||||
plugins: PluginsMap;
|
||||
filename: ?string;
|
||||
sawUnambiguousESM: boolean = false;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// @flow
|
||||
/* eslint sort-keys: "error" */
|
||||
|
||||
/**
|
||||
* @module parser/error-message
|
||||
*/
|
||||
|
||||
// The Errors key follows https://cs.chromium.org/chromium/src/v8/src/common/message-template.h unless it does not exist
|
||||
export const ErrorMessages = Object.freeze({
|
||||
AccessorIsGenerator: "A %0ter cannot be a generator",
|
||||
|
||||
@@ -49,6 +49,11 @@ import {
|
||||
PARAM,
|
||||
functionFlags,
|
||||
} from "../util/production-parameter";
|
||||
import {
|
||||
newArrowHeadScope,
|
||||
newAsyncArrowScope,
|
||||
newExpressionScope,
|
||||
} from "../util/expression-scope.js";
|
||||
import { Errors } from "./error";
|
||||
|
||||
export default class ExpressionParser extends LValParser {
|
||||
@@ -581,15 +586,10 @@ export default class ExpressionParser extends LValParser {
|
||||
stop: false,
|
||||
};
|
||||
do {
|
||||
const oldMaybeInAsyncArrowHead = this.state.maybeInAsyncArrowHead;
|
||||
if (state.maybeAsyncArrow) {
|
||||
this.state.maybeInAsyncArrowHead = true;
|
||||
}
|
||||
base = this.parseSubscript(base, startPos, startLoc, noCalls, state);
|
||||
|
||||
// After parsing a subscript, this isn't "async" for sure.
|
||||
state.maybeAsyncArrow = false;
|
||||
this.state.maybeInAsyncArrowHead = oldMaybeInAsyncArrowHead;
|
||||
} while (!state.stop);
|
||||
return base;
|
||||
}
|
||||
@@ -714,16 +714,15 @@ export default class ExpressionParser extends LValParser {
|
||||
optional: boolean,
|
||||
): N.Expression {
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
|
||||
this.next(); // eat `(`
|
||||
|
||||
let node = this.startNodeAt(startPos, startLoc);
|
||||
node.callee = base;
|
||||
if (state.maybeAsyncArrow) {
|
||||
this.expressionScope.enter(newAsyncArrowScope());
|
||||
}
|
||||
|
||||
if (state.optionalChainMember) {
|
||||
node.optional = optional;
|
||||
@@ -743,47 +742,17 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
if (state.maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
|
||||
state.stop = true;
|
||||
|
||||
this.expressionScope.validateAsPattern();
|
||||
this.expressionScope.exit();
|
||||
node = this.parseAsyncArrowFromCallExpression(
|
||||
this.startNodeAt(startPos, startLoc),
|
||||
node,
|
||||
);
|
||||
this.checkYieldAwaitInDefaultParams();
|
||||
this.state.yieldPos = oldYieldPos;
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
} else {
|
||||
this.toReferencedArguments(node);
|
||||
|
||||
// We keep the old value if it isn't null, for cases like
|
||||
// (x = async(yield)) => {}
|
||||
//
|
||||
// Hi developer of the future :) If you are implementing generator
|
||||
// arrow functions, please read the note below about "await" and
|
||||
// verify if the same logic is needed for yield.
|
||||
if (oldYieldPos !== -1) this.state.yieldPos = oldYieldPos;
|
||||
|
||||
// Await is trickier than yield. When parsing a possible arrow function
|
||||
// (e.g. something starting with `async(`) we don't know if its possible
|
||||
// parameters will actually be inside an async arrow function or if it is
|
||||
// a normal call expression.
|
||||
// If it ended up being a call expression, if we are in a context where
|
||||
// await expression are disallowed (and thus "await" is an identifier)
|
||||
// we must be careful not to leak this.state.awaitPos to an even outer
|
||||
// context, where "await" could not be an identifier.
|
||||
// For example, this code is valid because "await" isn't directly inside
|
||||
// an async function:
|
||||
//
|
||||
// async function a() {
|
||||
// function b(param = async (await)) {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
if (
|
||||
(!this.isAwaitAllowed() && !oldMaybeInArrowParameters) ||
|
||||
oldAwaitPos !== -1
|
||||
) {
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
if (state.maybeAsyncArrow) {
|
||||
this.expressionScope.exit();
|
||||
}
|
||||
this.toReferencedArguments(node);
|
||||
}
|
||||
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
@@ -1206,24 +1175,15 @@ export default class ExpressionParser extends LValParser {
|
||||
// async [no LineTerminator here] AsyncArrowBindingIdentifier[?Yield] [no LineTerminator here] => AsyncConciseBody[?In]
|
||||
parseAsyncArrowUnaryFunction(id: N.Expression): N.ArrowFunctionExpression {
|
||||
const node = this.startNodeAtNode(id);
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldMaybeInAsyncArrowHead = this.state.maybeInAsyncArrowHead;
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.state.maybeInAsyncArrowHead = true;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
// We don't need to push a new ParameterDeclarationScope here since we are sure
|
||||
// 1) it is an async arrow, 2) no biding pattern is allowed in params
|
||||
this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
|
||||
const params = [this.parseIdentifier()];
|
||||
this.prodParam.exit();
|
||||
if (this.hasPrecedingLineBreak()) {
|
||||
this.raise(this.state.pos, Errors.LineTerminatorBeforeArrow);
|
||||
}
|
||||
this.expect(tt.arrow);
|
||||
this.checkYieldAwaitInDefaultParams();
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
this.state.maybeInAsyncArrowHead = oldMaybeInAsyncArrowHead;
|
||||
this.state.yieldPos = oldYieldPos;
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
// let foo = async bar => {};
|
||||
this.parseArrowExpression(node, params, true);
|
||||
return node;
|
||||
@@ -1393,14 +1353,11 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
let val;
|
||||
this.next(); // eat `(`
|
||||
this.expressionScope.enter(newArrowHeadScope());
|
||||
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
this.state.inFSharpPipelineDirectBody = false;
|
||||
|
||||
const innerStartPos = this.state.start;
|
||||
@@ -1462,12 +1419,8 @@ export default class ExpressionParser extends LValParser {
|
||||
this.shouldParseArrow() &&
|
||||
(arrowNode = this.parseArrow(arrowNode))
|
||||
) {
|
||||
if (!this.isAwaitAllowed() && !this.state.maybeInAsyncArrowHead) {
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
}
|
||||
this.checkYieldAwaitInDefaultParams();
|
||||
this.state.yieldPos = oldYieldPos;
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
this.expressionScope.validateAsPattern();
|
||||
this.expressionScope.exit();
|
||||
for (const param of exprList) {
|
||||
if (param.extra && param.extra.parenthesized) {
|
||||
this.unexpected(param.extra.parenStart);
|
||||
@@ -1477,11 +1430,7 @@ export default class ExpressionParser extends LValParser {
|
||||
this.parseArrowExpression(arrowNode, exprList, false);
|
||||
return arrowNode;
|
||||
}
|
||||
|
||||
// We keep the old value if it isn't null, for cases like
|
||||
// (x = (yield)) => {}
|
||||
if (oldYieldPos !== -1) this.state.yieldPos = oldYieldPos;
|
||||
if (oldAwaitPos !== -1) this.state.awaitPos = oldAwaitPos;
|
||||
this.expressionScope.exit();
|
||||
|
||||
if (!exprList.length) {
|
||||
this.unexpected(this.state.lastTokStart);
|
||||
@@ -2016,11 +1965,6 @@ export default class ExpressionParser extends LValParser {
|
||||
type: string,
|
||||
inClassScope: boolean = false,
|
||||
): T {
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
|
||||
this.initFunction(node, isAsync);
|
||||
node.generator = !!isGenerator;
|
||||
const allowModifiers = isConstructor; // For TypeScript parameter properties
|
||||
@@ -2036,9 +1980,6 @@ export default class ExpressionParser extends LValParser {
|
||||
this.prodParam.exit();
|
||||
this.scope.exit();
|
||||
|
||||
this.state.yieldPos = oldYieldPos;
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -2089,23 +2030,17 @@ export default class ExpressionParser extends LValParser {
|
||||
this.prodParam.enter(flags);
|
||||
this.initFunction(node, isAsync);
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
|
||||
if (params) {
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.setArrowFunctionParameters(node, params, trailingCommaPos);
|
||||
}
|
||||
this.state.maybeInArrowParameters = false;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
this.parseFunctionBody(node, true);
|
||||
|
||||
this.prodParam.exit();
|
||||
this.scope.exit();
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
this.state.yieldPos = oldYieldPos;
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
|
||||
return this.finishNode(node, "ArrowFunctionExpression");
|
||||
}
|
||||
@@ -2135,8 +2070,7 @@ export default class ExpressionParser extends LValParser {
|
||||
isMethod?: boolean = false,
|
||||
): void {
|
||||
const isExpression = allowExpression && !this.match(tt.braceL);
|
||||
const oldInParameters = this.state.inParameters;
|
||||
this.state.inParameters = false;
|
||||
this.expressionScope.enter(newExpressionScope());
|
||||
|
||||
if (isExpression) {
|
||||
// https://tc39.es/ecma262/#prod-ExpressionBody
|
||||
@@ -2196,10 +2130,9 @@ export default class ExpressionParser extends LValParser {
|
||||
},
|
||||
);
|
||||
this.prodParam.exit();
|
||||
this.expressionScope.exit();
|
||||
this.state.labels = oldLabels;
|
||||
}
|
||||
|
||||
this.state.inParameters = oldInParameters;
|
||||
}
|
||||
|
||||
isSimpleParamList(
|
||||
@@ -2381,12 +2314,11 @@ export default class ExpressionParser extends LValParser {
|
||||
if (this.prodParam.hasAwait) {
|
||||
this.raise(startLoc, Errors.AwaitBindingIdentifier);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.state.awaitPos === -1 &&
|
||||
(this.state.maybeInAsyncArrowHead || this.isAwaitAllowed())
|
||||
) {
|
||||
this.state.awaitPos = this.state.start;
|
||||
} else {
|
||||
this.expressionScope.recordAsyncArrowParametersError(
|
||||
startLoc,
|
||||
Errors.AwaitBindingIdentifier,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2434,11 +2366,11 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
this.next();
|
||||
|
||||
if (this.state.inParameters) {
|
||||
this.raise(node.start, Errors.AwaitExpressionFormalParameter);
|
||||
} else if (this.state.awaitPos === -1) {
|
||||
this.state.awaitPos = node.start;
|
||||
}
|
||||
this.expressionScope.recordParameterInitializerError(
|
||||
node.start,
|
||||
Errors.AwaitExpressionFormalParameter,
|
||||
);
|
||||
|
||||
if (this.eat(tt.star)) {
|
||||
this.raise(node.start, Errors.ObsoleteAwaitStar);
|
||||
}
|
||||
@@ -2478,11 +2410,10 @@ export default class ExpressionParser extends LValParser {
|
||||
parseYield(): N.YieldExpression {
|
||||
const node = this.startNode();
|
||||
|
||||
if (this.state.inParameters) {
|
||||
this.raise(node.start, Errors.YieldInParameter);
|
||||
} else if (this.state.yieldPos === -1) {
|
||||
this.state.yieldPos = node.start;
|
||||
}
|
||||
this.expressionScope.recordParameterInitializerError(
|
||||
node.start,
|
||||
Errors.YieldInParameter,
|
||||
);
|
||||
|
||||
this.next();
|
||||
if (
|
||||
|
||||
@@ -8,6 +8,7 @@ import StatementParser from "./statement";
|
||||
import { SCOPE_PROGRAM } from "../util/scopeflags";
|
||||
import ScopeHandler from "../util/scope";
|
||||
import ClassScopeHandler from "../util/class-scope";
|
||||
import ExpressionScopeHandler from "../util/expression-scope";
|
||||
import ProductionParameterHandler, {
|
||||
PARAM_AWAIT,
|
||||
PARAM,
|
||||
@@ -34,6 +35,7 @@ export default class Parser extends StatementParser {
|
||||
this.scope = new ScopeHandler(this.raise.bind(this), this.inModule);
|
||||
this.prodParam = new ProductionParameterHandler();
|
||||
this.classScope = new ClassScopeHandler(this.raise.bind(this));
|
||||
this.expressionScope = new ExpressionScopeHandler(this.raise.bind(this));
|
||||
this.plugins = pluginsMap(this.options.plugins);
|
||||
this.filename = options.sourceFilename;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ import {
|
||||
} from "../util/scopeflags";
|
||||
import { ExpressionErrors } from "./util";
|
||||
import { PARAM, functionFlags } from "../util/production-parameter";
|
||||
import {
|
||||
newExpressionScope,
|
||||
newParameterDeclarationScope,
|
||||
} from "../util/expression-scope";
|
||||
|
||||
const loopLabel = { kind: "loop" },
|
||||
switchLabel = { kind: "switch" };
|
||||
@@ -1077,11 +1081,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
}
|
||||
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.maybeInArrowParameters = false;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
this.scope.enter(SCOPE_FUNCTION);
|
||||
this.prodParam.enter(functionFlags(isAsync, node.generator));
|
||||
|
||||
@@ -1113,9 +1113,6 @@ export default class StatementParser extends ExpressionParser {
|
||||
}
|
||||
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
this.state.yieldPos = oldYieldPos;
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -1124,10 +1121,8 @@ export default class StatementParser extends ExpressionParser {
|
||||
}
|
||||
|
||||
parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {
|
||||
const oldInParameters = this.state.inParameters;
|
||||
this.state.inParameters = true;
|
||||
|
||||
this.expect(tt.parenL);
|
||||
this.expressionScope.enter(newParameterDeclarationScope());
|
||||
node.params = this.parseBindingList(
|
||||
tt.parenR,
|
||||
charCodes.rightParenthesis,
|
||||
@@ -1135,8 +1130,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
allowModifiers,
|
||||
);
|
||||
|
||||
this.state.inParameters = oldInParameters;
|
||||
this.checkYieldAwaitInDefaultParams();
|
||||
this.expressionScope.exit();
|
||||
}
|
||||
|
||||
registerFunctionStatementId(node: N.Function): void {
|
||||
@@ -1529,6 +1523,9 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.expectPlugin("classStaticBlock", member.start);
|
||||
// Start a new lexical scope
|
||||
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
||||
// Start a new expression scope, this is required for parsing edge cases like:
|
||||
// async (x = class { static { await; } }) => {}
|
||||
this.expressionScope.enter(newExpressionScope());
|
||||
// Start a new scope with regard to loop labels
|
||||
const oldLabels = this.state.labels;
|
||||
this.state.labels = [];
|
||||
@@ -1538,6 +1535,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
const body = (member.body = []);
|
||||
this.parseBlockOrModuleBlockBody(body, undefined, false, tt.braceR);
|
||||
this.prodParam.exit();
|
||||
this.expressionScope.exit();
|
||||
this.scope.exit();
|
||||
this.state.labels = oldLabels;
|
||||
classBody.body.push(this.finishNode<N.StaticBlock>(member, "StaticBlock"));
|
||||
@@ -1638,42 +1636,34 @@ export default class StatementParser extends ExpressionParser {
|
||||
methodOrProp: N.ClassMethod | N.ClassProperty,
|
||||
): void {}
|
||||
|
||||
// https://tc39.es/proposal-class-fields/#prod-FieldDefinition
|
||||
parseClassPrivateProperty(
|
||||
node: N.ClassPrivateProperty,
|
||||
): N.ClassPrivateProperty {
|
||||
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
||||
this.prodParam.enter(PARAM);
|
||||
|
||||
node.value = this.eat(tt.eq) ? this.parseMaybeAssignAllowIn() : null;
|
||||
this.parseInitializer(node);
|
||||
this.semicolon();
|
||||
this.prodParam.exit();
|
||||
|
||||
this.scope.exit();
|
||||
|
||||
return this.finishNode(node, "ClassPrivateProperty");
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-class-fields/#prod-FieldDefinition
|
||||
parseClassProperty(node: N.ClassProperty): N.ClassProperty {
|
||||
if (!node.typeAnnotation) {
|
||||
if (!node.typeAnnotation || this.match(tt.eq)) {
|
||||
this.expectPlugin("classProperties");
|
||||
}
|
||||
|
||||
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
||||
this.prodParam.enter(PARAM);
|
||||
|
||||
if (this.match(tt.eq)) {
|
||||
this.expectPlugin("classProperties");
|
||||
this.next();
|
||||
node.value = this.parseMaybeAssignAllowIn();
|
||||
} else {
|
||||
node.value = null;
|
||||
}
|
||||
this.parseInitializer(node);
|
||||
this.semicolon();
|
||||
return this.finishNode(node, "ClassProperty");
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-class-fields/#prod-Initializer
|
||||
parseInitializer(node: N.ClassProperty | N.ClassPrivateProperty): void {
|
||||
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
||||
this.expressionScope.enter(newExpressionScope());
|
||||
this.prodParam.enter(PARAM);
|
||||
node.value = this.eat(tt.eq) ? this.parseMaybeAssignAllowIn() : null;
|
||||
this.expressionScope.exit();
|
||||
this.prodParam.exit();
|
||||
this.scope.exit();
|
||||
|
||||
return this.finishNode(node, "ClassProperty");
|
||||
}
|
||||
|
||||
parseClassId(
|
||||
@@ -1998,7 +1988,6 @@ export default class StatementParser extends ExpressionParser {
|
||||
// check for keywords used as local names
|
||||
this.checkReservedWord(local.name, local.start, true, false);
|
||||
// check if export is defined
|
||||
// $FlowIgnore
|
||||
this.scope.checkLocalExport(local);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,18 +164,6 @@ export default class UtilParser extends Tokenizer {
|
||||
}
|
||||
}
|
||||
|
||||
checkYieldAwaitInDefaultParams() {
|
||||
if (
|
||||
this.state.yieldPos !== -1 &&
|
||||
(this.state.awaitPos === -1 || this.state.yieldPos < this.state.awaitPos)
|
||||
) {
|
||||
this.raise(this.state.yieldPos, Errors.YieldBindingIdentifier);
|
||||
}
|
||||
if (this.state.awaitPos !== -1) {
|
||||
this.raise(this.state.awaitPos, Errors.AwaitBindingIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
// tryParse will clone parser state.
|
||||
// It is expensive and should be used with cautions
|
||||
tryParse<T: Node | $ReadOnlyArray<Node>>(
|
||||
|
||||
@@ -1649,11 +1649,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||
const oldYieldPos = this.state.yieldPos;
|
||||
const oldAwaitPos = this.state.awaitPos;
|
||||
this.state.maybeInArrowParameters = true;
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
|
||||
const res: ?N.ArrowFunctionExpression = this.tsTryParseAndCatch(() => {
|
||||
const node: N.ArrowFunctionExpression = this.startNodeAt(
|
||||
@@ -1669,8 +1665,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
});
|
||||
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
this.state.yieldPos = oldYieldPos;
|
||||
this.state.awaitPos = oldAwaitPos;
|
||||
|
||||
if (!res) {
|
||||
return undefined;
|
||||
|
||||
@@ -57,13 +57,7 @@ export default class State {
|
||||
noArrowParamsConversionAt: number[] = [];
|
||||
|
||||
// Flags to track
|
||||
inParameters: boolean = false;
|
||||
maybeInArrowParameters: boolean = false;
|
||||
// This flag is used to track async arrow head across function declarations.
|
||||
// e.g. async (foo = function (await) {}) => {}
|
||||
// When parsing `await` in this expression, `maybeInAsyncArrowHead` is true
|
||||
// but `maybeInArrowParameters` is false
|
||||
maybeInAsyncArrowHead: boolean = false;
|
||||
inPipeline: boolean = false;
|
||||
inType: boolean = false;
|
||||
noAnonFunctionType: boolean = false;
|
||||
@@ -94,10 +88,6 @@ export default class State {
|
||||
// where @foo belongs to the outer class and @bar to the inner
|
||||
decoratorStack: Array<Array<N.Decorator>> = [[]];
|
||||
|
||||
// Positions to delayed-check that yield/await does not exist in default parameters.
|
||||
yieldPos: number = -1;
|
||||
awaitPos: number = -1;
|
||||
|
||||
// Comment store.
|
||||
comments: Array<N.Comment> = [];
|
||||
|
||||
|
||||
189
packages/babel-parser/src/util/expression-scope.js
Normal file
189
packages/babel-parser/src/util/expression-scope.js
Normal file
@@ -0,0 +1,189 @@
|
||||
// @flow
|
||||
|
||||
/*:: declare var invariant; */
|
||||
/**
|
||||
* @module util/expression-scope
|
||||
|
||||
ExpressionScope is used to track declaration errors in these ambiguous patterns:
|
||||
|
||||
- CoverParenthesizedExpressionAndArrowParameterList
|
||||
e.g. we don't know if `({ x })` is an parenthesized expression or an
|
||||
arrow function parameters until we see an `=>` after `)`.
|
||||
|
||||
- CoverCallExpressionAndAsyncArrowHead
|
||||
e.g. we don't know if `async({ x })` is a call expression or an async arrow
|
||||
function parameters until we see an `=>` after `)`
|
||||
|
||||
The following declaration errors (@see parser/error-message) will be recorded in
|
||||
some expression scopes and thrown later when we know what the ambigous pattern is
|
||||
|
||||
- AwaitBindingIdentifier
|
||||
- AwaitExpressionFormalParameter
|
||||
- YieldInParameter
|
||||
|
||||
There are four different expression scope
|
||||
- Expression
|
||||
A general scope that represents program / function body / static block. No errors
|
||||
will be recorded nor thrown in this scope.
|
||||
|
||||
- MaybeArrowParameterDeclaration
|
||||
A scope that represents ambiguous arrow head e.g. `(x)`. Errors will be recorded
|
||||
alongside parent scopes and thrown when `ExpressionScopeHandler#validateAsPattern`
|
||||
is called.
|
||||
|
||||
- MaybeAsyncArrowParameterDeclaration
|
||||
A scope that represents ambiguous async arrow head e.g. `async(x)`. Errors will
|
||||
be recorded alongside parent scopes and thrown when
|
||||
`ExpressionScopeHandler#validateAsPattern` is called.
|
||||
|
||||
- ParameterDeclaration
|
||||
A scope that represents unambiguous function parameters `function(x)`. Errors
|
||||
recorded in this scope will be thrown immediately. No errors will be recorded in
|
||||
this scope.
|
||||
|
||||
// @see {@link https://docs.google.com/document/d/1FAvEp9EUK-G8kHfDIEo_385Hs2SUBCYbJ5H-NnLvq8M|V8 Expression Scope design docs}
|
||||
*/
|
||||
|
||||
const kExpression = 0,
|
||||
kMaybeArrowParameterDeclaration = 1,
|
||||
kMaybeAsyncArrowParameterDeclaration = 2,
|
||||
kParameterDeclaration = 3;
|
||||
|
||||
type ExpressionScopeType = 0 | 1 | 2 | 3;
|
||||
|
||||
type raiseFunction = (number, string, ...any) => void;
|
||||
|
||||
class ExpressionScope {
|
||||
type: ExpressionScopeType;
|
||||
|
||||
constructor(type: ExpressionScopeType = kExpression) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
canBeArrowParameterDeclaration() {
|
||||
return (
|
||||
this.type === kMaybeAsyncArrowParameterDeclaration ||
|
||||
this.type === kMaybeArrowParameterDeclaration
|
||||
);
|
||||
}
|
||||
|
||||
isCertainlyParameterDeclaration() {
|
||||
return this.type === kParameterDeclaration;
|
||||
}
|
||||
}
|
||||
|
||||
class ArrowHeadParsingScope extends ExpressionScope {
|
||||
errors: Map</* pos */ number, /* message */ string> = new Map();
|
||||
constructor(type: 1 | 2) {
|
||||
super(type);
|
||||
}
|
||||
recordDeclarationError(pos: number, message: string) {
|
||||
this.errors.set(pos, message);
|
||||
}
|
||||
clearDeclarationError(pos: number) {
|
||||
this.errors.delete(pos);
|
||||
}
|
||||
iterateErrors(iterator: (message: string, pos: number) => void) {
|
||||
this.errors.forEach(iterator);
|
||||
}
|
||||
}
|
||||
|
||||
export default class ExpressionScopeHandler {
|
||||
stack: Array<ExpressionScope> = [new ExpressionScope()];
|
||||
declare raise: raiseFunction;
|
||||
constructor(raise: raiseFunction) {
|
||||
this.raise = raise;
|
||||
}
|
||||
enter(scope: ExpressionScope) {
|
||||
this.stack.push(scope);
|
||||
}
|
||||
|
||||
exit() {
|
||||
this.stack.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Record likely parameter initializer errors
|
||||
*
|
||||
* When current scope is a ParameterDeclaration, the error will be thrown immediately,
|
||||
* otherwise it will be recorded to any ancestry MaybeArrowParameterDeclaration and
|
||||
* MaybeAsyncArrowParameterDeclaration scope until an Expression scope is seen.
|
||||
* @param {number} pos Error position
|
||||
* @param {string} message Error message
|
||||
* @memberof ExpressionScopeHandler
|
||||
*/
|
||||
recordParameterInitializerError(pos: number, message: string): void {
|
||||
const { stack } = this;
|
||||
let i = stack.length - 1;
|
||||
let scope: ExpressionScope = stack[i];
|
||||
while (!scope.isCertainlyParameterDeclaration()) {
|
||||
if (scope.canBeArrowParameterDeclaration()) {
|
||||
/*:: invariant(scope instanceof ArrowHeadParsingScope) */
|
||||
scope.recordDeclarationError(pos, message);
|
||||
} else {
|
||||
/*:: invariant(scope.type == kExpression) */
|
||||
// Type-Expression is the boundary where initializer error can populate to
|
||||
return;
|
||||
}
|
||||
scope = stack[--i];
|
||||
}
|
||||
/* eslint-disable @babel/development-internal/dry-error-messages */
|
||||
this.raise(pos, message);
|
||||
}
|
||||
/**
|
||||
* Record likely async arrow parameter errors
|
||||
*
|
||||
* Errors will be recorded to any ancestry MaybeAsyncArrowParameterDeclaration
|
||||
* scope until an Expression scope is seen.
|
||||
* @param {number} pos
|
||||
* @param {string} message
|
||||
* @memberof ExpressionScopeHandler
|
||||
*/
|
||||
recordAsyncArrowParametersError(pos: number, message: string): void {
|
||||
const { stack } = this;
|
||||
let i = stack.length - 1;
|
||||
let scope: ExpressionScope = stack[i];
|
||||
while (scope.canBeArrowParameterDeclaration()) {
|
||||
if (scope.type === kMaybeAsyncArrowParameterDeclaration) {
|
||||
/*:: invariant(scope instanceof ArrowHeadParsingScope) */
|
||||
scope.recordDeclarationError(pos, message);
|
||||
}
|
||||
scope = stack[--i];
|
||||
}
|
||||
}
|
||||
|
||||
validateAsPattern(): void {
|
||||
const { stack } = this;
|
||||
const currentScope = stack[stack.length - 1];
|
||||
if (!currentScope.canBeArrowParameterDeclaration()) return;
|
||||
/*:: invariant(currentScope instanceof ArrowHeadParsingScope) */
|
||||
currentScope.iterateErrors((message, pos) => {
|
||||
/* eslint-disable @babel/development-internal/dry-error-messages */
|
||||
this.raise(pos, message);
|
||||
// iterate from parent scope
|
||||
let i = stack.length - 2;
|
||||
let scope = stack[i];
|
||||
while (scope.canBeArrowParameterDeclaration()) {
|
||||
/*:: invariant(scope instanceof ArrowHeadParsingScope) */
|
||||
scope.clearDeclarationError(pos);
|
||||
scope = stack[--i];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function newParameterDeclarationScope() {
|
||||
return new ExpressionScope(kParameterDeclaration);
|
||||
}
|
||||
|
||||
export function newArrowHeadScope() {
|
||||
return new ArrowHeadParsingScope(kMaybeArrowParameterDeclaration);
|
||||
}
|
||||
|
||||
export function newAsyncArrowScope() {
|
||||
return new ArrowHeadParsingScope(kMaybeAsyncArrowParameterDeclaration);
|
||||
}
|
||||
|
||||
export function newExpressionScope() {
|
||||
return new ExpressionScope();
|
||||
}
|
||||
@@ -26,7 +26,12 @@ export const PARAM = 0b0000, // Initial Parameter flags
|
||||
// 6. parse function body
|
||||
// 7. exit current stack
|
||||
|
||||
export type ParamKind = typeof PARAM | typeof PARAM_AWAIT | typeof PARAM_YIELD;
|
||||
export type ParamKind =
|
||||
| typeof PARAM
|
||||
| typeof PARAM_AWAIT
|
||||
| typeof PARAM_IN
|
||||
| typeof PARAM_RETURN
|
||||
| typeof PARAM_YIELD;
|
||||
|
||||
export default class ProductionParameterHandler {
|
||||
stacks: Array<ParamKind> = [];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:7)"
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:7)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
@@ -66,4 +66,4 @@
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:15)"
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:15)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
@@ -70,12 +70,12 @@
|
||||
"start":28,"end":29,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":12},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":30,"end":31,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":14},"identifierName":"b"},
|
||||
"name": "b"
|
||||
},
|
||||
"computed": false
|
||||
}
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:7)"
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:7)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:17)"
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:17)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:8)",
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:8)",
|
||||
"SyntaxError: Binding invalid left-hand side in function parameter list (2:8)"
|
||||
],
|
||||
"program": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:8)"
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:8)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
@@ -46,12 +46,12 @@
|
||||
"right": {
|
||||
"type": "YieldExpression",
|
||||
"start":25,"end":30,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":13}},
|
||||
"delegate": false,
|
||||
"argument": null,
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 24
|
||||
}
|
||||
},
|
||||
"delegate": false,
|
||||
"argument": null
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:3)",
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:3)",
|
||||
"SyntaxError: Binding invalid left-hand side in function parameter list (2:3)"
|
||||
],
|
||||
"program": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:3)",
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:3)",
|
||||
"SyntaxError: Binding invalid left-hand side in function parameter list (2:3)"
|
||||
],
|
||||
"program": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:9)",
|
||||
"SyntaxError: yield is not allowed in generator parameters (2:9)",
|
||||
"SyntaxError: Binding invalid left-hand side in function parameter list (2:9)"
|
||||
],
|
||||
"program": {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
function* g( x = function() { async(yield) }) {};
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":48}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"g"},
|
||||
"name": "g"
|
||||
},
|
||||
"generator": true,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":13,"end":44,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":44}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "FunctionExpression",
|
||||
"start":17,"end":44,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":44}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":28,"end":44,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":44}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":30,"end":42,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":42}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":30,"end":42,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":42}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":36,"end":41,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":41},"identifierName":"yield"},
|
||||
"name": "yield"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":46,"end":48,"loc":{"start":{"line":1,"column":46},"end":{"line":1,"column":48}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "EmptyStatement",
|
||||
"start":48,"end":49,"loc":{"start":{"line":1,"column":48},"end":{"line":1,"column":49}}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'await' as identifier inside an async function (1:20)"
|
||||
"SyntaxError: Can not use 'await' as identifier inside an async function (1:14)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
@@ -42,6 +42,9 @@
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":14,"end":19,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":19}},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
@@ -54,9 +57,6 @@
|
||||
"type": "Identifier",
|
||||
"start":14,"end":19,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":19},"identifierName":"await"},
|
||||
"name": "await"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
async (x = function f(x = class await {}){}) => {}
|
||||
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":50,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":50}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":50,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":50}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":50,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":50}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":50,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":50}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":43,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":43}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "FunctionExpression",
|
||||
"start":11,"end":43,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":43}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"f"},
|
||||
"name": "f"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":22,"end":40,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":40}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":26,"end":40,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":40}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":32,"end":37,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":37},"identifierName":"await"},
|
||||
"name": "await"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":38,"end":40,"loc":{"start":{"line":1,"column":38},"end":{"line":1,"column":40}},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":41,"end":43,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":43}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":48,"end":50,"loc":{"start":{"line":1,"column":48},"end":{"line":1,"column":50}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async (x = function() { async(await) }) => {}
|
||||
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":38,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":38}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "FunctionExpression",
|
||||
"start":11,"end":38,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":38}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":22,"end":38,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":38}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":24,"end":36,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":36}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":24,"end":36,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":36}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":24,"end":29,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":29},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":43,"end":45,"loc":{"start":{"line":1,"column":43},"end":{"line":1,"column":45}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":63,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'await' as identifier inside an async function (2:23)"
|
||||
"SyntaxError: await is not allowed in async function parameters (2:23)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
function fn(x = async function () { await 1 }) {}
|
||||
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":11,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":11},"identifierName":"fn"},
|
||||
"name": "fn"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":12,"end":45,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":45}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "FunctionExpression",
|
||||
"start":16,"end":45,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":45}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":34,"end":45,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":45}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":36,"end":43,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":43}},
|
||||
"expression": {
|
||||
"type": "AwaitExpression",
|
||||
"start":36,"end":43,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":43}},
|
||||
"argument": {
|
||||
"type": "NumericLiteral",
|
||||
"start":42,"end":43,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":43}},
|
||||
"extra": {
|
||||
"rawValue": 1,
|
||||
"raw": "1"
|
||||
},
|
||||
"value": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":47,"end":49,"loc":{"start":{"line":1,"column":47},"end":{"line":1,"column":49}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
function fn(x = async () => await 1) {}
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":11,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":11},"identifierName":"fn"},
|
||||
"name": "fn"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":12,"end":35,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":35}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":16,"end":35,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":35}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "AwaitExpression",
|
||||
"start":28,"end":35,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":35}},
|
||||
"argument": {
|
||||
"type": "NumericLiteral",
|
||||
"start":34,"end":35,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":35}},
|
||||
"extra": {
|
||||
"rawValue": 1,
|
||||
"raw": "1"
|
||||
},
|
||||
"value": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":37,"end":39,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":39}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'await' as identifier inside an async function (2:7)"
|
||||
"SyntaxError: await is not allowed in async function parameters (2:7)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'await' as identifier inside an async function (2:13)"
|
||||
"SyntaxError: await is not allowed in async function parameters (2:13)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
async ( x = (await) => async (y) => {} );
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start":8,"end":38,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":38}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":8,"end":9,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":9},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":13,"end":18,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":18},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":23,"end":38,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":38}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":30,"end":31,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":31},"identifierName":"y"},
|
||||
"name": "y"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":36,"end":38,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":38}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async ({ x = [ await ], y = { await } }) => {}
|
||||
@@ -0,0 +1,127 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'await' as identifier inside an async function (1:15)",
|
||||
"SyntaxError: Can not use 'await' as identifier inside an async function (1:30)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "ObjectPattern",
|
||||
"start":7,"end":39,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":39}},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":9,"end":22,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":22}},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "AssignmentPattern",
|
||||
"start":9,"end":22,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":22}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ArrayExpression",
|
||||
"start":13,"end":22,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":22}},
|
||||
"elements": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":15,"end":20,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":20},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":24,"end":37,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":37}},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25},"identifierName":"y"},
|
||||
"name": "y"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "AssignmentPattern",
|
||||
"start":24,"end":37,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":37}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25},"identifierName":"y"},
|
||||
"name": "y"
|
||||
},
|
||||
"right": {
|
||||
"type": "ObjectExpression",
|
||||
"start":28,"end":37,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":37}},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35}},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35},"identifierName":"await"},
|
||||
"name": "await"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":44,"end":46,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":46}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (1:21)"
|
||||
"SyntaxError: yield is not allowed in generator parameters (1:21)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (1:16)",
|
||||
"SyntaxError: yield is not allowed in generator parameters (1:16)",
|
||||
"SyntaxError: Binding invalid left-hand side in function parameter list (1:16)"
|
||||
],
|
||||
"program": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (1:25)",
|
||||
"SyntaxError: yield is not allowed in generator parameters (1:25)",
|
||||
"SyntaxError: Binding invalid left-hand side in function parameter list (1:25)"
|
||||
],
|
||||
"program": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'yield' as identifier inside a generator (1:21)"
|
||||
"SyntaxError: yield is not allowed in generator parameters (1:21)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
async( x = class { #x = await });
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start":7,"end":31,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":31}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":11,"end":31,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":31}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":17,"end":31,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":31}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassPrivateProperty",
|
||||
"start":19,"end":29,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":29}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "PrivateName",
|
||||
"start":19,"end":21,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":21}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"x"},
|
||||
"name": "x"
|
||||
}
|
||||
},
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start":24,"end":29,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":29},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async( x = class { #x = await }) => {}
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":31,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":31}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":11,"end":31,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":31}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":17,"end":31,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":31}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassPrivateProperty",
|
||||
"start":19,"end":29,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":29}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "PrivateName",
|
||||
"start":19,"end":21,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":21}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"x"},
|
||||
"name": "x"
|
||||
}
|
||||
},
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start":24,"end":29,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":29},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":36,"end":38,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":38}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/experimental/class-private-properties/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/class-private-properties/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["classPrivateProperties"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async( x = class { [await] = x })
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start":7,"end":32,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":32}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":11,"end":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":17,"end":32,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":32}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":19,"end":30,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":30}},
|
||||
"static": false,
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":20,"end":25,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":25},"identifierName":"await"},
|
||||
"name": "await"
|
||||
},
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start":29,"end":30,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":30},"identifierName":"x"},
|
||||
"name": "x"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async (x = function f(x = class { [await] }){}) => {}
|
||||
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":53}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":53}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":53}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":53}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":46,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":46}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "FunctionExpression",
|
||||
"start":11,"end":46,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":46}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"f"},
|
||||
"name": "f"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":22,"end":43,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":43}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":26,"end":43,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":43}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":32,"end":43,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":43}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":34,"end":41,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":41}},
|
||||
"static": false,
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":35,"end":40,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":40},"identifierName":"await"},
|
||||
"name": "await"
|
||||
},
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":44,"end":46,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":46}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":51,"end":53,"loc":{"start":{"line":1,"column":51},"end":{"line":1,"column":53}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async( x = class { x = await });
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
|
||||
"name": "async"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "AssignmentExpression",
|
||||
"start":7,"end":30,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":30}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":11,"end":30,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":30}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":17,"end":30,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":30}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":19,"end":28,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":28}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"computed": false,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start":23,"end":28,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":28},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async( x = class { [await] = x }) => {}
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
|
||||
"errors": [
|
||||
"SyntaxError: Can not use 'await' as identifier inside an async function (1:20)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":32,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":32}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":11,"end":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":17,"end":32,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":32}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":19,"end":30,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":30}},
|
||||
"static": false,
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":20,"end":25,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":25},"identifierName":"await"},
|
||||
"name": "await"
|
||||
},
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start":29,"end":30,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":30},"identifierName":"x"},
|
||||
"name": "x"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":37,"end":39,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":39}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async( x = class { x = await }) => {}
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":30,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":30}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":11,"end":30,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":30}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":17,"end":30,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":30}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":19,"end":28,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":28}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"computed": false,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start":23,"end":28,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":28},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":35,"end":37,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":37}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/experimental/class-properties/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/class-properties/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
async (x = class { static { await } }) => {}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}},
|
||||
"expression": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":7,"end":37,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":37}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"right": {
|
||||
"type": "ClassExpression",
|
||||
"start":11,"end":37,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":37}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":17,"end":37,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":37}},
|
||||
"body": [
|
||||
{
|
||||
"type": "StaticBlock",
|
||||
"start":19,"end":35,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":35}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":28,"end":33,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":33}},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start":28,"end":33,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":33},"identifierName":"await"},
|
||||
"name": "await"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":42,"end":44,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":44}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
[await 0] = () => {}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"plugins": [
|
||||
"topLevelAwait",
|
||||
"classProperties"
|
||||
],
|
||||
"sourceType": "module"
|
||||
}
|
||||
62
packages/babel-parser/test/fixtures/experimental/top-level-await/inside-property-key/output.json
vendored
Normal file
62
packages/babel-parser/test/fixtures/experimental/top-level-await/inside-property-key/output.json
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"C"},
|
||||
"name": "C"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":8,"end":34,"loc":{"start":{"line":1,"column":8},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":12,"end":32,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":22}},
|
||||
"static": false,
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "AwaitExpression",
|
||||
"start":13,"end":20,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":10}},
|
||||
"argument": {
|
||||
"type": "NumericLiteral",
|
||||
"start":19,"end":20,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10}},
|
||||
"extra": {
|
||||
"rawValue": 0,
|
||||
"raw": "0"
|
||||
},
|
||||
"value": 0
|
||||
}
|
||||
},
|
||||
"value": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":24,"end":32,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":22}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":30,"end":32,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":22}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user