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.
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.meriyah = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- var version$1 = "7.3.0";
7
+ var version$1 = "7.3.1";
8
8
  var packageJson = {
9
9
  version: version$1};
10
10
 
@@ -97,7 +97,7 @@
97
97
  0,
98
98
  16384,
99
99
  0,
100
- 0,
100
+ 16384,
101
101
  0,
102
102
  0,
103
103
  1 | 2 | 64,
@@ -160,7 +160,7 @@
160
160
  1 | 2 | 4,
161
161
  16384,
162
162
  0,
163
- 0,
163
+ 16384,
164
164
  0,
165
165
  0
166
166
  ];
@@ -794,6 +794,8 @@
794
794
  [177]: "'import.meta' must not contain escaped characters",
795
795
  [178]: 'cannot use "await" as identifier inside an async function',
796
796
  [179]: 'cannot use "await" in static blocks',
797
+ [180]: "Unexpected token `}`. Did you mean `}` or `{'}'}`?",
798
+ [181]: "Unexpected token `>`. Did you mean `>` or `{'>'}`?",
797
799
  };
798
800
  class ParseError extends SyntaxError {
799
801
  start;
@@ -2251,6 +2253,9 @@
2251
2253
  if (t === 209006) {
2252
2254
  if (context & (2048 | 2))
2253
2255
  parser.report(112);
2256
+ if ((parser.destructible & 128) === 0) {
2257
+ parser.firstAwaitLocation ??= { start: parser.tokenStart, end: parser.currentLocation };
2258
+ }
2254
2259
  parser.destructible |= 128;
2255
2260
  }
2256
2261
  if (t === 241771 && context & 1024)
@@ -4532,6 +4537,12 @@
4532
4537
  parser.setToken(2162700);
4533
4538
  return;
4534
4539
  }
4540
+ if (parser.currentChar === 125) {
4541
+ parser.report(180);
4542
+ }
4543
+ if (parser.currentChar === 62) {
4544
+ parser.report(181);
4545
+ }
4535
4546
  let state = 0;
4536
4547
  while (parser.index < parser.end) {
4537
4548
  const type = CharTypes[parser.source.charCodeAt(parser.index)];
@@ -4705,7 +4716,7 @@
4705
4716
  hasVariable(name) {
4706
4717
  return this.variableBindings.has(name);
4707
4718
  }
4708
- addBlockName(context, name, kind, origin) {
4719
+ addBlockName(context, name, kind, origin = 0) {
4709
4720
  const { parser } = this;
4710
4721
  const value = this.variableBindings.get(name);
4711
4722
  if (value && (value & 2) === 0) {
@@ -4755,7 +4766,7 @@
4755
4766
  }
4756
4767
  function createArrowHeadParsingScope(parser, context, value) {
4757
4768
  const scope = parser.createScope().createChildScope(512);
4758
- scope.addBlockName(context, value, 1, 0);
4769
+ scope.addBlockName(context, value, 1);
4759
4770
  return scope;
4760
4771
  }
4761
4772
 
@@ -4785,6 +4796,7 @@
4785
4796
  assignable = 0;
4786
4797
  destructible = 0;
4787
4798
  strictReservedRange = null;
4799
+ firstAwaitLocation = null;
4788
4800
  leadingDecorators = { decorators: [] };
4789
4801
  constructor(source, rawOptions = {}) {
4790
4802
  this.source = source;
@@ -4993,7 +5005,7 @@
4993
5005
  statements.push(parseDirective(parser, context, expr, token, tokenStart));
4994
5006
  }
4995
5007
  while (parser.getToken() !== 1048576) {
4996
- statements.push(parseStatementListItem(parser, context, scope, undefined, 4, {}));
5008
+ statements.push(parseStatementListItem(parser, context, scope, undefined, {}, 4));
4997
5009
  }
4998
5010
  return statements;
4999
5011
  }
@@ -5029,18 +5041,18 @@
5029
5041
  moduleItem = parseImportDeclaration(parser, context, scope);
5030
5042
  break;
5031
5043
  default:
5032
- moduleItem = parseStatementListItem(parser, context, scope, undefined, 4, {});
5044
+ moduleItem = parseStatementListItem(parser, context, scope, undefined, {}, 4);
5033
5045
  }
5034
5046
  return moduleItem;
5035
5047
  }
5036
- function parseStatementListItem(parser, context, scope, privateScope, origin, labels) {
5048
+ function parseStatementListItem(parser, context, scope, privateScope, labels, origin = 2) {
5037
5049
  const start = parser.tokenStart;
5038
5050
  if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
5039
5051
  parser.report(172);
5040
5052
  }
5041
5053
  switch (parser.getToken()) {
5042
5054
  case 86104:
5043
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 0, start);
5055
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 0, start, origin);
5044
5056
  case 133:
5045
5057
  if (!(parser.features & 1)) {
5046
5058
  parser.report(30, '@');
@@ -5048,17 +5060,17 @@
5048
5060
  case 86094:
5049
5061
  return parseClassDeclaration(parser, context, scope, privateScope, 0);
5050
5062
  case 86090:
5051
- return parseLexicalDeclaration(parser, context, scope, privateScope, 16, 0);
5063
+ return parseLexicalDeclaration(parser, context, scope, privateScope, 16);
5052
5064
  case 241737:
5053
5065
  return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin);
5054
5066
  case 209013:
5055
- return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5067
+ return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5056
5068
  case 209006:
5057
5069
  if ((context & 2048 || (context & 2 && context & 8)) &&
5058
5070
  nextTokenIsUsingOnSameLine(parser)) {
5059
- return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5071
+ return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5060
5072
  }
5061
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5073
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5062
5074
  case 20564:
5063
5075
  parser.report(103, 'export');
5064
5076
  case 86106:
@@ -5072,15 +5084,15 @@
5072
5084
  parser.report(103, 'import');
5073
5085
  }
