Skip to content

Commit

Permalink
fix(parser): fix import.meta in sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaIT committed Mar 25, 2024
1 parent 223936e commit 15ea395
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/parser.ts
Expand Up @@ -1119,7 +1119,9 @@ export function parseAsyncArrowOrAsyncFunctionDeclaration(
* https://github.com/estree/estree/blob/master/es5.md#sequenceexpression
*
*/
if (parser.token === Token.Comma) expr = parseSequenceExpression(parser, context, 0, start, line, column, expr);
if (parser.token === Token.Comma) {
expr = parseSequenceExpression(parser, context, 0, start, line, column, expr);
}

/**
* ExpressionStatement[Yield, Await]:
Expand Down Expand Up @@ -2689,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]
Expand Down
4 changes: 4 additions & 0 deletions test/parser/next/import-meta.ts
Expand Up @@ -100,6 +100,10 @@ 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;'
]) {
it(`${arg}`, () => {
Expand Down

0 comments on commit 15ea395

Please sign in to comment.