diff --git a/src/parser.ts b/src/parser.ts index 9e0d3cb0..6186d70a 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -1100,15 +1100,6 @@ export function parseAsyncArrowOrAsyncFunctionDeclaration( */ expr = parseMemberOrUpdateExpression(parser, context, expr, 0, 0, start, line, column); - /** Sequence expression - * - * Note: The comma operator leads to a sequence expression which is not equivalent - * to the ES Expression, but it's part of the ESTree specs: - * - * https://github.com/estree/estree/blob/master/es5.md#sequenceexpression - * - */ - if (parser.token === Token.Comma) expr = parseSequenceExpression(parser, context, 0, start, line, column, expr); /** AssignmentExpression : * @@ -1120,6 +1111,18 @@ export function parseAsyncArrowOrAsyncFunctionDeclaration( parser.assignable = AssignmentKind.Assignable; + /** Sequence expression + * + * Note: The comma operator leads to a sequence expression which is not equivalent + * to the ES Expression, but it's part of the ESTree specs: + * + * https://github.com/estree/estree/blob/master/es5.md#sequenceexpression + * + */ + if (parser.token === Token.Comma) { + expr = parseSequenceExpression(parser, context, 0, start, line, column, expr); + } + /** * ExpressionStatement[Yield, Await]: * [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]Expression[+In, ?Yield, ?Await] @@ -2688,6 +2691,10 @@ export function parseImportMetaDeclaration( expr = parseAssignmentExpression(parser, context, 0, 0, start, line, column, expr as ESTree.Expression); + if (parser.token === Token.Comma) { + expr = parseSequenceExpression(parser, context, 0, start, line, column, expr); + } + /** * ExpressionStatement[Yield, Await]: * [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]Expression[+In, ?Yield, ?Await] @@ -3574,6 +3581,8 @@ export function parseAsyncExpression( if (inNew) report(parser, Errors.InvalidAsyncArrow); return parseArrowFromIdentifier(parser, context, parser.tokenValue, expr, inNew, canAssign, 0, start, line, column); } + + parser.assignable = AssignmentKind.Assignable; return expr; } diff --git a/test/parser/declarations/functions.ts b/test/parser/declarations/functions.ts index 819aa35d..4aad839f 100644 --- a/test/parser/declarations/functions.ts +++ b/test/parser/declarations/functions.ts @@ -397,6 +397,8 @@ describe('Declarations - Function', () => { 'function f() { function await() { } }', 'function f() { const await = 10; }', 'function f(a = async function (x) { await x; }) { a(); } f();', + 'function f() {async = 1, a = 2;}', + 'function f() {a = 1, async = 2;}', 'function f() {var async = 1; return async;}', 'function f() {let async = 1; return async;}', 'function f() {const async = 1; return async;}', diff --git a/test/parser/miscellaneous/pass.ts b/test/parser/miscellaneous/pass.ts index 24bc3633..b94f9c79 100644 --- a/test/parser/miscellaneous/pass.ts +++ b/test/parser/miscellaneous/pass.ts @@ -2834,6 +2834,8 @@ after = err; 'x = await(y);', 'class X { await() {} }', 'let async = await;', + 'async = 1, b = 2;', + 'b = 2, async = 1;', 'x = { await: false }', 'yield[100]', `async diff --git a/test/parser/next/import-meta.ts b/test/parser/next/import-meta.ts index 49249d2f..61440348 100644 --- a/test/parser/next/import-meta.ts +++ b/test/parser/next/import-meta.ts @@ -100,6 +100,12 @@ describe('Next - Import Meta', () => { '(a?.import("string")?.import.meta??(a))', 'import.meta?.(a?.import("string")?.import.meta??(a))', 'var a = import.meta;', + 'import.meta, 1;', + '1, import.meta;', + 'import.meta, a = 1;', + 'a = 1, import.meta;', + 'import.meta.url = 1, import.meta.url = 2;', + 'import.meta, import.meta.url = 1;', 'import.meta;' ]) { it(`${arg}`, () => {