5074
5086
  case 209005:
5075
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 1);
5087
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 1, origin);
5076
5088
  default:
5077
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5089
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5078
5090
  }
5079
5091
  }
5080
- function parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5092
+ function parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin = 0) {
5081
5093
  switch (parser.getToken()) {
5082
5094
  case 86088:
5083
- return parseVariableStatement(parser, context, scope, privateScope, 0);
5095
+ return parseVariableStatement(parser, context, scope, privateScope);
5084
5096
  case 20572:
5085
5097
  return parseReturnStatement(parser, context, privateScope);
5086
5098
  case 20569:
@@ -5110,7 +5122,7 @@
5110
5122
  case 20560:
5111
5123
  return parseDebuggerStatement(parser, context);
5112
5124
  case 209005:
5113
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 0);
5125
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 0, origin);
5114
5126
  case 20557:
5115
5127
  parser.report(164);
5116
5128
  case 20566:
@@ -5124,10 +5136,10 @@
5124
5136
  case 86094:
5125
5137
  parser.report(79);
5126
5138
  default:
5127
- return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5139
+ return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5128
5140
  }
5129
5141
  }
5130
- function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5142
+ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5131
5143
  const { tokenValue, tokenStart } = parser;
5132
5144
  const token = parser.getToken();
5133
5145
  let expr;
@@ -5142,11 +5154,11 @@
5142
5154
  default:
5143
5155
  expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart);
5144
5156
  }
5145
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, expr, token, tokenValue, tokenStart);
5157
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, expr, token, tokenValue, tokenStart, origin);
5146
5158
  }
5147
- function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart) {
5159
+ function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart, origin) {
5148
5160
  if (token & 143360 && parser.getToken() === 21) {
5149
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart);
5161
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart, origin);
5150
5162
  }
5151
5163
  let expression = parseMemberOrUpdateExpression(parser, context, privateScope, initialExpression, 0, 0, tokenStart);
5152
5164
  expression = parseAssignmentExpression(parser, context, privateScope, 0, 0, tokenStart, expression);
@@ -5159,7 +5171,7 @@
5159
5171
  const body = [];
5160
5172
  consume(parser, context | 32, 2162700);
5161
5173
  while (parser.getToken() !== 1074790415) {
5162
- body.push(parseStatementListItem(parser, context, scope, privateScope, 2, { $: labels }));
5174
+ body.push(parseStatementListItem(parser, context, scope, privateScope, { $: labels }));
5163
5175
  }
5164
5176
  consume(parser, context | 32, 1074790415);
5165
5177
  return parser.finishNode({
@@ -5188,7 +5200,7 @@
5188
5200
  expression,
5189
5201
  }, start);
5190
5202
  }
5191
- function parseLabelledStatement(parser, context, scope, privateScope, origin, labels, value, expr, token, allowFuncDecl, start) {
5203
+ function parseLabelledStatement(parser, context, scope, privateScope, labels, value, expr, token, allowFuncDecl, start, origin) {
5192
5204
  validateBindingIdentifier(parser, context, 0, token, 1);
5193
5205
  validateAndDeclareLabel(parser, labels, value);
5194
5206
  nextToken(parser, context | 32);
@@ -5196,27 +5208,27 @@
5196
5208
  (context & 1) === 0 &&
5197
5209
  parser.options.webcompat &&
5198
5210
  parser.getToken() === 86104
5199
- ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, origin, 0, 0, 0, parser.tokenStart)
5200
- : parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5211
+ ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, parser.tokenStart, origin)
5212
+ : parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5201
5213
  return parser.finishNode({
5202
5214
  type: 'LabeledStatement',
5203
5215
  label: expr,
5204
5216
  body,
5205
5217
  }, start);
5206
5218
  }
5207
- function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5219
+ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5208
5220
  const { tokenValue, tokenStart: start } = parser;
5209
5221
  const token = parser.getToken();
5210
5222
  let expr = parseIdentifier(parser, context);
5211
5223
  if (parser.getToken() === 21) {
5212
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, expr, token, 1, start);
5224
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, 1, start, origin);
5213
5225
  }
5214
5226
  const asyncNewLine = parser.flags & 1;
5215
5227
  if (!asyncNewLine) {
5216
5228
  if (parser.getToken() === 86104) {
5217
5229
  if (!allowFuncDecl)
5218
5230
  parser.report(125);
5219
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 1, start);
5231
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 1, start, origin);
5220
5232
  }
5221
5233
  if (isValidIdentifier(context, parser.getToken())) {
5222
5234
  expr = parseAsyncArrowAfterIdent(parser, context, privateScope, 1, start);
@@ -5226,7 +5238,7 @@
5226
5238
  }
5227
5239
  }
5228
5240
  if (parser.getToken() === 67174411) {
5229
- expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, 0, asyncNewLine, start);
5241
+ expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, asyncNewLine, start);
5230
5242
  }
5231
5243
  else {
5232
5244
  if (parser.getToken() === 10) {
@@ -5312,8 +5324,8 @@
5312
5324
  return context & 1 ||
5313
5325
  !parser.options.webcompat ||
5314
5326
  parser.getToken() !== 86104
5315
- ? parseStatement(parser, context, scope, privateScope, 0, { $: labels }, 0)
5316
- : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, 0, tokenStart);
5327
+ ? parseStatement(parser, context, scope, privateScope, { $: labels }, 0)
5328
+ : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, tokenStart);
5317
5329
  }
5318
5330
  function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5319
5331
  const start = parser.tokenStart;
