meriyah 7.3.0 → 7.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/meriyah.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var version$1 = "7.3.0";
1
+ var version$1 = "7.3.1";
2
2
  var packageJson = {
3
3
  version: version$1};
4
4
 
@@ -91,7 +91,7 @@ const CharTypes = [
91
91
  0,
92
92
  16384,
93
93
  0,
94
- 0,
94
+ 16384,
95
95
  0,
96
96
  0,
97
97
  1 | 2 | 64,
@@ -154,7 +154,7 @@ const CharTypes = [
154
154
  1 | 2 | 4,
155
155
  16384,
156
156
  0,
157
- 0,
157
+ 16384,
158
158
  0,
159
159
  0
160
160
  ];
@@ -788,6 +788,8 @@ const errorMessages = {
788
788
  [177]: "'import.meta' must not contain escaped characters",
789
789
  [178]: 'cannot use "await" as identifier inside an async function',
790
790
  [179]: 'cannot use "await" in static blocks',
791
+ [180]: "Unexpected token `}`. Did you mean `}` or `{'}'}`?",
792
+ [181]: "Unexpected token `>`. Did you mean `>` or `{'>'}`?",
791
793
  };
792
794
  class ParseError extends SyntaxError {
793
795
  start;
@@ -2245,6 +2247,9 @@ function isStrictReservedWord(parser, context, t) {
2245
2247
  if (t === 209006) {
2246
2248
  if (context & (2048 | 2))
2247
2249
  parser.report(112);
2250
+ if ((parser.destructible & 128) === 0) {
2251
+ parser.firstAwaitLocation ??= { start: parser.tokenStart, end: parser.currentLocation };
2252
+ }
2248
2253
  parser.destructible |= 128;
2249
2254
  }
2250
2255
  if (t === 241771 && context & 1024)
@@ -4526,6 +4531,12 @@ function nextJSXToken(parser) {
4526
4531
  parser.setToken(2162700);
4527
4532
  return;
4528
4533
  }
4534
+ if (parser.currentChar === 125) {
4535
+ parser.report(180);
4536
+ }
4537
+ if (parser.currentChar === 62) {
4538
+ parser.report(181);
4539
+ }
4529
4540
  let state = 0;
4530
4541
  while (parser.index < parser.end) {
4531
4542
  const type = CharTypes[parser.source.charCodeAt(parser.index)];
@@ -4699,7 +4710,7 @@ class Scope {
4699
4710
  hasVariable(name) {
4700
4711
  return this.variableBindings.has(name);
4701
4712
  }
4702
- addBlockName(context, name, kind, origin) {
4713
+ addBlockName(context, name, kind, origin = 0) {
4703
4714
  const { parser } = this;
4704
4715
  const value = this.variableBindings.get(name);
4705
4716
  if (value && (value & 2) === 0) {
@@ -4749,7 +4760,7 @@ class Scope {
4749
4760
  }
4750
4761
  function createArrowHeadParsingScope(parser, context, value) {
4751
4762
  const scope = parser.createScope().createChildScope(512);
4752
- scope.addBlockName(context, value, 1, 0);
4763
+ scope.addBlockName(context, value, 1);
4753
4764
  return scope;
4754
4765
  }
4755
4766
 
@@ -4779,6 +4790,7 @@ class Parser {
4779
4790
  assignable = 0;
4780
4791
  destructible = 0;
4781
4792
  strictReservedRange = null;
4793
+ firstAwaitLocation = null;
4782
4794
  leadingDecorators = { decorators: [] };
4783
4795
  constructor(source, rawOptions = {}) {
4784
4796
  this.source = source;
@@ -4987,7 +4999,7 @@ function parseStatementList(parser, context, scope) {
4987
4999
  statements.push(parseDirective(parser, context, expr, token, tokenStart));
4988
5000
  }
4989
5001
  while (parser.getToken() !== 1048576) {
4990
- statements.push(parseStatementListItem(parser, context, scope, undefined, 4, {}));
5002
+ statements.push(parseStatementListItem(parser, context, scope, undefined, {}, 4));
4991
5003
  }
4992
5004
  return statements;
4993
5005
  }
@@ -5023,18 +5035,18 @@ function parseModuleItem(parser, context, scope) {
5023
5035
  moduleItem = parseImportDeclaration(parser, context, scope);
5024
5036
  break;
5025
5037
  default:
5026
- moduleItem = parseStatementListItem(parser, context, scope, undefined, 4, {});
5038
+ moduleItem = parseStatementListItem(parser, context, scope, undefined, {}, 4);
5027
5039
  }
5028
5040
  return moduleItem;
5029
5041
  }
5030
- function parseStatementListItem(parser, context, scope, privateScope, origin, labels) {
5042
+ function parseStatementListItem(parser, context, scope, privateScope, labels, origin = 2) {
5031
5043
  const start = parser.tokenStart;
5032
5044
  if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
5033
5045
  parser.report(172);
5034
5046
  }
5035
5047
  switch (parser.getToken()) {
5036
5048
  case 86104:
5037
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 0, start);
5049
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 0, start, origin);
5038
5050
  case 133:
5039
5051
  if (!(parser.features & 1)) {
5040
5052
  parser.report(30, '@');
@@ -5042,17 +5054,17 @@ function parseStatementListItem(parser, context, scope, privateScope, origin, la
5042
5054
  case 86094:
5043
5055
  return parseClassDeclaration(parser, context, scope, privateScope, 0);
5044
5056
  case 86090:
5045
- return parseLexicalDeclaration(parser, context, scope, privateScope, 16, 0);
5057
+ return parseLexicalDeclaration(parser, context, scope, privateScope, 16);
5046
5058
  case 241737:
5047
5059
  return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin);
5048
5060
  case 209013:
5049
- return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5061
+ return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5050
5062
  case 209006:
5051
5063
  if ((context & 2048 || (context & 2 && context & 8)) &&
5052
5064
  nextTokenIsUsingOnSameLine(parser)) {
5053
- return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5065
+ return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5054
5066
  }
5055
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5067
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5056
5068
  case 20564:
5057
5069
  parser.report(103, 'export');
5058
5070
  case 86106:
@@ -5066,15 +5078,15 @@ function parseStatementListItem(parser, context, scope, privateScope, origin, la
5066
5078
  parser.report(103, 'import');
5067
5079
  }
5068
5080
  case 209005:
5069
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 1);
5081
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 1, origin);
5070
5082
  default:
5071
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5083
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5072
5084
  }
5073
5085
  }
5074
- function parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5086
+ function parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin = 0) {
5075
5087
  switch (parser.getToken()) {
5076
5088
  case 86088:
5077
- return parseVariableStatement(parser, context, scope, privateScope, 0);
5089
+ return parseVariableStatement(parser, context, scope, privateScope);
5078
5090
  case 20572:
5079
5091
  return parseReturnStatement(parser, context, privateScope);
5080
5092
  case 20569:
@@ -5104,7 +5116,7 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
5104
5116
  case 20560:
5105
5117
  return parseDebuggerStatement(parser, context);
5106
5118
  case 209005:
5107
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 0);
5119
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 0, origin);
5108
5120
  case 20557:
5109
5121
  parser.report(164);
5110
5122
  case 20566:
@@ -5118,10 +5130,10 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
5118
5130
  case 86094:
5119
5131
  parser.report(79);
5120
5132
  default:
5121
- return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5133
+ return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5122
5134
  }
5123
5135
  }
5124
- function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5136
+ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5125
5137
  const { tokenValue, tokenStart } = parser;
5126
5138
  const token = parser.getToken();
5127
5139
  let expr;
@@ -5136,11 +5148,11 @@ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope
5136
5148
  default:
5137
5149
  expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart);
5138
5150
  }
