Check for function when parsing export async (#639)

This commit is contained in:
Brian Ng 2017-07-19 13:03:49 -05:00 committed by Henry Zhu
parent fa4d4040dc
commit a46f87f726
3 changed files with 14 additions and 0 deletions

View File

@ -1255,6 +1255,15 @@ export default class StatementParser extends ExpressionParser {
this.checkExport(node, true, true);
return this.finishNode(node, "ExportDefaultDeclaration");
} else if (this.shouldParseExportDeclaration()) {
if (this.isContextual("async")) {
const next = this.lookahead();
// export async;
if (next.type !== tt._function) {
this.unexpected(next.start, "Unexpected token, expected function");
}
}
node.specifiers = [];
node.source = null;
node.declaration = this.parseExportDeclaration(node);

View File

@ -0,0 +1 @@
export async;

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "Unexpected token, expected function (1:12)"
}