@@ -5342,7 +5354,7 @@
5342
5354
  while (parser.getToken() !== 20556 &&
5343
5355
  parser.getToken() !== 1074790415 &&
5344
5356
  parser.getToken() !== 20561) {
5345
- const statement = parseStatementListItem(parser, context | 4, scope, privateScope, 2, {
5357
+ const statement = parseStatementListItem(parser, context | 4, scope, privateScope, {
5346
5358
  $: labels,
5347
5359
  });
5348
5360
  if (statement.type === 'VariableDeclaration' &&
@@ -5378,7 +5390,7 @@
5378
5390
  }, start);
5379
5391
  }
5380
5392
  function parseIterationStatementBody(parser, context, scope, privateScope, labels) {
5381
- return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, 0, { loop: 1, $: labels }, 0);
5393
+ return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, { loop: 1, $: labels }, 0);
5382
5394
  }
5383
5395
  function parseContinueStatement(parser, context, labels) {
5384
5396
  if ((context & 128) === 0)
@@ -5425,7 +5437,7 @@
5425
5437
  consume(parser, context | 32, 67174411);
5426
5438
  const object = parseExpressions(parser, context, privateScope, 0, 1, parser.tokenStart);
5427
5439
  consume(parser, context | 32, 16);
5428
- const body = parseStatement(parser, context, scope, privateScope, 2, labels, 0);
5440
+ const body = parseStatement(parser, context, scope, privateScope, labels, 0, 2);
5429
5441
  return parser.finishNode({
5430
5442
  type: 'WithStatement',
5431
5443
  object,
@@ -5472,7 +5484,7 @@
5472
5484
  scope = scope?.createChildScope(4);
5473
5485
  param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
5474
5486
  ? 256
5475
- : 512, 0);
5487
+ : 512);
5476
5488
  if (parser.getToken() === 18) {
5477
5489
  parser.report(86);
5478
5490
  }
@@ -5521,7 +5533,7 @@
5521
5533
  let expr = parseIdentifier(parser, context);
5522
5534
  if (parser.getToken() & (143360 | 2097152) &&
5523
5535
  (parser.getToken() & 20480) !== 20480) {
5524
- const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8, 0);
5536
+ const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8);
5525
5537
  matchOrInsertSemicolon(parser, context | 32);
5526
5538
  return parser.finishNode({
5527
5539
  type: 'VariableDeclaration',
@@ -5533,7 +5545,7 @@
5533
5545
  if (context & 1)
5534
5546
  parser.report(85);
5535
5547
  if (parser.getToken() === 21) {
5536
- return parseLabelledStatement(parser, context, scope, privateScope, origin, {}, tokenValue, expr, token, 0, tokenStart);
5548
+ return parseLabelledStatement(parser, context, scope, privateScope, {}, tokenValue, expr, token, 0, tokenStart, origin);
5537
5549
  }
5538
5550
  if (parser.getToken() === 10) {
5539
5551
  let scope = void 0;
@@ -5587,20 +5599,23 @@
5587
5599
  function isResourceBindingStart(token) {
5588
5600
  return (token & 143360) === 143360 && (token & 20480) !== 20480;
5589
5601
  }
5590
- function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5602
+ function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5591
5603
  const { tokenStart, tokenValue } = parser;
5592
5604
  const token = parser.getToken();
5593
5605
  const expression = parseIdentifier(parser, context);
5594
5606
  if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
5595
- if (origin & 4 && context & 8 && (context & 2) === 0) {
5607
+ if (origin & 4 &&
5608
+ context & 8 &&
5609
+ (context & 2) === 0 &&
5610
+ (context & 4096) === 0) {
5596
5611
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5597
5612
  }
5598
5613
  return parseLexicalDeclaration(parser, context, scope, privateScope, 16, origin, 'using', tokenStart, 1);
5599
5614
  }
5600
5615
  parser.assignable = 1;
5601
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 1, expression, token, tokenValue, tokenStart);
5616
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 1, expression, token, tokenValue, tokenStart, origin);
5602
5617
  }
5603
- function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5618
+ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5604
5619
  const start = parser.tokenStart;
5605
5620
  if (context & 524288)
5606
5621
  parser.report(179);
@@ -5624,9 +5639,9 @@
5624
5639
  type: 'AwaitExpression',
5625
5640
  argument,
5626
5641
  }, start);
5627
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 0, expression, 1048576, '', start);
5642
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 0, expression, 1048576, '', start, origin);
5628
5643
  }
5629
- function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5644
+ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin = 0, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5630
5645
  const start = declarationStart;
5631
5646
  if (!keywordConsumed)
5632
5647
  nextToken(parser, context);
@@ -5638,7 +5653,7 @@
5638
5653
  declarations,
5639
5654
  }, start);
5640
5655
  }
5641
- function parseVariableStatement(parser, context, scope, privateScope, origin) {
5656
+ function parseVariableStatement(parser, context, scope, privateScope, origin = 0) {
5642
5657
  const start = parser.tokenStart;
5643
5658
  nextToken(parser, context);
5644
5659
  const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 4, origin);
@@ -5649,7 +5664,7 @@
5649
5664
  declarations,
5650
5665
  }, start);
5651
5666
  }
5652
- function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin, declarationKind) {
5667
+ function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin = 0, declarationKind) {
5653
5668
  let bindingCount = 1;
5654
5669
  const firstDeclaration = parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind);
5655
5670
  const list = [firstDeclaration];
@@ -5680,11 +5695,14 @@
5680
5695
  const id = parseBindingPattern(parser, context, scope, privateScope, kind, origin);
5681
5696
  if (parser.getToken() === 1077936155) {
5682
5697
  nextToken(parser, context | 32);
5683
- init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5698
+ init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart, origin);
5684
5699
  if (origin & 32) {
5685
5700
  if (parser.getToken() === 471156 ||
5686
5701
  (parser.getToken() === 8673330 &&
5687
- (token & 2097152 || (kind & 4) === 0 || context & 1))) {
5702
+ (token & 2097152 ||
5703
+ (kind & 4) === 0 ||
5704
+ context & 1 ||
5705
+ !parser.options.webcompat))) {
5688
5706
  throw new ParseError(tokenStart, parser.currentLocation, 60, parser.getToken() === 471156 ? 'of' : 'in');
5689
5707
  }