5139
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, expr, token, tokenValue, tokenStart);
5151
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, expr, token, tokenValue, tokenStart, origin);
5140
5152
  }
5141
- function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart) {
5153
+ function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart, origin) {
5142
5154
  if (token & 143360 && parser.getToken() === 21) {
5143
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart);
5155
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart, origin);
5144
5156
  }
5145
5157
  let expression = parseMemberOrUpdateExpression(parser, context, privateScope, initialExpression, 0, 0, tokenStart);
5146
5158
  expression = parseAssignmentExpression(parser, context, privateScope, 0, 0, tokenStart, expression);
@@ -5153,7 +5165,7 @@ function parseBlock(parser, context, scope, privateScope, labels, start = parser
5153
5165
  const body = [];
5154
5166
  consume(parser, context | 32, 2162700);
5155
5167
  while (parser.getToken() !== 1074790415) {
5156
- body.push(parseStatementListItem(parser, context, scope, privateScope, 2, { $: labels }));
5168
+ body.push(parseStatementListItem(parser, context, scope, privateScope, { $: labels }));
5157
5169
  }
5158
5170
  consume(parser, context | 32, 1074790415);
5159
5171
  return parser.finishNode({
@@ -5182,7 +5194,7 @@ function parseExpressionStatement(parser, context, expression, start) {
5182
5194
  expression,
5183
5195
  }, start);
5184
5196
  }
5185
- function parseLabelledStatement(parser, context, scope, privateScope, origin, labels, value, expr, token, allowFuncDecl, start) {
5197
+ function parseLabelledStatement(parser, context, scope, privateScope, labels, value, expr, token, allowFuncDecl, start, origin) {
5186
5198
  validateBindingIdentifier(parser, context, 0, token, 1);
5187
5199
  validateAndDeclareLabel(parser, labels, value);
5188
5200
  nextToken(parser, context | 32);
@@ -5190,27 +5202,27 @@ function parseLabelledStatement(parser, context, scope, privateScope, origin, la
5190
5202
  (context & 1) === 0 &&
5191
5203
  parser.options.webcompat &&
5192
5204
  parser.getToken() === 86104
5193
- ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, origin, 0, 0, 0, parser.tokenStart)
5194
- : parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5205
+ ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, parser.tokenStart, origin)
5206
+ : parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5195
5207
  return parser.finishNode({
5196
5208
  type: 'LabeledStatement',
5197
5209
  label: expr,
5198
5210
  body,
5199
5211
  }, start);
5200
5212
  }
5201
- function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5213
+ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5202
5214
  const { tokenValue, tokenStart: start } = parser;
5203
5215
  const token = parser.getToken();
5204
5216
  let expr = parseIdentifier(parser, context);
5205
5217
  if (parser.getToken() === 21) {
5206
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, expr, token, 1, start);
5218
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, 1, start, origin);
5207
5219
  }
5208
5220
  const asyncNewLine = parser.flags & 1;
5209
5221
  if (!asyncNewLine) {
5210
5222
  if (parser.getToken() === 86104) {
5211
5223
  if (!allowFuncDecl)
5212
5224
  parser.report(125);
5213
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 1, start);
5225
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 1, start, origin);
5214
5226
  }
5215
5227
  if (isValidIdentifier(context, parser.getToken())) {
5216
5228
  expr = parseAsyncArrowAfterIdent(parser, context, privateScope, 1, start);
@@ -5220,7 +5232,7 @@ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, priva
5220
5232
  }
5221
5233
  }
5222
5234
  if (parser.getToken() === 67174411) {
5223
- expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, 0, asyncNewLine, start);
5235
+ expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, asyncNewLine, start);
5224
5236
  }
5225
5237
  else {
5226
5238
  if (parser.getToken() === 10) {
@@ -5306,8 +5318,8 @@ function parseConsequentOrAlternative(parser, context, scope, privateScope, labe
5306
5318
  return context & 1 ||
5307
5319
  !parser.options.webcompat ||
5308
5320
  parser.getToken() !== 86104
5309
- ? parseStatement(parser, context, scope, privateScope, 0, { $: labels }, 0)
5310
- : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, 0, tokenStart);
5321
+ ? parseStatement(parser, context, scope, privateScope, { $: labels }, 0)
5322
+ : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, tokenStart);
5311
5323
  }
5312
5324
  function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5313
5325
  const start = parser.tokenStart;
