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

Support async generators #2101

Merged
merged 2 commits into from
Aug 29, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Error messages should be identical to V8.
export const Messages = {
AsyncFunctionInSingleStatementContext: 'Async functions can only be declared at the top level or inside a block.',
BadImportCallArity: 'Unexpected token',
BadGetterArity: 'Getter must not have any formal parameters',
BadSetterArity: 'Setter must have exactly one formal parameter',
Expand All @@ -12,6 +13,7 @@ export const Messages = {
DefaultRestProperty: 'Unexpected token =',
DuplicateBinding: 'Duplicate binding %0',
DuplicateConstructor: 'A class may only have one constructor',
DuplicateParameter: 'Duplicate parameter name not allowed in this context',
DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals',
ForInOfLoopInitializer: '%0 loop variable declaration may not have an initializer',
GeneratorInLegacyContext: 'Generator declarations are not allowed in legacy contexts',
Expand Down Expand Up @@ -49,7 +51,6 @@ export const Messages = {
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
StrictModeWith: 'Strict mode code may not include a with statement',
StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this in favor of DuplicateParameter which aligns with V8

StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
StrictReservedWord: 'Use of future reserved word in strict mode',
StrictVarName: 'Variable name may not be eval or arguments in strict mode',
Expand All @@ -60,6 +61,7 @@ export const Messages = {
UnexpectedNumber: 'Unexpected number',
UnexpectedReserved: 'Unexpected reserved word',
UnexpectedString: 'Unexpected string',
UnexpectedSuper: '\'super\' keyword unexpected here',
UnexpectedTemplate: 'Unexpected quasi %0',
UnexpectedToken: 'Unexpected token %0',
UnexpectedTokenIllegal: 'Unexpected token ILLEGAL',
Expand Down
8 changes: 4 additions & 4 deletions src/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ export class AsyncFunctionDeclaration {
readonly generator: boolean;
readonly expression: boolean;
readonly async: boolean;
constructor(id: Identifier | null, params: FunctionParameter[], body: BlockStatement) {
constructor(id: Identifier | null, params: FunctionParameter[], body: BlockStatement, generator: boolean) {
this.type = Syntax.FunctionDeclaration;
this.id = id;
this.params = params;
this.body = body;
this.generator = false;
this.generator = generator;
this.expression = false;
this.async = true;
}
Expand All @@ -134,12 +134,12 @@ export class AsyncFunctionExpression {
readonly generator: boolean;
readonly expression: boolean;
readonly async: boolean;
constructor(id: Identifier | null, params: FunctionParameter[], body: BlockStatement) {
constructor(id: Identifier | null, params: FunctionParameter[], body: BlockStatement, generator: boolean) {
this.type = Syntax.FunctionExpression;
this.id = id;
this.params = params;
this.body = body;
this.generator = false;
this.generator = generator;
this.expression = false;
this.async = true;
}
Expand Down
Loading