5690
5708
  }
@@ -5957,7 +5975,7 @@
5957
5975
  parser.report(120);
5958
5976
  if ((parser.getToken() & 537079808) === 537079808)
5959
5977
  parser.report(121);
5960
- scope?.addBlockName(context, parser.tokenValue, 8, 0);
5978
+ scope?.addBlockName(context, parser.tokenValue, 8);
5961
5979
  return parseIdentifier(parser, context);
5962
5980
  }
5963
5981
  function parseImportDeclaration(parser, context, scope) {
@@ -5985,7 +6003,7 @@
5985
6003
  specifiers = [parseImportNamespaceSpecifier(parser, context, scope)];
5986
6004
  }
5987
6005
  else if (parser.getToken() === 209011 || parser.getToken() === 18) {
5988
- scope?.addBlockName(context, tokenValue, 8, 0);
6006
+ scope?.addBlockName(context, tokenValue, 8);
5989
6007
  specifiers = [
5990
6008
  parser.finishNode({
5991
6009
  type: 'ImportDefaultSpecifier',
@@ -6003,7 +6021,7 @@
6003
6021
  const fromLocal = parseIdentifier(parser, context);
6004
6022
  if (parser.getToken() === 209011) {
6005
6023
  validateBindingIdentifier(parser, context, 16, fromToken, 0);
6006
- scope?.addBlockName(context, fromLocal.name, 8, 0);
6024
+ scope?.addBlockName(context, fromLocal.name, 8);
6007
6025
  phase = 'source';
6008
6026
  specifiers = [
6009
6027
  parser.finishNode({
@@ -6013,7 +6031,7 @@
6013
6031
  ];
6014
6032
  }
6015
6033
  else {
6016
- scope?.addBlockName(context, tokenValue, 8, 0);
6034
+ scope?.addBlockName(context, tokenValue, 8);
6017
6035
  specifiers = [
6018
6036
  parser.finishNode({
6019
6037
  type: 'ImportDefaultSpecifier',
@@ -6038,7 +6056,7 @@
6038
6056
  ];
6039
6057
  }
6040
6058
  else if (parser.getToken() === 18) {
6041
- scope?.addBlockName(context, tokenValue, 8, 0);
6059
+ scope?.addBlockName(context, tokenValue, 8);
6042
6060
  specifiers = [
6043
6061
  parser.finishNode({
6044
6062
  type: 'ImportDefaultSpecifier',
@@ -6145,7 +6163,7 @@
6145
6163
  else {
6146
6164
  parser.report(25, KeywordDescTable[77932 & 255]);
6147
6165
  }
6148
- scope?.addBlockName(context, tokenValue, 8, 0);
6166
+ scope?.addBlockName(context, tokenValue, 8);
6149
6167
  specifiers.push(parser.finishNode({
6150
6168
  type: 'ImportSpecifier',
6151
6169
  local,
@@ -6191,7 +6209,7 @@
6191
6209
  if (isDefaultExport) {
6192
6210
  switch (parser.getToken()) {
6193
6211
  case 86104: {
6194
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 0, parser.tokenStart);
6212
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 0, parser.tokenStart, 4);
6195
6213
  break;
6196
6214
  }
6197
6215
  case 133:
@@ -6207,11 +6225,11 @@
6207
6225
  const { flags } = parser;
6208
6226
  if ((flags & 1) === 0) {
6209
6227
  if (parser.getToken() === 86104) {
6210
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 1, tokenStart);
6228
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 1, tokenStart, 4);
6211
6229
  }
6212
6230
  else {
6213
6231
  if (parser.getToken() === 67174411) {
6214
- declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, 0, flags, tokenStart);
6232
+ declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, flags, tokenStart);
6215
6233
  declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
6216
6234
  declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
6217
6235
  }
@@ -6328,7 +6346,7 @@
6328
6346
  declaration = parseClassDeclaration(parser, context, scope, undefined, 2);
6329
6347
  break;
6330
6348
  case 86104:
6331
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 0, parser.tokenStart);
6349
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 0, parser.tokenStart, 4);
6332
6350
  break;
6333
6351
  case 241737:
6334
6352
  declaration = parseLexicalDeclaration(parser, context, scope, undefined, 8, 64);
@@ -6343,7 +6361,7 @@
6343
6361
  const { tokenStart } = parser;
6344
6362
  nextToken(parser, context);
6345
6363
  if ((parser.flags & 1) === 0 && parser.getToken() === 86104) {
6346
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 1, tokenStart);
6364
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 1, tokenStart, 4);
6347
6365
  break;
6348
6366
  }
6349
6367
  }
@@ -6359,8 +6377,8 @@
6359
6377
  };
6360
6378
  return parser.finishNode(node, start);
6361
6379
  }
6362
- function parseExpression(parser, context, privateScope, canAssign, inGroup, start) {
6363
- let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start);
6380
+ function parseExpression(parser, context, privateScope, canAssign, inGroup, start, origin = 0) {
6381
+ let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start, origin);
6364
6382
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGroup, 0, start);
6365
6383
  return parseAssignmentExpression(parser, context, privateScope, inGroup, 0, start, expr);
6366
6384
  }
@@ -6515,7 +6533,7 @@
6515
6533
  }
6516
6534
  }
6517
6535
  if (!inNew && parser.getToken() === 67174411) {
6518
- return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, 0, flags, start);
6536
+ return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, flags, start);
6519
6537
  }
6520
6538
  if (parser.getToken() === 10) {
6521
6539
  classifyIdentifier(parser, context, token);
@@ -6563,8 +6581,12 @@
6563
6581
  return parseIdentifierOrArrow(parser, context, privateScope);
6564
6582
  }