@@ -5336,7 +5348,7 @@ function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5336
5348
  while (parser.getToken() !== 20556 &&
5337
5349
  parser.getToken() !== 1074790415 &&
5338
5350
  parser.getToken() !== 20561) {
5339
- const statement = parseStatementListItem(parser, context | 4, scope, privateScope, 2, {
5351
+ const statement = parseStatementListItem(parser, context | 4, scope, privateScope, {
5340
5352
  $: labels,
5341
5353
  });
5342
5354
  if (statement.type === 'VariableDeclaration' &&
@@ -5372,7 +5384,7 @@ function parseWhileStatement(parser, context, scope, privateScope, labels) {
5372
5384
  }, start);
5373
5385
  }
5374
5386
  function parseIterationStatementBody(parser, context, scope, privateScope, labels) {
5375
- return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, 0, { loop: 1, $: labels }, 0);
5387
+ return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, { loop: 1, $: labels }, 0);
5376
5388
  }
5377
5389
  function parseContinueStatement(parser, context, labels) {
5378
5390
  if ((context & 128) === 0)
@@ -5419,7 +5431,7 @@ function parseWithStatement(parser, context, scope, privateScope, labels) {
5419
5431
  consume(parser, context | 32, 67174411);
5420
5432
  const object = parseExpressions(parser, context, privateScope, 0, 1, parser.tokenStart);
5421
5433
  consume(parser, context | 32, 16);
5422
- const body = parseStatement(parser, context, scope, privateScope, 2, labels, 0);
5434
+ const body = parseStatement(parser, context, scope, privateScope, labels, 0, 2);
5423
5435
  return parser.finishNode({
5424
5436
  type: 'WithStatement',
5425
5437
  object,
@@ -5466,7 +5478,7 @@ function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
5466
5478
  scope = scope?.createChildScope(4);
5467
5479
  param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
5468
5480
  ? 256
5469
- : 512, 0);
5481
+ : 512);
5470
5482
  if (parser.getToken() === 18) {
5471
5483
  parser.report(86);
5472
5484
  }
@@ -5515,7 +5527,7 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
5515
5527
  let expr = parseIdentifier(parser, context);
5516
5528
  if (parser.getToken() & (143360 | 2097152) &&
5517
5529
  (parser.getToken() & 20480) !== 20480) {
5518
- const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8, 0);
5530
+ const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8);
5519
5531
  matchOrInsertSemicolon(parser, context | 32);
5520
5532
  return parser.finishNode({
5521
5533
  type: 'VariableDeclaration',
@@ -5527,7 +5539,7 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
5527
5539
  if (context & 1)
5528
5540
  parser.report(85);
5529
5541
  if (parser.getToken() === 21) {
5530
- return parseLabelledStatement(parser, context, scope, privateScope, origin, {}, tokenValue, expr, token, 0, tokenStart);
5542
+ return parseLabelledStatement(parser, context, scope, privateScope, {}, tokenValue, expr, token, 0, tokenStart, origin);
5531
5543
  }
5532
5544
  if (parser.getToken() === 10) {
5533
5545
  let scope = void 0;
@@ -5581,20 +5593,23 @@ function nextTokenIsUsingOnSameLine(parser) {
5581
5593
  function isResourceBindingStart(token) {
5582
5594
  return (token & 143360) === 143360 && (token & 20480) !== 20480;
5583
5595
  }
5584
- function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5596
+ function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5585
5597
  const { tokenStart, tokenValue } = parser;
5586
5598
  const token = parser.getToken();
5587
5599
  const expression = parseIdentifier(parser, context);
5588
5600
  if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
5589
- if (origin & 4 && context & 8 && (context & 2) === 0) {
5601
+ if (origin & 4 &&
5602
+ context & 8 &&
5603
+ (context & 2) === 0 &&
5604
+ (context & 4096) === 0) {
5590
5605
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5591
5606
  }
5592
5607
  return parseLexicalDeclaration(parser, context, scope, privateScope, 16, origin, 'using', tokenStart, 1);
5593
5608
  }
5594
5609
  parser.assignable = 1;
5595
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 1, expression, token, tokenValue, tokenStart);
5610
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 1, expression, token, tokenValue, tokenStart, origin);
5596
5611
  }
5597
- function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5612
+ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5598
5613
  const start = parser.tokenStart;
5599
5614
  if (context & 524288)
5600
5615
  parser.report(179);
@@ -5618,9 +5633,9 @@ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope,
5618
5633
  type: 'AwaitExpression',
5619
5634
  argument,
5620
5635
  }, start);
5621
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 0, expression, 1048576, '', start);
5636
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 0, expression, 1048576, '', start, origin);
5622
5637
  }
5623
- function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5638
+ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin = 0, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5624
5639
  const start = declarationStart;
5625
5640
  if (!keywordConsumed)
5626
5641
  nextToken(parser, context);
@@ -5632,7 +5647,7 @@ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, ori
5632
5647
  declarations,
5633
5648
  }, start);
5634
5649
  }
5635
- function parseVariableStatement(parser, context, scope, privateScope, origin) {
5650
+ function parseVariableStatement(parser, context, scope, privateScope, origin = 0) {
5636
5651
  const start = parser.tokenStart;
5637
5652
  nextToken(parser, context);
5638
5653
  const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 4, origin);
@@ -5643,7 +5658,7 @@ function parseVariableStatement(parser, context, scope, privateScope, origin) {
5643
5658
  declarations,
5644
5659
  }, start);
5645
5660
  }
5646
- function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin, declarationKind) {
5661
+ function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin = 0, declarationKind) {
5647
5662
  let bindingCount = 1;
5648
5663
  const firstDeclaration = parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind);
5649
5664
  const list = [firstDeclaration];
@@ -5674,11 +5689,14 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
5674
5689
  const id = parseBindingPattern(parser, context, scope, privateScope, kind, origin);
5675
5690
  if (parser.getToken() === 1077936155) {
5676
5691
  nextToken(parser, context | 32);
5677
- init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5692
+ init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart, origin);
5678
5693
  if (origin & 32) {
5679
5694
  if (parser.getToken() === 471156 ||
5680
5695
  (parser.getToken() === 8673330 &&
5681
- (token & 2097152 || (kind & 4) === 0 || context & 1))) {
5696
+ (token & 2097152 ||
5697
+ (kind & 4) === 0 ||
5698
+ context & 1 ||
5699
+ !parser.options.webcompat))) {
5682
5700
  throw new ParseError(tokenStart, parser.currentLocation, 60, parser.getToken() === 471156 ? 'of' : 'in');
5683
5701
  }