6565
6583
  function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, start) {
6566
- if (inGroup)
6584
+ if (inGroup) {
6585
+ if ((parser.destructible & 128) === 0) {
6586
+ parser.firstAwaitLocation ??= { start, end: parser.currentLocation };
6587
+ }
6567
6588
  parser.destructible |= 128;
6589
+ }
6568
6590
  if (context & 524288)
6569
6591
  parser.report(179);
6570
6592
  const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope);
@@ -6598,7 +6620,7 @@
6598
6620
  throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 98);
6599
6621
  return possibleIdentifierOrArrowFunc;
6600
6622
  }
6601
- function parseFunctionBody(parser, context, scope, privateScope, origin, funcNameToken, functionScope) {
6623
+ function parseFunctionBody(parser, context, scope, privateScope, funcNameToken, functionScope, origin = 0) {
6602
6624
  const { tokenStart } = parser;
6603
6625
  parser.flags &= -4161;
6604
6626
  consume(parser, context | 32, 2162700);
@@ -6647,7 +6669,7 @@
6647
6669
  (512 | 256 | 64 | 4096);
6648
6670
  parser.destructible = (parser.destructible | 256) ^ 256;
6649
6671
  while (parser.getToken() !== 1074790415) {
6650
- body.push(parseStatementListItem(parser, context, scope, privateScope, 4, {}));
6672
+ body.push(parseStatementListItem(parser, context, scope, privateScope, {}, 4));
6651
6673
  }
6652
6674
  consume(parser, origin & (16 | 8) ? context | 32 : context, 1074790415);
6653
6675
  parser.flags &= -4289;
@@ -6896,7 +6918,7 @@
6896
6918
  prefix: true,
6897
6919
  }, start);
6898
6920
  }
6899
- function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start) {
6921
+ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start, origin = 0) {
6900
6922
  if ((parser.getToken() & 143360) === 143360) {
6901
6923
  switch (parser.getToken()) {
6902
6924
  case 209006:
@@ -6916,7 +6938,7 @@
6916
6938
  if ((token & 36864) === 36864) {
6917
6939
  parser.flags |= 256;
6918
6940
  }
6919
- return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start);
6941
+ return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start, origin);
6920
6942
  }
6921
6943
  if (context & 16 &&
6922
6944
  !(context & 32768) &&
@@ -6957,7 +6979,7 @@
6957
6979
  case 69271571:
6958
6980
  return parseArrayLiteral(parser, context, privateScope, canAssign ? 0 : 1, inGroup);
6959
6981
  case 67174411:
6960
- return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, 0, start);
6982
+ return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, start, origin);
6961
6983
  case 86021:
6962
6984
  case 86022:
6963
6985
  case 86023:
@@ -7286,7 +7308,7 @@
7286
7308
  type: 'ThisExpression',
7287
7309
  }, tokenStart);
7288
7310
  }
7289
- function parseFunctionDeclaration(parser, context, scope, privateScope, origin, allowGen, flags, isAsync, start) {
7311
+ function parseFunctionDeclaration(parser, context, scope, privateScope, allowGen, flags, isAsync, start, origin = 0) {
7290
7312
  nextToken(parser, context | 32);
7291
7313
  const isGenerator = allowGen ? optionalBit(parser, context, 8391476) : 0;
7292
7314
  let id = null;
@@ -7340,7 +7362,7 @@
7340
7362
  functionScope = functionScope?.createChildScope(256);
7341
7363
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, functionScope, privateScope, 0, 1);
7342
7364
  const modifierFlags = 8 | 4 | 128 | 524288;
7343
- const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, 8, funcNameToken, functionScope);
7365
+ const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, funcNameToken, functionScope, 8);
7344
7366
  return parser.finishNode({
7345
7367
  type: 'FunctionDeclaration',
7346
7368
  id,
@@ -7379,7 +7401,7 @@
7379
7401
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, scope, privateScope, inGroup, 1);
7380
7402
  const body = parseFunctionBody(parser, (context & -131229) |
7381
7403
  32768 |
7382
- 4096, scope?.createChildScope(64), privateScope, 0, funcNameToken, scope);
7404
+ 4096, scope?.createChildScope(64), privateScope, funcNameToken, scope);
7383
7405
  parser.assignable = 2;
7384
7406
  return parser.finishNode({
7385
7407
  type: 'FunctionExpression',
@@ -7391,7 +7413,7 @@
7391
7413
  }, start);
7392
7414
  }
7393
7415
  function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7394
- const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7416
+ const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7395
7417
  if (parser.destructible & 64) {
7396
7418
  parser.report(63);
7397
7419
  }
@@ -7400,7 +7422,7 @@
7400
7422
  }
7401
7423
  return expr;
7402
7424
  }
7403
- function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7425
+ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7404
7426
  const { tokenStart: start } = parser;
7405
7427
  nextToken(parser, context | 32);
7406
7428
  const elements = [];
@@ -7509,7 +7531,7 @@
7509
7531
  }
7510
7532
  }
7511
7533
  else if (token === 14) {
7512
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, origin, 0, inGroup, isPattern);
7534
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, 0, inGroup, isPattern, origin);
7513
7535
  destructible |= parser.destructible;
7514
7536
  if (parser.getToken() !== 18 && parser.getToken() !== 20)
7515
7537
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
@@ -7579,7 +7601,7 @@
7579
7601
  right,
7580
7602
  }, start);
7581
7603
  }
7582
- function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, origin, isAsync, inGroup, isPattern) {
7604
+ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, isAsync, inGroup, isPattern, origin = 0) {
7583
7605
  const { tokenStart: start } = parser;
7584
7606
  nextToken(parser, context | 32);
7585
7607
  let argument = null;
@@ -7728,7 +7750,7 @@
7728
7750
  scope = scope?.createChildScope(64);
7729
7751
  const body = parseFunctionBody(parser, (context & -655373) |
7730
7752
  32768 |
7731
- 4096, scope, privateScope, 0, void 0, scope?.parent);
7753
+ 4096, scope, privateScope, void 0, scope?.parent);
7732
7754
  return parser.finishNode({
7733
7755
  type: 'FunctionExpression',
7734
7756
  params,
@@ -7739,7 +7761,7 @@
7739
7761
  }, start);