5684
5702
  }
@@ -5951,7 +5969,7 @@ function parseRestrictedIdentifier(parser, context, scope) {
5951
5969
  parser.report(120);
5952
5970
  if ((parser.getToken() & 537079808) === 537079808)
5953
5971
  parser.report(121);
5954
- scope?.addBlockName(context, parser.tokenValue, 8, 0);
5972
+ scope?.addBlockName(context, parser.tokenValue, 8);
5955
5973
  return parseIdentifier(parser, context);
5956
5974
  }
5957
5975
  function parseImportDeclaration(parser, context, scope) {
@@ -5979,7 +5997,7 @@ function parseImportDeclaration(parser, context, scope) {
5979
5997
  specifiers = [parseImportNamespaceSpecifier(parser, context, scope)];
5980
5998
  }
5981
5999
  else if (parser.getToken() === 209011 || parser.getToken() === 18) {
5982
- scope?.addBlockName(context, tokenValue, 8, 0);
6000
+ scope?.addBlockName(context, tokenValue, 8);
5983
6001
  specifiers = [
5984
6002
  parser.finishNode({
5985
6003
  type: 'ImportDefaultSpecifier',
@@ -5997,7 +6015,7 @@ function parseImportDeclaration(parser, context, scope) {
5997
6015
  const fromLocal = parseIdentifier(parser, context);
5998
6016
  if (parser.getToken() === 209011) {
5999
6017
  validateBindingIdentifier(parser, context, 16, fromToken, 0);
6000
- scope?.addBlockName(context, fromLocal.name, 8, 0);
6018
+ scope?.addBlockName(context, fromLocal.name, 8);
6001
6019
  phase = 'source';
6002
6020
  specifiers = [
6003
6021
  parser.finishNode({
@@ -6007,7 +6025,7 @@ function parseImportDeclaration(parser, context, scope) {
6007
6025
  ];
6008
6026
  }
6009
6027
  else {
6010
- scope?.addBlockName(context, tokenValue, 8, 0);
6028
+ scope?.addBlockName(context, tokenValue, 8);
6011
6029
  specifiers = [
6012
6030
  parser.finishNode({
6013
6031
  type: 'ImportDefaultSpecifier',
@@ -6032,7 +6050,7 @@ function parseImportDeclaration(parser, context, scope) {
6032
6050
  ];
6033
6051
  }
6034
6052
  else if (parser.getToken() === 18) {
6035
- scope?.addBlockName(context, tokenValue, 8, 0);
6053
+ scope?.addBlockName(context, tokenValue, 8);
6036
6054
  specifiers = [
6037
6055
  parser.finishNode({
6038
6056
  type: 'ImportDefaultSpecifier',
@@ -6139,7 +6157,7 @@ function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers)
6139
6157
  else {
6140
6158
  parser.report(25, KeywordDescTable[77932 & 255]);
6141
6159
  }
6142
- scope?.addBlockName(context, tokenValue, 8, 0);
6160
+ scope?.addBlockName(context, tokenValue, 8);
6143
6161
  specifiers.push(parser.finishNode({
6144
6162
  type: 'ImportSpecifier',
6145
6163
  local,
@@ -6185,7 +6203,7 @@ function parseExportDeclaration(parser, context, scope) {
6185
6203
  if (isDefaultExport) {
6186
6204
  switch (parser.getToken()) {
6187
6205
  case 86104: {
6188
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 0, parser.tokenStart);
6206
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 0, parser.tokenStart, 4);
6189
6207
  break;
6190
6208
  }
6191
6209
  case 133:
@@ -6201,11 +6219,11 @@ function parseExportDeclaration(parser, context, scope) {
6201
6219
  const { flags } = parser;
6202
6220
  if ((flags & 1) === 0) {
6203
6221
  if (parser.getToken() === 86104) {
6204
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 1, tokenStart);
6222
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 1, tokenStart, 4);
6205
6223
  }
6206
6224
  else {
6207
6225
  if (parser.getToken() === 67174411) {
6208
- declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, 0, flags, tokenStart);
6226
+ declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, flags, tokenStart);
6209
6227
  declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
6210
6228
  declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
6211
6229
  }
@@ -6322,7 +6340,7 @@ function parseExportDeclaration(parser, context, scope) {
6322
6340
  declaration = parseClassDeclaration(parser, context, scope, undefined, 2);
6323
6341
  break;
6324
6342
  case 86104:
6325
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 0, parser.tokenStart);
6343
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 0, parser.tokenStart, 4);
6326
6344
  break;
6327
6345
  case 241737:
6328
6346
  declaration = parseLexicalDeclaration(parser, context, scope, undefined, 8, 64);
@@ -6337,7 +6355,7 @@ function parseExportDeclaration(parser, context, scope) {
6337
6355
  const { tokenStart } = parser;
6338
6356
  nextToken(parser, context);
6339
6357
  if ((parser.flags & 1) === 0 && parser.getToken() === 86104) {
6340
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 1, tokenStart);
6358
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 1, tokenStart, 4);
6341
6359
  break;
6342
6360
  }
6343
6361
  }
@@ -6353,8 +6371,8 @@ function parseExportDeclaration(parser, context, scope) {
6353
6371
  };
6354
6372
  return parser.finishNode(node, start);
6355
6373
  }
6356
- function parseExpression(parser, context, privateScope, canAssign, inGroup, start) {
6357
- let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start);
6374
+ function parseExpression(parser, context, privateScope, canAssign, inGroup, start, origin = 0) {
6375
+ let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start, origin);
6358
6376
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGroup, 0, start);
6359
6377
  return parseAssignmentExpression(parser, context, privateScope, inGroup, 0, start, expr);
6360
6378
  }
@@ -6509,7 +6527,7 @@ function parseAsyncExpression(parser, context, privateScope, inGroup, isLHS, can
6509
6527
  }
6510
6528
  }
6511
6529
  if (!inNew && parser.getToken() === 67174411) {
6512
- return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, 0, flags, start);
6530
+ return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, flags, start);
6513
6531
  }
6514
6532
  if (parser.getToken() === 10) {
6515
6533
  classifyIdentifier(parser, context, token);
@@ -6557,8 +6575,12 @@ function parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup
6557
6575
  return parseIdentifierOrArrow(parser, context, privateScope);
6558
6576
  }
6559
6577
  function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, start) {
6560
- if (inGroup)
6578
+ if (inGroup) {
6579
+ if ((parser.destructible & 128) === 0) {
6580
+ parser.firstAwaitLocation ??= { start, end: parser.currentLocation };
6581
+ }
6561
6582
  parser.destructible |= 128;
6583
+ }
6562
6584
  if (context & 524288)
6563
6585
  parser.report(179);
6564
6586
  const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope);
@@ -6592,7 +6614,7 @@ function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew,
6592
6614
  throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 98);
6593
6615
  return possibleIdentifierOrArrowFunc;
6594
6616
  }
6595
- function parseFunctionBody(parser, context, scope, privateScope, origin, funcNameToken, functionScope) {
6617
+ function parseFunctionBody(parser, context, scope, privateScope, funcNameToken, functionScope, origin = 0) {
6596
6618
  const { tokenStart } = parser;
6597
6619
  parser.flags &= -4161;
6598
6620
  consume(parser, context | 32, 2162700);
@@ -6641,7 +6663,7 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
6641
6663
  (512 | 256 | 64 | 4096);
6642
6664
  parser.destructible = (parser.destructible | 256) ^ 256;
6643
6665
  while (parser.getToken() !== 1074790415) {
6644
- body.push(parseStatementListItem(parser, context, scope, privateScope, 4, {}));
6666
+ body.push(parseStatementListItem(parser, context, scope, privateScope, {}, 4));
6645
6667
  }
6646
6668
  consume(parser, origin & (16 | 8) ? context | 32 : context, 1074790415);
6647
6669
  parser.flags &= -4289;
@@ -6890,7 +6912,7 @@ function parseUpdateExpressionPrefixed(parser, context, privateScope, inNew, isL
6890
6912
  prefix: true,
6891
6913
  }, start);
6892
6914
  }
6893
- function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start) {
6915
+ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start, origin = 0) {
6894
6916
  if ((parser.getToken() & 143360) === 143360) {
6895
6917
  switch (parser.getToken()) {
6896
6918
  case 209006:
@@ -6910,7 +6932,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6910
6932
  if ((token & 36864) === 36864) {
6911
6933
  parser.flags |= 256;
6912
6934
  }
6913
- return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start);
6935
+ return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start, origin);
6914
6936
  }
6915
6937
  if (context & 16 &&
6916
6938
  !(context & 32768) &&
@@ -6951,7 +6973,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6951
6973
  case 69271571:
6952
6974
  return parseArrayLiteral(parser, context, privateScope, canAssign ? 0 : 1, inGroup);
6953
6975
  case 67174411:
6954
- return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, 0, start);
6976
+ return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, start, origin);
6955
6977
  case 86021:
6956
6978
  case 86022:
6957
6979
  case 86023:
@@ -7280,7 +7302,7 @@ function parseThisExpression(parser, context) {
7280
7302
  type: 'ThisExpression',
7281
7303
  }, tokenStart);
7282
7304
  }
7283
- function parseFunctionDeclaration(parser, context, scope, privateScope, origin, allowGen, flags, isAsync, start) {
7305
+ function parseFunctionDeclaration(parser, context, scope, privateScope, allowGen, flags, isAsync, start, origin = 0) {
7284
7306
  nextToken(parser, context | 32);
7285
7307
  const isGenerator = allowGen ? optionalBit(parser, context, 8391476) : 0;
7286
7308
  let id = null;
@@ -7334,7 +7356,7 @@ function parseFunctionDeclaration(parser, context, scope, privateScope, origin,
7334
7356
  functionScope = functionScope?.createChildScope(256);
7335
7357
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, functionScope, privateScope, 0, 1);
7336
7358
  const modifierFlags = 8 | 4 | 128 | 524288;
7337
- const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, 8, funcNameToken, functionScope);
7359
+ const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, funcNameToken, functionScope, 8);
7338
7360
  return parser.finishNode({
7339
7361
  type: 'FunctionDeclaration',
7340
7362
  id,
@@ -7373,7 +7395,7 @@ function parseFunctionExpression(parser, context, privateScope, isAsync, inGroup
7373
7395
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, scope, privateScope, inGroup, 1);
7374
7396
  const body = parseFunctionBody(parser, (context & -131229) |
7375
7397
  32768 |
7376
- 4096, scope?.createChildScope(64), privateScope, 0, funcNameToken, scope);
7398
+ 4096, scope?.createChildScope(64), privateScope, funcNameToken, scope);
7377
7399
  parser.assignable = 2;
7378
7400
  return parser.finishNode({
7379
7401
  type: 'FunctionExpression',
@@ -7385,7 +7407,7 @@ function parseFunctionExpression(parser, context, privateScope, isAsync, inGroup
7385
7407
  }, start);
7386
7408
  }
7387
7409
  function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7388
- const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7410
+ const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7389
7411
  if (parser.destructible & 64) {
7390
7412
  parser.report(63);
7391
7413
  }
@@ -7394,7 +7416,7 @@ function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGro
7394
7416
  }
7395
7417
  return expr;
7396
7418
  }
7397
- function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7419
+ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7398
7420
  const { tokenStart: start } = parser;
7399
7421
  nextToken(parser, context | 32);
7400
7422
  const elements = [];
@@ -7503,7 +7525,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7503
7525
  }
7504
7526
  }
7505
7527
  else if (token === 14) {
7506
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, origin, 0, inGroup, isPattern);
7528
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, 0, inGroup, isPattern, origin);
7507
7529
  destructible |= parser.destructible;
7508
7530
  if (parser.getToken() !== 18 && parser.getToken() !== 20)
7509
7531
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
@@ -7573,7 +7595,7 @@ function parseArrayOrObjectAssignmentPattern(parser, context, privateScope, dest
7573
7595
  right,
7574
7596
  }, start);
7575
7597
  }
7576
- function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, origin, isAsync, inGroup, isPattern) {
7598
+ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, isAsync, inGroup, isPattern, origin = 0) {
7577
7599
  const { tokenStart: start } = parser;
7578
7600
  nextToken(parser, context | 32);
7579
7601
  let argument = null;
@@ -7722,7 +7744,7 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
7722
7744
  scope = scope?.createChildScope(64);
7723
7745
  const body = parseFunctionBody(parser, (context & -655373) |
7724
7746
  32768 |
7725
- 4096, scope, privateScope, 0, void 0, scope?.parent);
7747
+ 4096, scope, privateScope, void 0, scope?.parent);
7726
7748
  return parser.finishNode({
7727
7749
  type: 'FunctionExpression',
7728
7750
  params,
@@ -7733,7 +7755,7 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
7733
7755
  }, start);