7740
7762
  }
7741
7763
  function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7742
- const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7764
+ const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7743
7765
  if (parser.destructible & 64) {
7744
7766
  parser.report(63);
7745
7767
  }
@@ -7748,7 +7770,7 @@
7748
7770
  }
7749
7771
  return expr;
7750
7772
  }
7751
- function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7773
+ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7752
7774
  const { tokenStart: start } = parser;
7753
7775
  nextToken(parser, context);
7754
7776
  const properties = [];
@@ -7759,7 +7781,7 @@
7759
7781
  const { tokenValue, tokenStart } = parser;
7760
7782
  const token = parser.getToken();
7761
7783
  if (token === 14) {
7762
- properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, origin, 0, inGroup, isPattern));
7784
+ properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, 0, inGroup, isPattern, origin));
7763
7785
  }
7764
7786
  else {
7765
7787
  let state = 0;
@@ -8287,6 +8309,7 @@
8287
8309
  const params = [];
8288
8310
  parser.flags = (parser.flags | 128) ^ 128;
8289
8311
  parser.strictReservedRange = null;
8312
+ parser.firstAwaitLocation = null;
8290
8313
  if (parser.getToken() === 16) {
8291
8314
  if (kind & 512) {
8292
8315
  parser.report(37, 'Setter', 'one', '');
@@ -8316,17 +8339,17 @@
8316
8339
  parser.flags |= 512;
8317
8340
  }
8318
8341
  }
8319
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8342
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8320
8343
  }
8321
8344
  else {
8322
8345
  if (parser.getToken() === 2162700) {
8323
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8346
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8324
8347
  }
8325
8348
  else if (parser.getToken() === 69271571) {
8326
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8349
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8327
8350
  }
8328
8351
  else if (parser.getToken() === 14) {
8329
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, 0, inGroup, 1);
8352
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, inGroup, 1);
8330
8353
  }
8331
8354
  isNonSimpleParameterList = 1;
8332
8355
  if (parser.destructible & (32 | 16))
@@ -8365,17 +8388,20 @@
8365
8388
  consume(parser, context, 20);
8366
8389
  return key;
8367
8390
  }
8368
- function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, origin, start) {
8391
+ function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, start, origin) {
8369
8392
  parser.flags = (parser.flags | 128) ^ 128;
8370
8393
  const parenthesesStart = parser.tokenStart;
8371
8394
  nextToken(parser, context | 32 | 262144);
8372
8395
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8373
8396
  context = (context | 131072) ^ 131072;
8374
8397
  if (consumeOpt(parser, context, 16)) {
8375
- return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start);
8398
+ return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start, origin);
8376
8399
  }
8377
8400
  let destructible = 0;
8401
+ const previousAwaitYield = parser.destructible & (256 | 128);
8378
8402
  parser.destructible &= -385;
8403
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8404
+ parser.firstAwaitLocation = null;
8379
8405
  let expr;
8380
8406
  let expressions = [];
8381
8407
  let isSequence = 0;
@@ -8387,14 +8413,14 @@
8387
8413
  const { tokenStart } = parser;
8388
8414
  const token = parser.getToken();
8389
8415
  if (token & 143360) {
8390
- scope?.addBlockName(context, parser.tokenValue, 1, 0);
8416
+ scope?.addBlockName(context, parser.tokenValue, 1);
8391
8417
  if ((token & 537079808) === 537079808) {
8392
8418
  isNonSimpleParameterList = 1;
8393
8419
  }
8394
8420
  else if ((token & 36864) === 36864) {
8395
8421
  hasStrictReserved = 1;
8396
8422
  }
8397
- expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart);
8423
+ expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart, 0);
8398
8424
  if (parser.getToken() === 16 || parser.getToken() === 18) {
8399
8425
  if (parser.assignable & 2) {
8400
8426
  destructible |= 16;
@@ -8417,8 +8443,8 @@
8417
8443
  else if ((token & 2097152) === 2097152) {
8418
8444
  expr =
8419
8445
  token === 2162700
8420
- ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind, origin)
8421
- : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind, origin);
8446
+ ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind)
8447
+ : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind);
8422
8448
  destructible |= parser.destructible;
8423
8449
  isNonSimpleParameterList = 1;
8424
8450
  parser.assignable = 2;
@@ -8433,7 +8459,7 @@
8433
8459
  }
8434
8460
  }
8435
8461
  else if (token === 14) {
8436
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 0, 1, 0);
8462
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 1, 0);
8437
8463
  if (parser.destructible & 16)
8438
8464
  parser.report(74);
8439
8465
  isNonSimpleParameterList = 1;
@@ -8466,7 +8492,10 @@
8466
8492
  }, tokenAfterParenthesesStart);
8467
8493
  }
8468
8494
  consume(parser, context, 16);
8469
- parser.destructible = destructible;
8495
+ parser.destructible = destructible | previousAwaitYield;
8496
+ if (previousFirstAwaitLocation) {
8497
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8498
+ }
8470
8499
  return parser.options.preserveParens
8471
8500
  ? parser.finishNode({
8472
8501
  type: 'ParenthesizedExpression',
@@ -8507,8 +8536,12 @@
8507
8536
  if (parser.getToken() === 10) {
8508
8537
  if (destructible & (32 | 16))
8509
8538
  parser.report(49);
8510
- if (context & (2048 | 2) && destructible & 128)
8539
+ if (context & (2048 | 2) && destructible & 128) {
8540
+ const loc = parser.firstAwaitLocation;
8541
+ if (loc)
8542
+ throw new ParseError(loc.start, loc.end, 31);
8511
8543
  parser.report(31);
8544
+ }
8512
8545
  if (context & (1 | 1024) && destructible & 256) {
8513
8546
  parser.report(32);
8514
8547
  }
@@ -8516,7 +8549,7 @@
8516
8549
  parser.flags |= 128;
8517
8550
  if (hasStrictReserved)
8518
8551
  parser.flags |= 256;
8519
- return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start);
8552
+ return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start, origin);
8520
8553
  }