7734
7756
  }
7735
7757
  function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7736
- const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7758
+ const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7737
7759
  if (parser.destructible & 64) {
7738
7760
  parser.report(63);
7739
7761
  }
@@ -7742,7 +7764,7 @@ function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGr
7742
7764
  }
7743
7765
  return expr;
7744
7766
  }
7745
- function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7767
+ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7746
7768
  const { tokenStart: start } = parser;
7747
7769
  nextToken(parser, context);
7748
7770
  const properties = [];
@@ -7753,7 +7775,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7753
7775
  const { tokenValue, tokenStart } = parser;
7754
7776
  const token = parser.getToken();
7755
7777
  if (token === 14) {
7756
- properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, origin, 0, inGroup, isPattern));
7778
+ properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, 0, inGroup, isPattern, origin));
7757
7779
  }
7758
7780
  else {
7759
7781
  let state = 0;
@@ -8281,6 +8303,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
8281
8303
  const params = [];
8282
8304
  parser.flags = (parser.flags | 128) ^ 128;
8283
8305
  parser.strictReservedRange = null;
8306
+ parser.firstAwaitLocation = null;
8284
8307
  if (parser.getToken() === 16) {
8285
8308
  if (kind & 512) {
8286
8309
  parser.report(37, 'Setter', 'one', '');
@@ -8310,17 +8333,17 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
8310
8333
  parser.flags |= 512;
8311
8334
  }
8312
8335
  }
8313
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8336
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8314
8337
  }
8315
8338
  else {
8316
8339
  if (parser.getToken() === 2162700) {
8317
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8340
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8318
8341
  }
8319
8342
  else if (parser.getToken() === 69271571) {
8320
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8343
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8321
8344
  }
8322
8345
  else if (parser.getToken() === 14) {
8323
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, 0, inGroup, 1);
8346
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, inGroup, 1);
8324
8347
  }
8325
8348
  isNonSimpleParameterList = 1;
8326
8349
  if (parser.destructible & (32 | 16))
@@ -8359,17 +8382,20 @@ function parseComputedPropertyName(parser, context, privateScope, inGroup) {
8359
8382
  consume(parser, context, 20);
8360
8383
  return key;
8361
8384
  }
8362
- function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, origin, start) {
8385
+ function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, start, origin) {
8363
8386
  parser.flags = (parser.flags | 128) ^ 128;
8364
8387
  const parenthesesStart = parser.tokenStart;
8365
8388
  nextToken(parser, context | 32 | 262144);
8366
8389
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8367
8390
  context = (context | 131072) ^ 131072;
8368
8391
  if (consumeOpt(parser, context, 16)) {
8369
- return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start);
8392
+ return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start, origin);
8370
8393
  }
8371
8394
  let destructible = 0;
8395
+ const previousAwaitYield = parser.destructible & (256 | 128);
8372
8396
  parser.destructible &= -385;
8397
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8398
+ parser.firstAwaitLocation = null;
8373
8399
  let expr;
8374
8400
  let expressions = [];
8375
8401
  let isSequence = 0;
@@ -8381,14 +8407,14 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8381
8407
  const { tokenStart } = parser;
8382
8408
  const token = parser.getToken();
8383
8409
  if (token & 143360) {
8384
- scope?.addBlockName(context, parser.tokenValue, 1, 0);
8410
+ scope?.addBlockName(context, parser.tokenValue, 1);
8385
8411
  if ((token & 537079808) === 537079808) {
8386
8412
  isNonSimpleParameterList = 1;
8387
8413
  }
8388
8414
  else if ((token & 36864) === 36864) {
8389
8415
  hasStrictReserved = 1;
8390
8416
  }
8391
- expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart);
8417
+ expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart, 0);
8392
8418
  if (parser.getToken() === 16 || parser.getToken() === 18) {
8393
8419
  if (parser.assignable & 2) {
8394
8420
  destructible |= 16;
@@ -8411,8 +8437,8 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8411
8437
  else if ((token & 2097152) === 2097152) {
8412
8438
  expr =
8413
8439
  token === 2162700
8414
- ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind, origin)
8415
- : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind, origin);
8440
+ ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind)
8441
+ : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind);
8416
8442
  destructible |= parser.destructible;
8417
8443
  isNonSimpleParameterList = 1;
8418
8444
  parser.assignable = 2;
@@ -8427,7 +8453,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8427
8453
  }
8428
8454
  }
8429
8455
  else if (token === 14) {
8430
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 0, 1, 0);
8456
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 1, 0);
8431
8457
  if (parser.destructible & 16)
8432
8458
  parser.report(74);
8433
8459
  isNonSimpleParameterList = 1;
@@ -8460,7 +8486,10 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8460
8486
  }, tokenAfterParenthesesStart);
8461
8487
  }
8462
8488
  consume(parser, context, 16);
8463
- parser.destructible = destructible;
8489
+ parser.destructible = destructible | previousAwaitYield;
8490
+ if (previousFirstAwaitLocation) {
8491
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8492
+ }
8464
8493
  return parser.options.preserveParens
8465
8494
  ? parser.finishNode({
8466
8495
  type: 'ParenthesizedExpression',
@@ -8501,8 +8530,12 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8501
8530
  if (parser.getToken() === 10) {
8502
8531
  if (destructible & (32 | 16))
8503
8532
  parser.report(49);
8504
- if (context & (2048 | 2) && destructible & 128)
8533
+ if (context & (2048 | 2) && destructible & 128) {
8534
+ const loc = parser.firstAwaitLocation;
8535
+ if (loc)
8536
+ throw new ParseError(loc.start, loc.end, 31);
8505
8537
  parser.report(31);
8538
+ }
8506
8539
  if (context & (1 | 1024) && destructible & 256) {
8507
8540
  parser.report(32);
8508
8541
  }
@@ -8510,7 +8543,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8510
8543
  parser.flags |= 128;
8511
8544
  if (hasStrictReserved)
8512
8545
  parser.flags |= 256;
8513
- return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start);
8546
+ return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start, origin);
8514
8547
  }
8515
8548
  if (destructible & 64) {
8516
8549
  parser.report(63);
@@ -8518,7 +8551,11 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8518
8551
  if (destructible & 8) {
8519
8552
  parser.report(146);
8520
8553
  }
8521
- parser.destructible = ((parser.destructible | 256) ^ 256) | destructible;
8554
+ parser.destructible =
8555
+ ((parser.destructible | 256) ^ 256) | destructible | previousAwaitYield;
8556
+ if (previousFirstAwaitLocation) {
8557
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8558
+ }
8522
8559
  return parser.options.preserveParens
8523
8560
  ? parser.finishNode({
8524
8561
  type: 'ParenthesizedExpression',
@@ -8549,23 +8586,23 @@ function parseIdentifierOrArrow(parser, context, privateScope) {
8549
8586
  }
8550
8587
  return expr;
8551
8588
  }
8552
- function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start) {
8589
+ function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start, origin = 0) {
8553
8590
  if (!canAssign)
8554
8591
  parser.report(57);
8555
8592
  if (inNew)
8556
8593
  parser.report(51);
8557
8594
  parser.flags &= -129;
8558
8595
  const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, value) : void 0;
8559
- return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start);
8596
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start, origin);
8560
8597
  }
8561
- function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start) {
8598
+ function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start, origin = 0) {
8562
8599
  if (!canAssign)
8563
8600
  parser.report(57);
8564
8601
  for (let i = 0; i < params.length; ++i)
8565
8602
  reinterpretToPattern(parser, params[i]);
8566
- return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start);
8603
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin);
8567
8604
  }
8568
- function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start) {
8605
+ function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin = 0) {
8569
8606
  if (parser.flags & 1)
8570
8607
  parser.report(48);
8571
8608
  consume(parser, context | 32, 10);
@@ -8583,7 +8620,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8583
8620
  else {
8584
8621
  scope = scope?.createChildScope(64);
8585
8622
  const modifierFlags = 4 | 131072 | 8;
8586
- body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, 16, void 0, void 0);
8623
+ body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, void 0, void 0, 16);
8587
8624
  switch (parser.getToken()) {
8588
8625
  case 69271571:
8589
8626
  if ((parser.flags & 1) === 0) {
@@ -8602,8 +8639,11 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8602
8639
  parser.flags |= 1024;
8603
8640
  break;
8604
8641
  }
8605
- if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0)
8606
- parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8642
+ if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0) {
8643
+ if (parser.getToken() !== 8673330 || origin !== 32) {
8644
+ parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8645
+ }
8646
+ }
8607
8647
  if ((parser.getToken() & 33619968) === 33619968)
8608
8648
  parser.report(127);
8609
8649
  }
@@ -8621,6 +8661,7 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
8621
8661
  consume(parser, context, 67174411);
8622
8662
  parser.flags = (parser.flags | 128) ^ 128;
8623
8663
  parser.strictReservedRange = null;
8664
+ parser.firstAwaitLocation = null;
8624
8665
  const params = [];
8625
8666
  if (consumeOpt(parser, context, 16))
8626
8667
  return params;
@@ -8640,17 +8681,17 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
8640
8681
  parser.flags |= 512;
8641
8682
  }
8642
8683
  }
8643
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8684
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8644
8685
  }
8645
8686
  else {
8646
8687
  if (token === 2162700) {
8647
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8688
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8648
8689
  }
8649
8690
  else if (token === 69271571) {
8650
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8691
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8651
8692
  }
8652
8693
  else if (token === 14) {
8653
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 0, inGroup, 1);
8694
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, inGroup, 1);
8654
8695
  }
8655
8696
  else {
8656
8697
  parser.report(30, KeywordDescTable[token & 255]);
@@ -8774,9 +8815,11 @@ function parseAsyncArrowAfterIdent(parser, context, privateScope, canAssign, sta
8774
8815
  }
8775
8816
  return parseArrowFromIdentifier(parser, (context & -524289) | 2048, privateScope, parser.tokenValue, parseIdentifier(parser, context), 0, canAssign, 1, start);
8776
8817
  }