8521
8554
  if (destructible & 64) {
8522
8555
  parser.report(63);
@@ -8524,7 +8557,11 @@
8524
8557
  if (destructible & 8) {
8525
8558
  parser.report(146);
8526
8559
  }
8527
- parser.destructible = ((parser.destructible | 256) ^ 256) | destructible;
8560
+ parser.destructible =
8561
+ ((parser.destructible | 256) ^ 256) | destructible | previousAwaitYield;
8562
+ if (previousFirstAwaitLocation) {
8563
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8564
+ }
8528
8565
  return parser.options.preserveParens
8529
8566
  ? parser.finishNode({
8530
8567
  type: 'ParenthesizedExpression',
@@ -8555,23 +8592,23 @@
8555
8592
  }
8556
8593
  return expr;
8557
8594
  }
8558
- function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start) {
8595
+ function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start, origin = 0) {
8559
8596
  if (!canAssign)
8560
8597
  parser.report(57);
8561
8598
  if (inNew)
8562
8599
  parser.report(51);
8563
8600
  parser.flags &= -129;
8564
8601
  const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, value) : void 0;
8565
- return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start);
8602
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start, origin);
8566
8603
  }
8567
- function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start) {
8604
+ function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start, origin = 0) {
8568
8605
  if (!canAssign)
8569
8606
  parser.report(57);
8570
8607
  for (let i = 0; i < params.length; ++i)
8571
8608
  reinterpretToPattern(parser, params[i]);
8572
- return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start);
8609
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin);
8573
8610
  }
8574
- function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start) {
8611
+ function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin = 0) {
8575
8612
  if (parser.flags & 1)
8576
8613
  parser.report(48);
8577
8614
  consume(parser, context | 32, 10);
@@ -8589,7 +8626,7 @@
8589
8626
  else {
8590
8627
  scope = scope?.createChildScope(64);
8591
8628
  const modifierFlags = 4 | 131072 | 8;
8592
- body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, 16, void 0, void 0);
8629
+ body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, void 0, void 0, 16);
8593
8630
  switch (parser.getToken()) {
8594
8631
  case 69271571:
8595
8632
  if ((parser.flags & 1) === 0) {
@@ -8608,8 +8645,11 @@
8608
8645
  parser.flags |= 1024;
8609
8646
  break;
8610
8647
  }
8611
- if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0)
8612
- parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8648
+ if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0) {
8649
+ if (parser.getToken() !== 8673330 || origin !== 32) {
8650
+ parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8651
+ }
8652
+ }
8613
8653
  if ((parser.getToken() & 33619968) === 33619968)
8614
8654
  parser.report(127);
8615
8655
  }
@@ -8627,6 +8667,7 @@
8627
8667
  consume(parser, context, 67174411);
8628
8668
  parser.flags = (parser.flags | 128) ^ 128;
8629
8669
  parser.strictReservedRange = null;
8670
+ parser.firstAwaitLocation = null;
8630
8671
  const params = [];
8631
8672
  if (consumeOpt(parser, context, 16))
8632
8673
  return params;
@@ -8646,17 +8687,17 @@
8646
8687
  parser.flags |= 512;
8647
8688
  }
8648
8689
  }
8649
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8690
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8650
8691
  }
8651
8692
  else {
8652
8693
  if (token === 2162700) {
8653
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8694
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8654
8695
  }
8655
8696
  else if (token === 69271571) {
8656
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8697
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8657
8698
  }
8658
8699
  else if (token === 14) {
8659
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 0, inGroup, 1);
8700
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, inGroup, 1);
8660
8701
  }
8661
8702
  else {
8662
8703
  parser.report(30, KeywordDescTable[token & 255]);
@@ -8780,9 +8821,11 @@
8780
8821
  }
8781
8822
  return parseArrowFromIdentifier(parser, (context & -524289) | 2048, privateScope, parser.tokenValue, parseIdentifier(parser, context), 0, canAssign, 1, start);
8782
8823
  }