8777
- function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, origin, flags, start) {
8818
+ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, flags, start) {
8778
8819
  nextToken(parser, context | 32);
8779
8820
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8821
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8822
+ parser.firstAwaitLocation = null;
8780
8823
  context = (context | 131072) ^ 131072;
8781
8824
  if (consumeOpt(parser, context, 16)) {
8782
8825
  if (parser.getToken() === 10) {
@@ -8790,6 +8833,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8790
8833
  else {
8791
8834
  parser.assignable = 2;
8792
8835
  }
8836
+ if (previousFirstAwaitLocation)
8837
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8793
8838
  return parser.finishNode({
8794
8839
  type: 'CallExpression',
8795
8840
  callee,
@@ -8808,7 +8853,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8808
8853
  const { tokenStart } = parser;
8809
8854
  const token = parser.getToken();
8810
8855
  if (token & 143360) {
8811
- scope?.addBlockName(context, parser.tokenValue, kind, 0);
8856
+ scope?.addBlockName(context, parser.tokenValue, kind);
8812
8857
  if ((token & 537079808) === 537079808) {
8813
8858
  parser.flags |= 512;
8814
8859
  }
@@ -8838,8 +8883,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8838
8883
  else if (token & 2097152) {
8839
8884
  expr =
8840
8885
  token === 2162700
8841
- ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin)
8842
- : parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin);
8886
+ ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind)
8887
+ : parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind);
8843
8888
  destructible |= parser.destructible;
8844
8889
  isNonSimpleParameterList = 1;
8845
8890
  if (parser.getToken() !== 16 && parser.getToken() !== 18) {
@@ -8856,7 +8901,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8856
8901
  }
8857
8902
  }
8858
8903
  else if (token === 14) {
8859
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 1, 1, 0);
8904
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 1, 1, 0);
8860
8905
  destructible |=
8861
8906
  (parser.getToken() === 16 ? 0 : 16) | parser.destructible;
8862
8907
  isNonSimpleParameterList = 1;
@@ -8877,6 +8922,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8877
8922
  else {
8878
8923
  parser.assignable = 2;
8879
8924
  }
8925
+ if (previousFirstAwaitLocation)
8926
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8880
8927
  return parser.finishNode({
8881
8928
  type: 'CallExpression',
8882
8929
  callee,
@@ -8900,8 +8947,12 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8900
8947
  parser.report(27);
8901
8948
  if (parser.flags & 1 || flags & 1)
8902
8949
  parser.report(48);
8903
- if (destructible & 128)
8950
+ if (destructible & 128) {
8951
+ const loc = parser.firstAwaitLocation;
8952
+ if (loc)
8953
+ throw new ParseError(loc.start, loc.end, 31);
8904
8954
  parser.report(31);
8955
+ }
8905
8956
  if (context & (1 | 1024) && destructible & 256)
8906
8957
  parser.report(32);
8907
8958
  if (isNonSimpleParameterList)
@@ -8920,6 +8971,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8920
8971
  else {
8921
8972
  parser.assignable = 2;
8922
8973
  }
8974
+ if (previousFirstAwaitLocation)
8975
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8923
8976
  return parser.finishNode({
8924
8977
  type: 'CallExpression',
8925
8978
  callee,
@@ -8966,7 +9019,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8966
9019
  parser.report(121);
8967
9020
  }
8968
9021
  if (scope) {
8969
- scope.addBlockName(context, tokenValue, 32, 0);
9022
+ scope.addBlockName(context, tokenValue, 32);
8970
9023
  if (flags) {
8971
9024
  if (flags & 2) {
8972
9025
  parser.declareUnboundVariable(tokenValue);
@@ -8987,7 +9040,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8987
9040
  else {
8988
9041
  inheritedContext = (inheritedContext | 512) ^ 512;
8989
9042
  }
8990
- const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 8, 0);
9043
+ const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 0, 8);
8991
9044
  return parser.finishNode({
8992
9045
  type: 'ClassDeclaration',
8993
9046
  id,
@@ -9018,7 +9071,7 @@ function parseClassExpression(parser, context, privateScope, inGroup, start) {
9018
9071
  else {
9019
9072
  inheritedContext = (inheritedContext | 512) ^ 512;
9020
9073
  }
9021
- const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, 0, inGroup);
9074
+ const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, inGroup);
9022
9075
  parser.assignable = 2;
9023
9076
  return parser.finishNode({
9024
9077
  type: 'ClassExpression',
@@ -9085,7 +9138,7 @@ function parseDecorator(parser, context, privateScope) {
9085
9138
  expression,
9086
9139
  }, start);
9087
9140
  }
9088
- function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, origin, inGroup) {
9141
+ function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, inGroup, origin = 0) {
9089
9142
  const { tokenStart } = parser;
9090
9143
  const privateScope = parser.createPrivateScopeIfLexical(parentScope);
9091
9144
  consume(parser, context | 32, 2162700);
@@ -9325,22 +9378,22 @@ function parsePropertyDefinition(parser, context, privateScope, key, state, deco
9325
9378
  ...(parser.features & 1 ? { decorators } : null),
9326
9379
  }, start);
9327
9380
  }
9328
- function parseBindingPattern(parser, context, scope, privateScope, type, origin) {
9381
+ function parseBindingPattern(parser, context, scope, privateScope, kind, origin = 0) {
9329
9382
  if (parser.getToken() & 143360 ||
9330
9383
  ((context & 1) === 0 && parser.getToken() === -2147483526))
9331
- return parseAndClassifyIdentifier(parser, context, scope, type, origin);
9384
+ return parseAndClassifyIdentifier(parser, context, scope, kind, origin);
9332
9385
  if ((parser.getToken() & 2097152) !== 2097152)
9333
9386
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
9334
9387
  const left = parser.getToken() === 69271571
9335
- ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, type, origin)
9336
- : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, type, origin);
9388
+ ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin)
9389
+ : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin);
9337
9390
  if (parser.destructible & 16)
9338
9391
  parser.report(50);
9339
9392
  if (parser.destructible & 32)
9340
9393
  parser.report(50);
9341
9394
  return left;
9342
9395
  }
9343
- function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
9396
+ function parseAndClassifyIdentifier(parser, context, scope, kind, origin = 0) {
9344
9397
  const token = parser.getToken();
9345
9398
  if (context & 1) {
9346
9399
  if ((token & 537079808) === 537079808) {
@@ -9468,7 +9521,7 @@ function parseJSXChildrenAndClosingFragment(parser, context, privateScope, inJSX
9468
9521
  }
9469
9522
  function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild) {
9470
9523
  if (parser.getToken() === 138)
9471
- return parseJSXText(parser, context);
9524
+ return parseJSXText(parser);
9472
9525
  if (parser.getToken() === 2162700)
9473
9526
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9474
9527
  if (parser.getToken() === 8456256) {
@@ -9482,7 +9535,7 @@ function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild
9482
9535
  }
9483
9536
  function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChild) {
9484
9537
  if (parser.getToken() === 138)
9485
- return parseJSXText(parser, context);
9538
+ return parseJSXText(parser);
9486
9539
  if (parser.getToken() === 2162700)
9487
9540
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9488
9541
  if (parser.getToken() === 8456256) {
@@ -9494,9 +9547,9 @@ function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChil
9494
9547
  }
9495
9548
  parser.report(0);
9496
9549
  }
9497
- function parseJSXText(parser, context) {
9550
+ function parseJSXText(parser) {
9498
9551
  const start = parser.tokenStart;
9499
- nextToken(parser, context);
9552
+ nextJSXToken(parser);
9500
9553
  const node = {
9501
9554
  type: 'JSXText',
9502
9555
  value: parser.tokenValue,