8783
- function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, origin, flags, start) {
8824
+ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, flags, start) {
8784
8825
  nextToken(parser, context | 32);
8785
8826
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8827
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8828
+ parser.firstAwaitLocation = null;
8786
8829
  context = (context | 131072) ^ 131072;
8787
8830
  if (consumeOpt(parser, context, 16)) {
8788
8831
  if (parser.getToken() === 10) {
@@ -8796,6 +8839,8 @@
8796
8839
  else {
8797
8840
  parser.assignable = 2;
8798
8841
  }
8842
+ if (previousFirstAwaitLocation)
8843
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8799
8844
  return parser.finishNode({
8800
8845
  type: 'CallExpression',
8801
8846
  callee,
@@ -8814,7 +8859,7 @@
8814
8859
  const { tokenStart } = parser;
8815
8860
  const token = parser.getToken();
8816
8861
  if (token & 143360) {
8817
- scope?.addBlockName(context, parser.tokenValue, kind, 0);
8862
+ scope?.addBlockName(context, parser.tokenValue, kind);
8818
8863
  if ((token & 537079808) === 537079808) {
8819
8864
  parser.flags |= 512;
8820
8865
  }
@@ -8844,8 +8889,8 @@
8844
8889
  else if (token & 2097152) {
8845
8890
  expr =
8846
8891
  token === 2162700
8847
- ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin)
8848
- : parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin);
8892
+ ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind)
8893
+ : parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind);
8849
8894
  destructible |= parser.destructible;
8850
8895
  isNonSimpleParameterList = 1;
8851
8896
  if (parser.getToken() !== 16 && parser.getToken() !== 18) {
@@ -8862,7 +8907,7 @@
8862
8907
  }
8863
8908
  }
8864
8909
  else if (token === 14) {
8865
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 1, 1, 0);
8910
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 1, 1, 0);
8866
8911
  destructible |=
8867
8912
  (parser.getToken() === 16 ? 0 : 16) | parser.destructible;
8868
8913
  isNonSimpleParameterList = 1;
@@ -8883,6 +8928,8 @@
8883
8928
  else {
8884
8929
  parser.assignable = 2;
8885
8930
  }
8931
+ if (previousFirstAwaitLocation)
8932
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8886
8933
  return parser.finishNode({
8887
8934
  type: 'CallExpression',
8888
8935
  callee,
@@ -8906,8 +8953,12 @@
8906
8953
  parser.report(27);
8907
8954
  if (parser.flags & 1 || flags & 1)
8908
8955
  parser.report(48);
8909
- if (destructible & 128)
8956
+ if (destructible & 128) {
8957
+ const loc = parser.firstAwaitLocation;
8958
+ if (loc)
8959
+ throw new ParseError(loc.start, loc.end, 31);
8910
8960
  parser.report(31);
8961
+ }
8911
8962
  if (context & (1 | 1024) && destructible & 256)
8912
8963
  parser.report(32);
8913
8964
  if (isNonSimpleParameterList)
@@ -8926,6 +8977,8 @@
8926
8977
  else {
8927
8978
  parser.assignable = 2;
8928
8979
  }
8980
+ if (previousFirstAwaitLocation)
8981
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8929
8982
  return parser.finishNode({
8930
8983
  type: 'CallExpression',
8931
8984
  callee,
@@ -8972,7 +9025,7 @@
8972
9025
  parser.report(121);
8973
9026
  }
8974
9027
  if (scope) {
8975
- scope.addBlockName(context, tokenValue, 32, 0);
9028
+ scope.addBlockName(context, tokenValue, 32);
8976
9029
  if (flags) {
8977
9030
  if (flags & 2) {
8978
9031
  parser.declareUnboundVariable(tokenValue);
@@ -8993,7 +9046,7 @@
8993
9046
  else {
8994
9047
  inheritedContext = (inheritedContext | 512) ^ 512;
8995
9048
  }
8996
- const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 8, 0);
9049
+ const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 0, 8);
8997
9050
  return parser.finishNode({
8998
9051
  type: 'ClassDeclaration',
8999
9052
  id,
@@ -9024,7 +9077,7 @@
9024
9077
  else {
9025
9078
  inheritedContext = (inheritedContext | 512) ^ 512;
9026
9079
  }
9027
- const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, 0, inGroup);
9080
+ const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, inGroup);
9028
9081
  parser.assignable = 2;
9029
9082
  return parser.finishNode({
9030
9083
  type: 'ClassExpression',
@@ -9091,7 +9144,7 @@
9091
9144
  expression,
9092
9145
  }, start);
9093
9146
  }
9094
- function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, origin, inGroup) {
9147
+ function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, inGroup, origin = 0) {
9095
9148
  const { tokenStart } = parser;
9096
9149
  const privateScope = parser.createPrivateScopeIfLexical(parentScope);
9097
9150
  consume(parser, context | 32, 2162700);
@@ -9331,22 +9384,22 @@
9331
9384
  ...(parser.features & 1 ? { decorators } : null),
9332
9385
  }, start);
9333
9386
  }
9334
- function parseBindingPattern(parser, context, scope, privateScope, type, origin) {
9387
+ function parseBindingPattern(parser, context, scope, privateScope, kind, origin = 0) {
9335
9388
  if (parser.getToken() & 143360 ||
9336
9389
  ((context & 1) === 0 && parser.getToken() === -2147483526))
9337
- return parseAndClassifyIdentifier(parser, context, scope, type, origin);
9390
+ return parseAndClassifyIdentifier(parser, context, scope, kind, origin);
9338
9391
  if ((parser.getToken() & 2097152) !== 2097152)
9339
9392
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
9340
9393
  const left = parser.getToken() === 69271571
9341
- ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, type, origin)
9342
- : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, type, origin);
9394
+ ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin)
9395
+ : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin);
9343
9396
  if (parser.destructible & 16)
9344
9397
  parser.report(50);
9345
9398
  if (parser.destructible & 32)
9346
9399
  parser.report(50);
9347
9400
  return left;
9348
9401
  }
9349
- function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
9402
+ function parseAndClassifyIdentifier(parser, context, scope, kind, origin = 0) {
9350
9403
  const token = parser.getToken();
9351
9404
  if (context & 1) {
9352
9405
  if ((token & 537079808) === 537079808) {
@@ -9474,7 +9527,7 @@
9474
9527
  }
9475
9528
  function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild) {
9476
9529
  if (parser.getToken() === 138)
9477
- return parseJSXText(parser, context);
9530
+ return parseJSXText(parser);
9478
9531
  if (parser.getToken() === 2162700)
9479
9532
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9480
9533
  if (parser.getToken() === 8456256) {
@@ -9488,7 +9541,7 @@
9488
9541
  }
9489
9542
  function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChild) {
9490
9543
  if (parser.getToken() === 138)
9491
- return parseJSXText(parser, context);
9544
+ return parseJSXText(parser);
9492
9545
  if (parser.getToken() === 2162700)
9493
9546
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9494
9547
  if (parser.getToken() === 8456256) {
@@ -9500,9 +9553,9 @@
9500
9553
  }
9501
9554
  parser.report(0);
9502
9555
  }
9503
- function parseJSXText(parser, context) {
9556
+ function parseJSXText(parser) {
9504
9557
  const start = parser.tokenStart;
9505
- nextToken(parser, context);
9558
+ nextJSXToken(parser);
9506
9559
  const node = {
9507
9560
  type: 'JSXText',
9508
9561
  value: parser.tokenValue,