meriyah 7.3.0 → 7.3.2

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.2";
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;
@@ -2038,6 +2040,9 @@ function scanSingleToken(parser, context, state) {
2038
2040
  }
2039
2041
  case 8390721: {
2040
2042
  advanceChar(parser);
2043
+ if (context & 1048576) {
2044
+ return 8390721;
2045
+ }
2041
2046
  const ch = parser.currentChar;
2042
2047
  if (ch === 61) {
2043
2048
  advanceChar(parser);
@@ -2245,6 +2250,9 @@ function isStrictReservedWord(parser, context, t) {
2245
2250
  if (t === 209006) {
2246
2251
  if (context & (2048 | 2))
2247
2252
  parser.report(112);
2253
+ if ((parser.destructible & 128) === 0) {
2254
+ parser.firstAwaitLocation ??= { start: parser.tokenStart, end: parser.currentLocation };
2255
+ }
2248
2256
  parser.destructible |= 128;
2249
2257
  }
2250
2258
  if (t === 241771 && context & 1024)
@@ -4526,6 +4534,12 @@ function nextJSXToken(parser) {
4526
4534
  parser.setToken(2162700);
4527
4535
  return;
4528
4536
  }
4537
+ if (parser.currentChar === 125) {
4538
+ parser.report(180);
4539
+ }
4540
+ if (parser.currentChar === 62) {
4541
+ parser.report(181);
4542
+ }
4529
4543
  let state = 0;
4530
4544
  while (parser.index < parser.end) {
4531
4545
  const type = CharTypes[parser.source.charCodeAt(parser.index)];
@@ -4552,7 +4566,7 @@ function nextJSXToken(parser) {
4552
4566
  parser.setToken(138);
4553
4567
  }
4554
4568
  function rescanJSXIdentifier(parser) {
4555
- if ((parser.getToken() & 143360) === 143360) {
4569
+ if (parser.getToken() & 143360) {
4556
4570
  const { index } = parser;
4557
4571
  let char = parser.currentChar;
4558
4572
  while (CharTypes[char] & (32768 | 2)) {
@@ -4657,18 +4671,18 @@ class Scope {
4657
4671
  createChildScope(type) {
4658
4672
  return new Scope(this.parser, type, this);
4659
4673
  }
4660
- addVarOrBlock(context, name, kind, origin) {
4674
+ addVarOrBlock(context, name, kind, tokenStart, tokenEnd, origin) {
4661
4675
  if (kind & 4) {
4662
- this.addVarName(context, name, kind);
4676
+ this.addVarName(context, name, kind, tokenStart, tokenEnd);
4663
4677
  }
4664
4678
  else {
4665
- this.addBlockName(context, name, kind, origin);
4679
+ this.addBlockName(context, name, kind, tokenStart, tokenEnd, origin);
4666
4680
  }
4667
4681
  if (origin & 64) {
4668
4682
  this.parser.declareUnboundVariable(name);
4669
4683
  }
4670
4684
  }
4671
- addVarName(context, name, kind) {
4685
+ addVarName(context, name, kind, tokenStart, tokenEnd) {
4672
4686
  const { parser } = this;
4673
4687
  let currentScope = this;
4674
4688
  while (currentScope && (currentScope.type & 128) === 0) {
@@ -4680,17 +4694,17 @@ class Scope {
4680
4694
  ((kind & 128 && value & 68) ||
4681
4695
  (value & 128 && kind & 68))) ;
4682
4696
  else {
4683
- parser.report(147, name);
4697
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4684
4698
  }
4685
4699
  }
4686
4700
  if (currentScope === this) {
4687
4701
  if (value && value & 1 && kind & 1) {
4688
- currentScope.recordScopeError(147, name);
4702
+ currentScope.recordScopeError(147, tokenStart, tokenEnd, name);
4689
4703
  }
4690
4704
  }
4691
4705
  if (value &&
4692
4706
  (value & 256 || (value & 512 && !parser.options.webcompat))) {
4693
- parser.report(147, name);
4707
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4694
4708
  }
4695
4709
  currentScope.variableBindings.set(name, kind);
4696
4710
  currentScope = currentScope.parent;
@@ -4699,12 +4713,12 @@ class Scope {
4699
4713
  hasVariable(name) {
4700
4714
  return this.variableBindings.has(name);
4701
4715
  }
4702
- addBlockName(context, name, kind, origin) {
4716
+ addBlockName(context, name, kind, tokenStart, tokenEnd, origin = 0) {
4703
4717
  const { parser } = this;
4704
4718
  const value = this.variableBindings.get(name);
4705
4719
  if (value && (value & 2) === 0) {
4706
4720
  if (kind & 1) {
4707
- this.recordScopeError(147, name);
4721
+ this.recordScopeError(147, tokenStart, tokenEnd, name);
4708
4722
  }
4709
4723
  else if (parser.options.webcompat &&
4710
4724
  (context & 1) === 0 &&
@@ -4712,31 +4726,31 @@ class Scope {
4712
4726
  value === 64 &&
4713
4727
  kind === 64) ;
4714
4728
  else {
4715
- parser.report(147, name);
4729
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4716
4730
  }
4717
4731
  }
4718
4732
  if (this.type & 64 &&
4719
4733
  this.parent?.hasVariable(name) &&
4720
4734
  (this.parent.variableBindings.get(name) & 2) === 0) {
4721
- parser.report(147, name);
4735
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4722
4736
  }
4723
4737
  if (this.type & 512 && value && (value & 2) === 0) {
4724
4738
  if (kind & 1) {
4725
- this.recordScopeError(147, name);
4739
+ this.recordScopeError(147, tokenStart, tokenEnd, name);
4726
4740
  }
4727
4741
  }
4728
4742
  if (this.type & 32) {
4729
4743
  if (this.parent.variableBindings.get(name) & 768)
4730
- parser.report(161, name);
4744
+ throw new ParseError(tokenStart, tokenEnd, 161, name);
4731
4745
  }
4732
4746
  this.variableBindings.set(name, kind);
4733
4747
  }
4734
- recordScopeError(type, ...params) {
4735
- this.scopeError = {
4748
+ recordScopeError(type, tokenStart, tokenEnd, ...params) {
4749
+ this.scopeError ??= {
4736
4750
  type,
4737
4751
  params,
4738
- start: this.parser.tokenStart,
4739
- end: this.parser.currentLocation,
4752
+ start: tokenStart,
4753
+ end: tokenEnd,
4740
4754
  };
4741
4755
  }
4742
4756
  reportScopeError() {
@@ -4747,9 +4761,9 @@ class Scope {
4747
4761
  throw new ParseError(scopeError.start, scopeError.end, scopeError.type, ...scopeError.params);
4748
4762
  }
4749
4763
  }
4750
- function createArrowHeadParsingScope(parser, context, value) {
4764
+ function createArrowHeadParsingScope(parser, context, value, tokenStart, tokenEnd) {
4751
4765
  const scope = parser.createScope().createChildScope(512);
4752
- scope.addBlockName(context, value, 1, 0);
4766
+ scope.addBlockName(context, value, 1, tokenStart, tokenEnd);
4753
4767
  return scope;
4754
4768
  }
4755
4769
 
@@ -4779,6 +4793,7 @@ class Parser {
4779
4793
  assignable = 0;
4780
4794
  destructible = 0;
4781
4795
  strictReservedRange = null;
4796
+ firstAwaitLocation = null;
4782
4797
  leadingDecorators = { decorators: [] };
4783
4798
  constructor(source, rawOptions = {}) {
4784
4799
  this.source = source;
@@ -4987,7 +5002,7 @@ function parseStatementList(parser, context, scope) {
4987
5002
  statements.push(parseDirective(parser, context, expr, token, tokenStart));
4988
5003
  }
4989
5004
  while (parser.getToken() !== 1048576) {
4990
- statements.push(parseStatementListItem(parser, context, scope, undefined, 4, {}));
5005
+ statements.push(parseStatementListItem(parser, context, scope, undefined, {}, 4));
4991
5006
  }
4992
5007
  return statements;
4993
5008
  }
@@ -5023,18 +5038,18 @@ function parseModuleItem(parser, context, scope) {
5023
5038
  moduleItem = parseImportDeclaration(parser, context, scope);
5024
5039
  break;
5025
5040
  default:
5026
- moduleItem = parseStatementListItem(parser, context, scope, undefined, 4, {});
5041
+ moduleItem = parseStatementListItem(parser, context, scope, undefined, {}, 4);
5027
5042
  }
5028
5043
  return moduleItem;
5029
5044
  }
5030
- function parseStatementListItem(parser, context, scope, privateScope, origin, labels) {
5045
+ function parseStatementListItem(parser, context, scope, privateScope, labels, origin = 2) {
5031
5046
  const start = parser.tokenStart;
5032
5047
  if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
5033
5048
  parser.report(172);
5034
5049
  }
5035
5050
  switch (parser.getToken()) {
5036
5051
  case 86104:
5037
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 0, start);
5052
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 0, start, origin);
5038
5053
  case 133:
5039
5054
  if (!(parser.features & 1)) {
5040
5055
  parser.report(30, '@');
@@ -5042,17 +5057,17 @@ function parseStatementListItem(parser, context, scope, privateScope, origin, la
5042
5057
  case 86094:
5043
5058
  return parseClassDeclaration(parser, context, scope, privateScope, 0);
5044
5059
  case 86090:
5045
- return parseLexicalDeclaration(parser, context, scope, privateScope, 16, 0);
5060
+ return parseLexicalDeclaration(parser, context, scope, privateScope, 16);
5046
5061
  case 241737:
5047
5062
  return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin);
5048
5063
  case 209013:
5049
- return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5064
+ return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5050
5065
  case 209006:
5051
5066
  if ((context & 2048 || (context & 2 && context & 8)) &&
5052
5067
  nextTokenIsUsingOnSameLine(parser)) {
5053
- return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5068
+ return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5054
5069
  }
5055
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5070
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5056
5071
  case 20564:
5057
5072
  parser.report(103, 'export');
5058
5073
  case 86106:
@@ -5066,15 +5081,15 @@ function parseStatementListItem(parser, context, scope, privateScope, origin, la
5066
5081
  parser.report(103, 'import');
5067
5082
  }
5068
5083
  case 209005:
5069
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 1);
5084
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 1, origin);
5070
5085
  default:
5071
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5086
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5072
5087
  }
5073
5088
  }
5074
- function parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5089
+ function parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin = 0) {
5075
5090
  switch (parser.getToken()) {
5076
5091
  case 86088:
5077
- return parseVariableStatement(parser, context, scope, privateScope, 0);
5092
+ return parseVariableStatement(parser, context, scope, privateScope);
5078
5093
  case 20572:
5079
5094
  return parseReturnStatement(parser, context, privateScope);
5080
5095
  case 20569:
@@ -5104,7 +5119,7 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
5104
5119
  case 20560:
5105
5120
  return parseDebuggerStatement(parser, context);
5106
5121
  case 209005:
5107
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 0);
5122
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 0, origin);
5108
5123
  case 20557:
5109
5124
  parser.report(164);
5110
5125
  case 20566:
@@ -5118,10 +5133,10 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
5118
5133
  case 86094:
5119
5134
  parser.report(79);
5120
5135
  default:
5121
- return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5136
+ return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5122
5137
  }
5123
5138
  }
5124
- function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5139
+ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5125
5140
  const { tokenValue, tokenStart } = parser;
5126
5141
  const token = parser.getToken();
5127
5142
  let expr;
@@ -5136,11 +5151,11 @@ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope
5136
5151
  default:
5137
5152
  expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart);
5138
5153
  }
5139
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, expr, token, tokenValue, tokenStart);
5154
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, expr, token, tokenValue, tokenStart, origin);
5140
5155
  }
5141
- function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart) {
5156
+ function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart, origin) {
5142
5157
  if (token & 143360 && parser.getToken() === 21) {
5143
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart);
5158
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart, origin);
5144
5159
  }
5145
5160
  let expression = parseMemberOrUpdateExpression(parser, context, privateScope, initialExpression, 0, 0, tokenStart);
5146
5161
  expression = parseAssignmentExpression(parser, context, privateScope, 0, 0, tokenStart, expression);
@@ -5153,7 +5168,7 @@ function parseBlock(parser, context, scope, privateScope, labels, start = parser
5153
5168
  const body = [];
5154
5169
  consume(parser, context | 32, 2162700);
5155
5170
  while (parser.getToken() !== 1074790415) {
5156
- body.push(parseStatementListItem(parser, context, scope, privateScope, 2, { $: labels }));
5171
+ body.push(parseStatementListItem(parser, context, scope, privateScope, { $: labels }));
5157
5172
  }
5158
5173
  consume(parser, context | 32, 1074790415);
5159
5174
  return parser.finishNode({
@@ -5182,7 +5197,7 @@ function parseExpressionStatement(parser, context, expression, start) {
5182
5197
  expression,
5183
5198
  }, start);
5184
5199
  }
5185
- function parseLabelledStatement(parser, context, scope, privateScope, origin, labels, value, expr, token, allowFuncDecl, start) {
5200
+ function parseLabelledStatement(parser, context, scope, privateScope, labels, value, expr, token, allowFuncDecl, start, origin) {
5186
5201
  validateBindingIdentifier(parser, context, 0, token, 1);
5187
5202
  validateAndDeclareLabel(parser, labels, value);
5188
5203
  nextToken(parser, context | 32);
@@ -5190,27 +5205,27 @@ function parseLabelledStatement(parser, context, scope, privateScope, origin, la
5190
5205
  (context & 1) === 0 &&
5191
5206
  parser.options.webcompat &&
5192
5207
  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);
5208
+ ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, parser.tokenStart, origin)
5209
+ : parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5195
5210
  return parser.finishNode({
5196
5211
  type: 'LabeledStatement',
5197
5212
  label: expr,
5198
5213
  body,
5199
5214
  }, start);
5200
5215
  }
5201
- function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5216
+ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5202
5217
  const { tokenValue, tokenStart: start } = parser;
5203
5218
  const token = parser.getToken();
5204
5219
  let expr = parseIdentifier(parser, context);
5205
5220
  if (parser.getToken() === 21) {
5206
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, expr, token, 1, start);
5221
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, 1, start, origin);
5207
5222
  }
5208
5223
  const asyncNewLine = parser.flags & 1;
5209
5224
  if (!asyncNewLine) {
5210
5225
  if (parser.getToken() === 86104) {
5211
5226
  if (!allowFuncDecl)
5212
5227
  parser.report(125);
5213
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 1, start);
5228
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 1, start, origin);
5214
5229
  }
5215
5230
  if (isValidIdentifier(context, parser.getToken())) {
5216
5231
  expr = parseAsyncArrowAfterIdent(parser, context, privateScope, 1, start);
@@ -5220,7 +5235,7 @@ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, priva
5220
5235
  }
5221
5236
  }
5222
5237
  if (parser.getToken() === 67174411) {
5223
- expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, 0, asyncNewLine, start);
5238
+ expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, asyncNewLine, start);
5224
5239
  }
5225
5240
  else {
5226
5241
  if (parser.getToken() === 10) {
@@ -5306,8 +5321,8 @@ function parseConsequentOrAlternative(parser, context, scope, privateScope, labe
5306
5321
  return context & 1 ||
5307
5322
  !parser.options.webcompat ||
5308
5323
  parser.getToken() !== 86104
5309
- ? parseStatement(parser, context, scope, privateScope, 0, { $: labels }, 0)
5310
- : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, 0, tokenStart);
5324
+ ? parseStatement(parser, context, scope, privateScope, { $: labels }, 0)
5325
+ : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, tokenStart);
5311
5326
  }
5312
5327
  function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5313
5328
  const start = parser.tokenStart;
@@ -5336,7 +5351,7 @@ function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5336
5351
  while (parser.getToken() !== 20556 &&
5337
5352
  parser.getToken() !== 1074790415 &&
5338
5353
  parser.getToken() !== 20561) {
5339
- const statement = parseStatementListItem(parser, context | 4, scope, privateScope, 2, {
5354
+ const statement = parseStatementListItem(parser, context | 4, scope, privateScope, {
5340
5355
  $: labels,
5341
5356
  });
5342
5357
  if (statement.type === 'VariableDeclaration' &&
@@ -5372,7 +5387,7 @@ function parseWhileStatement(parser, context, scope, privateScope, labels) {
5372
5387
  }, start);
5373
5388
  }
5374
5389
  function parseIterationStatementBody(parser, context, scope, privateScope, labels) {
5375
- return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, 0, { loop: 1, $: labels }, 0);
5390
+ return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, { loop: 1, $: labels }, 0);
5376
5391
  }
5377
5392
  function parseContinueStatement(parser, context, labels) {
5378
5393
  if ((context & 128) === 0)
@@ -5419,7 +5434,7 @@ function parseWithStatement(parser, context, scope, privateScope, labels) {
5419
5434
  consume(parser, context | 32, 67174411);
5420
5435
  const object = parseExpressions(parser, context, privateScope, 0, 1, parser.tokenStart);
5421
5436
  consume(parser, context | 32, 16);
5422
- const body = parseStatement(parser, context, scope, privateScope, 2, labels, 0);
5437
+ const body = parseStatement(parser, context, scope, privateScope, labels, 0, 2);
5423
5438
  return parser.finishNode({
5424
5439
  type: 'WithStatement',
5425
5440
  object,
@@ -5466,7 +5481,7 @@ function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
5466
5481
  scope = scope?.createChildScope(4);
5467
5482
  param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
5468
5483
  ? 256
5469
- : 512, 0);
5484
+ : 512);
5470
5485
  if (parser.getToken() === 18) {
5471
5486
  parser.report(86);
5472
5487
  }
@@ -5510,12 +5525,12 @@ function parseDoWhileStatement(parser, context, scope, privateScope, labels) {
5510
5525
  }, start);
5511
5526
  }
5512
5527
  function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin) {
5513
- const { tokenValue, tokenStart } = parser;
5528
+ const { tokenValue, tokenStart, currentLocation } = parser;
5514
5529
  const token = parser.getToken();
5515
5530
  let expr = parseIdentifier(parser, context);
5516
5531
  if (parser.getToken() & (143360 | 2097152) &&
5517
5532
  (parser.getToken() & 20480) !== 20480) {
5518
- const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8, 0);
5533
+ const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8);
5519
5534
  matchOrInsertSemicolon(parser, context | 32);
5520
5535
  return parser.finishNode({
5521
5536
  type: 'VariableDeclaration',
@@ -5527,12 +5542,12 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
5527
5542
  if (context & 1)
5528
5543
  parser.report(85);
5529
5544
  if (parser.getToken() === 21) {
5530
- return parseLabelledStatement(parser, context, scope, privateScope, origin, {}, tokenValue, expr, token, 0, tokenStart);
5545
+ return parseLabelledStatement(parser, context, scope, privateScope, {}, tokenValue, expr, token, 0, tokenStart, origin);
5531
5546
  }
5532
5547
  if (parser.getToken() === 10) {
5533
5548
  let scope = void 0;
5534
5549
  if (parser.options.lexical)
5535
- scope = createArrowHeadParsingScope(parser, context, tokenValue);
5550
+ scope = createArrowHeadParsingScope(parser, context, tokenValue, tokenStart, currentLocation);
5536
5551
  parser.flags = (parser.flags | 128) ^ 128;
5537
5552
  expr = parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, tokenStart);
5538
5553
  }
@@ -5581,20 +5596,23 @@ function nextTokenIsUsingOnSameLine(parser) {
5581
5596
  function isResourceBindingStart(token) {
5582
5597
  return (token & 143360) === 143360 && (token & 20480) !== 20480;
5583
5598
  }
5584
- function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5599
+ function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5585
5600
  const { tokenStart, tokenValue } = parser;
5586
5601
  const token = parser.getToken();
5587
5602
  const expression = parseIdentifier(parser, context);
5588
5603
  if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
5589
- if (origin & 4 && context & 8 && (context & 2) === 0) {
5604
+ if (origin & 4 &&
5605
+ context & 8 &&
5606
+ (context & 2) === 0 &&
5607
+ (context & 4096) === 0) {
5590
5608
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5591
5609
  }
5592
5610
  return parseLexicalDeclaration(parser, context, scope, privateScope, 16, origin, 'using', tokenStart, 1);
5593
5611
  }
5594
5612
  parser.assignable = 1;
5595
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 1, expression, token, tokenValue, tokenStart);
5613
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 1, expression, token, tokenValue, tokenStart, origin);
5596
5614
  }
5597
- function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5615
+ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5598
5616
  const start = parser.tokenStart;
5599
5617
  if (context & 524288)
5600
5618
  parser.report(179);
@@ -5618,9 +5636,9 @@ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope,
5618
5636
  type: 'AwaitExpression',
5619
5637
  argument,
5620
5638
  }, start);
5621
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 0, expression, 1048576, '', start);
5639
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 0, expression, 1048576, '', start, origin);
5622
5640
  }
5623
- function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5641
+ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin = 0, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5624
5642
  const start = declarationStart;
5625
5643
  if (!keywordConsumed)
5626
5644
  nextToken(parser, context);
@@ -5632,7 +5650,7 @@ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, ori
5632
5650
  declarations,
5633
5651
  }, start);
5634
5652
  }
5635
- function parseVariableStatement(parser, context, scope, privateScope, origin) {
5653
+ function parseVariableStatement(parser, context, scope, privateScope, origin = 0) {
5636
5654
  const start = parser.tokenStart;
5637
5655
  nextToken(parser, context);
5638
5656
  const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 4, origin);
@@ -5643,7 +5661,7 @@ function parseVariableStatement(parser, context, scope, privateScope, origin) {
5643
5661
  declarations,
5644
5662
  }, start);
5645
5663
  }
5646
- function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin, declarationKind) {
5664
+ function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin = 0, declarationKind) {
5647
5665
  let bindingCount = 1;
5648
5666
  const firstDeclaration = parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind);
5649
5667
  const list = [firstDeclaration];
@@ -5674,11 +5692,14 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
5674
5692
  const id = parseBindingPattern(parser, context, scope, privateScope, kind, origin);
5675
5693
  if (parser.getToken() === 1077936155) {
5676
5694
  nextToken(parser, context | 32);
5677
- init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5695
+ init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart, origin);
5678
5696
  if (origin & 32) {
5679
5697
  if (parser.getToken() === 471156 ||
5680
5698
  (parser.getToken() === 8673330 &&
5681
- (token & 2097152 || (kind & 4) === 0 || context & 1))) {
5699
+ (token & 2097152 ||
5700
+ (kind & 4) === 0 ||
5701
+ context & 1 ||
5702
+ !parser.options.webcompat))) {
5682
5703
  throw new ParseError(tokenStart, parser.currentLocation, 60, parser.getToken() === 471156 ? 'of' : 'in');
5683
5704
  }
5684
5705
  }
@@ -5745,6 +5766,7 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5745
5766
  }
5746
5767
  else if (parser.getToken() === 471156) {
5747
5768
  const ofStart = parser.tokenStart;
5769
+ const ofEnd = parser.currentLocation;
5748
5770
  const ofToken = parser.getToken();
5749
5771
  const ofValue = parser.tokenValue;
5750
5772
  const ofIdentifier = parseIdentifier(parser, context);
@@ -5760,7 +5782,7 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5760
5782
  else {
5761
5783
  resourceDeclarationKind = 'using';
5762
5784
  validateBindingIdentifier(parser, context, 16, ofToken, 0);
5763
- scope?.addBlockName(context, ofValue, 16, 32);
5785
+ scope?.addBlockName(context, ofValue, 16, ofStart, ofEnd, 32);
5764
5786
  let declarationInitializer = null;
5765
5787
  if (parser.getToken() === 1077936155) {
5766
5788
  nextToken(parser, context | 32);
@@ -5951,7 +5973,7 @@ function parseRestrictedIdentifier(parser, context, scope) {
5951
5973
  parser.report(120);
5952
5974
  if ((parser.getToken() & 537079808) === 537079808)
5953
5975
  parser.report(121);
5954
- scope?.addBlockName(context, parser.tokenValue, 8, 0);
5976
+ scope?.addBlockName(context, parser.tokenValue, 8, parser.tokenStart, parser.currentLocation);
5955
5977
  return parseIdentifier(parser, context);
5956
5978
  }
5957
5979
  function parseImportDeclaration(parser, context, scope) {
@@ -5968,7 +5990,7 @@ function parseImportDeclaration(parser, context, scope) {
5968
5990
  else {
5969
5991
  if (parser.getToken() & 143360) {
5970
5992
  const token = parser.getToken();
5971
- const { tokenValue } = parser;
5993
+ const { tokenValue, tokenStart: start, currentLocation } = parser;
5972
5994
  const isPhaseDefer = parser.features & 2 && (token & -2147483648) === 0 && tokenValue == 'defer';
5973
5995
  const isPhaseSource = parser.features & 4 && (token & -2147483648) === 0 && tokenValue == 'source';
5974
5996
  if (isPhaseDefer || isPhaseSource) {
@@ -5979,7 +6001,7 @@ function parseImportDeclaration(parser, context, scope) {
5979
6001
  specifiers = [parseImportNamespaceSpecifier(parser, context, scope)];
5980
6002
  }
5981
6003
  else if (parser.getToken() === 209011 || parser.getToken() === 18) {
5982
- scope?.addBlockName(context, tokenValue, 8, 0);
6004
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
5983
6005
  specifiers = [
5984
6006
  parser.finishNode({
5985
6007
  type: 'ImportDefaultSpecifier',
@@ -5994,10 +6016,11 @@ function parseImportDeclaration(parser, context, scope) {
5994
6016
  else if (parser.getToken() === 209011) {
5995
6017
  const fromToken = parser.getToken();
5996
6018
  const fromStart = parser.tokenStart;
6019
+ const fromEnd = parser.currentLocation;
5997
6020
  const fromLocal = parseIdentifier(parser, context);
5998
6021
  if (parser.getToken() === 209011) {
5999
6022
  validateBindingIdentifier(parser, context, 16, fromToken, 0);
6000
- scope?.addBlockName(context, fromLocal.name, 8, 0);
6023
+ scope?.addBlockName(context, fromLocal.name, 8, fromStart, fromEnd);
6001
6024
  phase = 'source';
6002
6025
  specifiers = [
6003
6026
  parser.finishNode({
@@ -6007,7 +6030,7 @@ function parseImportDeclaration(parser, context, scope) {
6007
6030
  ];
6008
6031
  }
6009
6032
  else {
6010
- scope?.addBlockName(context, tokenValue, 8, 0);
6033
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
6011
6034
  specifiers = [
6012
6035
  parser.finishNode({
6013
6036
  type: 'ImportDefaultSpecifier',
@@ -6032,7 +6055,7 @@ function parseImportDeclaration(parser, context, scope) {
6032
6055
  ];
6033
6056
  }
6034
6057
  else if (parser.getToken() === 18) {
6035
- scope?.addBlockName(context, tokenValue, 8, 0);
6058
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
6036
6059
  specifiers = [
6037
6060
  parser.finishNode({
6038
6061
  type: 'ImportDefaultSpecifier',
@@ -6117,7 +6140,8 @@ function parseModuleSpecifier(parser, context) {
6117
6140
  function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers) {
6118
6141
  nextToken(parser, context);
6119
6142
  while (parser.getToken() & 143360 || parser.getToken() === 134283267) {
6120
- let { tokenValue, tokenStart } = parser;
6143
+ let { tokenValue, tokenStart, currentLocation } = parser;
6144
+ const start = tokenStart;
6121
6145
  const token = parser.getToken();
6122
6146
  const imported = parseModuleExportName(parser, context);
6123
6147
  let local;
@@ -6130,6 +6154,8 @@ function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers)
6130
6154
  validateBindingIdentifier(parser, context, 16, parser.getToken(), 0);
6131
6155
  }
6132
6156
  tokenValue = parser.tokenValue;
6157
+ tokenStart = parser.tokenStart;
6158
+ currentLocation = parser.currentLocation;
6133
6159
  local = parseIdentifier(parser, context);
6134
6160
  }
6135
6161
  else if (imported.type === 'Identifier') {
@@ -6139,12 +6165,12 @@ function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers)
6139
6165
  else {
6140
6166
  parser.report(25, KeywordDescTable[77932 & 255]);
6141
6167
  }
6142
- scope?.addBlockName(context, tokenValue, 8, 0);
6168
+ scope?.addBlockName(context, tokenValue, 8, tokenStart, currentLocation);
6143
6169
  specifiers.push(parser.finishNode({
6144
6170
  type: 'ImportSpecifier',
6145
6171
  local,
6146
6172
  imported,
6147
- }, tokenStart));
6173
+ }, start));
6148
6174
  if (parser.getToken() !== 1074790415)
6149
6175
  consume(parser, context, 18);
6150
6176
  }
@@ -6185,7 +6211,7 @@ function parseExportDeclaration(parser, context, scope) {
6185
6211
  if (isDefaultExport) {
6186
6212
  switch (parser.getToken()) {
6187
6213
  case 86104: {
6188
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 0, parser.tokenStart);
6214
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 0, parser.tokenStart, 4);
6189
6215
  break;
6190
6216
  }
6191
6217
  case 133:
@@ -6201,17 +6227,17 @@ function parseExportDeclaration(parser, context, scope) {
6201
6227
  const { flags } = parser;
6202
6228
  if ((flags & 1) === 0) {
6203
6229
  if (parser.getToken() === 86104) {
6204
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 1, tokenStart);
6230
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 1, tokenStart, 4);
6205
6231
  }
6206
6232
  else {
6207
6233
  if (parser.getToken() === 67174411) {
6208
- declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, 0, flags, tokenStart);
6234
+ declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, flags, tokenStart);
6209
6235
  declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
6210
6236
  declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
6211
6237
  }
6212
6238
  else if (parser.getToken() & 143360) {
6213
6239
  if (scope)
6214
- scope = createArrowHeadParsingScope(parser, context, parser.tokenValue);
6240
+ scope = createArrowHeadParsingScope(parser, context, parser.tokenValue, parser.tokenStart, parser.currentLocation);
6215
6241
  declaration = parseIdentifier(parser, context);
6216
6242
  declaration = parseArrowFunctionExpression(parser, context, scope, undefined, [declaration], 1, tokenStart);
6217
6243
  }
@@ -6322,7 +6348,7 @@ function parseExportDeclaration(parser, context, scope) {
6322
6348
  declaration = parseClassDeclaration(parser, context, scope, undefined, 2);
6323
6349
  break;
6324
6350
  case 86104:
6325
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 0, parser.tokenStart);
6351
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 0, parser.tokenStart, 4);
6326
6352
  break;
6327
6353
  case 241737:
6328
6354
  declaration = parseLexicalDeclaration(parser, context, scope, undefined, 8, 64);
@@ -6337,7 +6363,7 @@ function parseExportDeclaration(parser, context, scope) {
6337
6363
  const { tokenStart } = parser;
6338
6364
  nextToken(parser, context);
6339
6365
  if ((parser.flags & 1) === 0 && parser.getToken() === 86104) {
6340
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 1, tokenStart);
6366
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 1, tokenStart, 4);
6341
6367
  break;
6342
6368
  }
6343
6369
  }
@@ -6353,8 +6379,8 @@ function parseExportDeclaration(parser, context, scope) {
6353
6379
  };
6354
6380
  return parser.finishNode(node, start);
6355
6381
  }
6356
- function parseExpression(parser, context, privateScope, canAssign, inGroup, start) {
6357
- let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start);
6382
+ function parseExpression(parser, context, privateScope, canAssign, inGroup, start, origin = 0) {
6383
+ let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start, origin);
6358
6384
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGroup, 0, start);
6359
6385
  return parseAssignmentExpression(parser, context, privateScope, inGroup, 0, start, expr);
6360
6386
  }
@@ -6509,7 +6535,7 @@ function parseAsyncExpression(parser, context, privateScope, inGroup, isLHS, can
6509
6535
  }
6510
6536
  }
6511
6537
  if (!inNew && parser.getToken() === 67174411) {
6512
- return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, 0, flags, start);
6538
+ return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, flags, start);
6513
6539
  }
6514
6540
  if (parser.getToken() === 10) {
6515
6541
  classifyIdentifier(parser, context, token);
@@ -6557,8 +6583,12 @@ function parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup
6557
6583
  return parseIdentifierOrArrow(parser, context, privateScope);
6558
6584
  }
6559
6585
  function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, start) {
6560
- if (inGroup)
6586
+ if (inGroup) {
6587
+ if ((parser.destructible & 128) === 0) {
6588
+ parser.firstAwaitLocation ??= { start, end: parser.currentLocation };
6589
+ }
6561
6590
  parser.destructible |= 128;
6591
+ }
6562
6592
  if (context & 524288)
6563
6593
  parser.report(179);
6564
6594
  const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope);
@@ -6592,7 +6622,7 @@ function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew,
6592
6622
  throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 98);
6593
6623
  return possibleIdentifierOrArrowFunc;
6594
6624
  }
6595
- function parseFunctionBody(parser, context, scope, privateScope, origin, funcNameToken, functionScope) {
6625
+ function parseFunctionBody(parser, context, scope, privateScope, funcNameToken, functionScope, origin = 0) {
6596
6626
  const { tokenStart } = parser;
6597
6627
  parser.flags &= -4161;
6598
6628
  consume(parser, context | 32, 2162700);
@@ -6641,7 +6671,7 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
6641
6671
  (512 | 256 | 64 | 4096);
6642
6672
  parser.destructible = (parser.destructible | 256) ^ 256;
6643
6673
  while (parser.getToken() !== 1074790415) {
6644
- body.push(parseStatementListItem(parser, context, scope, privateScope, 4, {}));
6674
+ body.push(parseStatementListItem(parser, context, scope, privateScope, {}, 4));
6645
6675
  }
6646
6676
  consume(parser, origin & (16 | 8) ? context | 32 : context, 1074790415);
6647
6677
  parser.flags &= -4289;
@@ -6890,7 +6920,7 @@ function parseUpdateExpressionPrefixed(parser, context, privateScope, inNew, isL
6890
6920
  prefix: true,
6891
6921
  }, start);
6892
6922
  }
6893
- function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start) {
6923
+ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start, origin = 0) {
6894
6924
  if ((parser.getToken() & 143360) === 143360) {
6895
6925
  switch (parser.getToken()) {
6896
6926
  case 209006:
@@ -6910,7 +6940,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6910
6940
  if ((token & 36864) === 36864) {
6911
6941
  parser.flags |= 256;
6912
6942
  }
6913
- return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start);
6943
+ return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start, origin);
6914
6944
  }
6915
6945
  if (context & 16 &&
6916
6946
  !(context & 32768) &&
@@ -6951,7 +6981,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6951
6981
  case 69271571:
6952
6982
  return parseArrayLiteral(parser, context, privateScope, canAssign ? 0 : 1, inGroup);
6953
6983
  case 67174411:
6954
- return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, 0, start);
6984
+ return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, start, origin);
6955
6985
  case 86021:
6956
6986
  case 86022:
6957
6987
  case 86023:
@@ -7280,7 +7310,7 @@ function parseThisExpression(parser, context) {
7280
7310
  type: 'ThisExpression',
7281
7311
  }, tokenStart);
7282
7312
  }
7283
- function parseFunctionDeclaration(parser, context, scope, privateScope, origin, allowGen, flags, isAsync, start) {
7313
+ function parseFunctionDeclaration(parser, context, scope, privateScope, allowGen, flags, isAsync, start, origin = 0) {
7284
7314
  nextToken(parser, context | 32);
7285
7315
  const isGenerator = allowGen ? optionalBit(parser, context, 8391476) : 0;
7286
7316
  let id = null;
@@ -7296,12 +7326,7 @@ function parseFunctionDeclaration(parser, context, scope, privateScope, origin,
7296
7326
  : 64 | (isAsync ? 1024 : 0) | (isGenerator ? 1024 : 0);
7297
7327
  validateFunctionName(parser, context, parser.getToken());
7298
7328
  if (scope) {
7299
- if (kind & 4) {
7300
- scope.addVarName(context, parser.tokenValue, kind);
7301
- }
7302
- else {
7303
- scope.addBlockName(context, parser.tokenValue, kind, origin);
7304
- }
7329
+ scope.addVarOrBlock(context, parser.tokenValue, kind, parser.tokenStart, parser.currentLocation, origin);
7305
7330
  functionScope = functionScope?.createChildScope(128);
7306
7331
  if (flags) {
7307
7332
  if (flags & 2) {
@@ -7334,7 +7359,7 @@ function parseFunctionDeclaration(parser, context, scope, privateScope, origin,
7334
7359
  functionScope = functionScope?.createChildScope(256);
7335
7360
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, functionScope, privateScope, 0, 1);
7336
7361
  const modifierFlags = 8 | 4 | 128 | 524288;
7337
- const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, 8, funcNameToken, functionScope);
7362
+ const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, funcNameToken, functionScope, 8);
7338
7363
  return parser.finishNode({
7339
7364
  type: 'FunctionDeclaration',
7340
7365
  id,
@@ -7373,7 +7398,7 @@ function parseFunctionExpression(parser, context, privateScope, isAsync, inGroup
7373
7398
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, scope, privateScope, inGroup, 1);
7374
7399
  const body = parseFunctionBody(parser, (context & -131229) |
7375
7400
  32768 |
7376
- 4096, scope?.createChildScope(64), privateScope, 0, funcNameToken, scope);
7401
+ 4096, scope?.createChildScope(64), privateScope, funcNameToken, scope);
7377
7402
  parser.assignable = 2;
7378
7403
  return parser.finishNode({
7379
7404
  type: 'FunctionExpression',
@@ -7385,7 +7410,7 @@ function parseFunctionExpression(parser, context, privateScope, isAsync, inGroup
7385
7410
  }, start);
7386
7411
  }
7387
7412
  function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7388
- const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7413
+ const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7389
7414
  if (parser.destructible & 64) {
7390
7415
  parser.report(63);
7391
7416
  }
@@ -7394,7 +7419,7 @@ function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGro
7394
7419
  }
7395
7420
  return expr;
7396
7421
  }
7397
- function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7422
+ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7398
7423
  const { tokenStart: start } = parser;
7399
7424
  nextToken(parser, context | 32);
7400
7425
  const elements = [];
@@ -7406,7 +7431,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7406
7431
  }
7407
7432
  else {
7408
7433
  let left;
7409
- const { tokenStart, tokenValue } = parser;
7434
+ const { tokenStart, tokenValue, currentLocation } = parser;
7410
7435
  const token = parser.getToken();
7411
7436
  if (token & 143360) {
7412
7437
  left = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
@@ -7414,7 +7439,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7414
7439
  if (parser.assignable & 2)
7415
7440
  parser.report(26);
7416
7441
  nextToken(parser, context | 32);
7417
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7442
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7418
7443
  const right = parseExpression(parser, context, privateScope, 1, inGroup, parser.tokenStart);
7419
7444
  left = parser.finishNode(isPattern
7420
7445
  ? {
@@ -7440,7 +7465,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7440
7465
  destructible |= 16;
7441
7466
  }
7442
7467
  else {
7443
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7468
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7444
7469
  }
7445
7470
  destructible |=
7446
7471
  parser.destructible & 256
@@ -7503,7 +7528,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7503
7528
  }
7504
7529
  }
7505
7530
  else if (token === 14) {
7506
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, origin, 0, inGroup, isPattern);
7531
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, 0, inGroup, isPattern, origin);
7507
7532
  destructible |= parser.destructible;
7508
7533
  if (parser.getToken() !== 18 && parser.getToken() !== 20)
7509
7534
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
@@ -7573,12 +7598,12 @@ function parseArrayOrObjectAssignmentPattern(parser, context, privateScope, dest
7573
7598
  right,
7574
7599
  }, start);
7575
7600
  }
7576
- function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, origin, isAsync, inGroup, isPattern) {
7601
+ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, isAsync, inGroup, isPattern, origin = 0) {
7577
7602
  const { tokenStart: start } = parser;
7578
7603
  nextToken(parser, context | 32);
7579
7604
  let argument = null;
7580
7605
  let destructible = 0;
7581
- const { tokenValue, tokenStart } = parser;
7606
+ const { tokenValue, tokenStart, currentLocation } = parser;
7582
7607
  let token = parser.getToken();
7583
7608
  if (token & 143360) {
7584
7609
  parser.assignable = 1;
@@ -7595,7 +7620,7 @@ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingT
7595
7620
  destructible |= 16;
7596
7621
  }
7597
7622
  else if (token === closingToken || token === 18) {
7598
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7623
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7599
7624
  }
7600
7625
  else {
7601
7626
  destructible |= 32;
@@ -7722,7 +7747,7 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
7722
7747
  scope = scope?.createChildScope(64);
7723
7748
  const body = parseFunctionBody(parser, (context & -655373) |
7724
7749
  32768 |
7725
- 4096, scope, privateScope, 0, void 0, scope?.parent);
7750
+ 4096, scope, privateScope, void 0, scope?.parent);
7726
7751
  return parser.finishNode({
7727
7752
  type: 'FunctionExpression',
7728
7753
  params,
@@ -7733,7 +7758,7 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
7733
7758
  }, start);
7734
7759
  }
7735
7760
  function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7736
- const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7761
+ const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7737
7762
  if (parser.destructible & 64) {
7738
7763
  parser.report(63);
7739
7764
  }
@@ -7742,7 +7767,7 @@ function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGr
7742
7767
  }
7743
7768
  return expr;
7744
7769
  }
7745
- function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7770
+ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7746
7771
  const { tokenStart: start } = parser;
7747
7772
  nextToken(parser, context);
7748
7773
  const properties = [];
@@ -7750,10 +7775,10 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7750
7775
  let prototypeCount = 0;
7751
7776
  context = (context | 131072) ^ 131072;
7752
7777
  while (parser.getToken() !== 1074790415) {
7753
- const { tokenValue, tokenStart } = parser;
7778
+ const { tokenValue, tokenStart, currentLocation } = parser;
7754
7779
  const token = parser.getToken();
7755
7780
  if (token === 14) {
7756
- properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, origin, 0, inGroup, isPattern));
7781
+ properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, 0, inGroup, isPattern, origin));
7757
7782
  }
7758
7783
  else {
7759
7784
  let state = 0;
@@ -7775,7 +7800,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7775
7800
  else {
7776
7801
  validateBindingIdentifier(parser, context, kind, token, 0);
7777
7802
  }
7778
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7803
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7779
7804
  if (consumeOpt(parser, context | 32, 1077936155)) {
7780
7805
  destructible |= 8;
7781
7806
  const right = parseExpression(parser, context, privateScope, 1, inGroup, parser.tokenStart);
@@ -7799,7 +7824,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7799
7824
  }
7800
7825
  }
7801
7826
  else if (consumeOpt(parser, context | 32, 21)) {
7802
- const { tokenStart } = parser;
7827
+ const { tokenStart, currentLocation } = parser;
7803
7828
  if (tokenValue === '__proto__')
7804
7829
  prototypeCount++;
7805
7830
  if (parser.getToken() & 143360) {
@@ -7815,7 +7840,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7815
7840
  destructible |= 16;
7816
7841
  }
7817
7842
  else if ((tokenAfterColon & 143360) === 143360) {
7818
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
7843
+ scope?.addVarOrBlock(context, valueAfterColon, kind, tokenStart, currentLocation, origin);
7819
7844
  }
7820
7845
  }
7821
7846
  else {
@@ -7833,7 +7858,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7833
7858
  destructible |= 32;
7834
7859
  }
7835
7860
  else {
7836
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
7861
+ scope?.addVarOrBlock(context, valueAfterColon, kind, tokenStart, currentLocation, origin);
7837
7862
  }
7838
7863
  value = parseAssignmentExpression(parser, context, privateScope, inGroup, isPattern, tokenStart, value);
7839
7864
  }
@@ -8001,7 +8026,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
8001
8026
  prototypeCount++;
8002
8027
  if (parser.getToken() & 143360) {
8003
8028
  value = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
8004
- const { tokenValue: valueAfterColon } = parser;
8029
+ const { tokenValue: valueAfterColon, tokenStart: start, currentLocation } = parser;
8005
8030
  const token = parser.getToken();
8006
8031
  value = parseMemberOrUpdateExpression(parser, context, privateScope, value, inGroup, 0, tokenStart);
8007
8032
  if (parser.getToken() === 18 || parser.getToken() === 1074790415) {
@@ -8010,7 +8035,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
8010
8035
  destructible |= 16;
8011
8036
  }
8012
8037
  else {
8013
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
8038
+ scope?.addVarOrBlock(context, valueAfterColon, kind, start, currentLocation, origin);
8014
8039
  }
8015
8040
  }
8016
8041
  else {
@@ -8102,7 +8127,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
8102
8127
  state |= 2;
8103
8128
  if (parser.getToken() === 21) {
8104
8129
  nextToken(parser, context | 32);
8105
- const { tokenStart, tokenValue } = parser;
8130
+ const { tokenStart, tokenValue, currentLocation } = parser;
8106
8131
  const tokenAfterColon = parser.getToken();
8107
8132
  if (parser.getToken() & 143360) {
8108
8133
  value = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
@@ -8123,7 +8148,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
8123
8148
  destructible |= 16;
8124
8149
  }
8125
8150
  else if ((tokenAfterColon & 143360) === 143360) {
8126
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
8151
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
8127
8152
  }
8128
8153
  }
8129
8154
  else {
@@ -8281,6 +8306,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
8281
8306
  const params = [];
8282
8307
  parser.flags = (parser.flags | 128) ^ 128;
8283
8308
  parser.strictReservedRange = null;
8309
+ parser.firstAwaitLocation = null;
8284
8310
  if (parser.getToken() === 16) {
8285
8311
  if (kind & 512) {
8286
8312
  parser.report(37, 'Setter', 'one', '');
@@ -8310,17 +8336,17 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
8310
8336
  parser.flags |= 512;
8311
8337
  }
8312
8338
  }
8313
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8339
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8314
8340
  }
8315
8341
  else {
8316
8342
  if (parser.getToken() === 2162700) {
8317
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8343
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8318
8344
  }
8319
8345
  else if (parser.getToken() === 69271571) {
8320
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8346
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8321
8347
  }
8322
8348
  else if (parser.getToken() === 14) {
8323
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, 0, inGroup, 1);
8349
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, inGroup, 1);
8324
8350
  }
8325
8351
  isNonSimpleParameterList = 1;
8326
8352
  if (parser.destructible & (32 | 16))
@@ -8359,17 +8385,20 @@ function parseComputedPropertyName(parser, context, privateScope, inGroup) {
8359
8385
  consume(parser, context, 20);
8360
8386
  return key;
8361
8387
  }
8362
- function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, origin, start) {
8388
+ function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, start, origin) {
8363
8389
  parser.flags = (parser.flags | 128) ^ 128;
8364
8390
  const parenthesesStart = parser.tokenStart;
8365
8391
  nextToken(parser, context | 32 | 262144);
8366
8392
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8367
8393
  context = (context | 131072) ^ 131072;
8368
8394
  if (consumeOpt(parser, context, 16)) {
8369
- return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start);
8395
+ return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start, origin);
8370
8396
  }
8371
8397
  let destructible = 0;
8398
+ const previousAwaitYield = parser.destructible & (256 | 128);
8372
8399
  parser.destructible &= -385;
8400
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8401
+ parser.firstAwaitLocation = null;
8373
8402
  let expr;
8374
8403
  let expressions = [];
8375
8404
  let isSequence = 0;
@@ -8378,17 +8407,17 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8378
8407
  const tokenAfterParenthesesStart = parser.tokenStart;
8379
8408
  parser.assignable = 1;
8380
8409
  while (parser.getToken() !== 16) {
8381
- const { tokenStart } = parser;
8410
+ const { tokenStart, currentLocation } = parser;
8382
8411
  const token = parser.getToken();
8383
8412
  if (token & 143360) {
8384
- scope?.addBlockName(context, parser.tokenValue, 1, 0);
8413
+ scope?.addBlockName(context, parser.tokenValue, 1, tokenStart, currentLocation);
8385
8414
  if ((token & 537079808) === 537079808) {
8386
8415
  isNonSimpleParameterList = 1;
8387
8416
  }
8388
8417
  else if ((token & 36864) === 36864) {
8389
8418
  hasStrictReserved = 1;
8390
8419
  }
8391
- expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart);
8420
+ expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart, 0);
8392
8421
  if (parser.getToken() === 16 || parser.getToken() === 18) {
8393
8422
  if (parser.assignable & 2) {
8394
8423
  destructible |= 16;
@@ -8411,8 +8440,8 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8411
8440
  else if ((token & 2097152) === 2097152) {
8412
8441
  expr =
8413
8442
  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);
8443
+ ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind)
8444
+ : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind);
8416
8445
  destructible |= parser.destructible;
8417
8446
  isNonSimpleParameterList = 1;
8418
8447
  parser.assignable = 2;
@@ -8427,7 +8456,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8427
8456
  }
8428
8457
  }
8429
8458
  else if (token === 14) {
8430
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 0, 1, 0);
8459
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 1, 0);
8431
8460
  if (parser.destructible & 16)
8432
8461
  parser.report(74);
8433
8462
  isNonSimpleParameterList = 1;
@@ -8460,7 +8489,10 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8460
8489
  }, tokenAfterParenthesesStart);
8461
8490
  }
8462
8491
  consume(parser, context, 16);
8463
- parser.destructible = destructible;
8492
+ parser.destructible = destructible | previousAwaitYield;
8493
+ if (previousFirstAwaitLocation) {
8494
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8495
+ }
8464
8496
  return parser.options.preserveParens
8465
8497
  ? parser.finishNode({
8466
8498
  type: 'ParenthesizedExpression',
@@ -8501,8 +8533,12 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8501
8533
  if (parser.getToken() === 10) {
8502
8534
  if (destructible & (32 | 16))
8503
8535
  parser.report(49);
8504
- if (context & (2048 | 2) && destructible & 128)
8536
+ if (context & (2048 | 2) && destructible & 128) {
8537
+ const loc = parser.firstAwaitLocation;
8538
+ if (loc)
8539
+ throw new ParseError(loc.start, loc.end, 31);
8505
8540
  parser.report(31);
8541
+ }
8506
8542
  if (context & (1 | 1024) && destructible & 256) {
8507
8543
  parser.report(32);
8508
8544
  }
@@ -8510,7 +8546,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8510
8546
  parser.flags |= 128;
8511
8547
  if (hasStrictReserved)
8512
8548
  parser.flags |= 256;
8513
- return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start);
8549
+ return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start, origin);
8514
8550
  }
8515
8551
  if (destructible & 64) {
8516
8552
  parser.report(63);
@@ -8518,7 +8554,11 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8518
8554
  if (destructible & 8) {
8519
8555
  parser.report(146);
8520
8556
  }
8521
- parser.destructible = ((parser.destructible | 256) ^ 256) | destructible;
8557
+ parser.destructible =
8558
+ ((parser.destructible | 256) ^ 256) | destructible | previousAwaitYield;
8559
+ if (previousFirstAwaitLocation) {
8560
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8561
+ }
8522
8562
  return parser.options.preserveParens
8523
8563
  ? parser.finishNode({
8524
8564
  type: 'ParenthesizedExpression',
@@ -8527,8 +8567,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8527
8567
  : expr;
8528
8568
  }
8529
8569
  function parseIdentifierOrArrow(parser, context, privateScope) {
8530
- const { tokenStart: start } = parser;
8531
- const { tokenValue } = parser;
8570
+ const { tokenValue, tokenStart, currentLocation } = parser;
8532
8571
  let isNonSimpleParameterList = 0;
8533
8572
  let hasStrictReserved = 0;
8534
8573
  if ((parser.getToken() & 537079808) === 537079808) {
@@ -8540,32 +8579,36 @@ function parseIdentifierOrArrow(parser, context, privateScope) {
8540
8579
  const expr = parseIdentifier(parser, context);
8541
8580
  parser.assignable = 1;
8542
8581
  if (parser.getToken() === 10) {
8543
- const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, tokenValue) : undefined;
8582
+ const scope = parser.options.lexical
8583
+ ? createArrowHeadParsingScope(parser, context, tokenValue, tokenStart, currentLocation)
8584
+ : undefined;
8544
8585
  if (isNonSimpleParameterList)
8545
8586
  parser.flags |= 128;
8546
8587
  if (hasStrictReserved)
8547
8588
  parser.flags |= 256;
8548
- return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, start);
8589
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, tokenStart);
8549
8590
  }
8550
8591
  return expr;
8551
8592
  }
8552
- function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start) {
8593
+ function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start, origin = 0) {
8553
8594
  if (!canAssign)
8554
8595
  parser.report(57);
8555
8596
  if (inNew)
8556
8597
  parser.report(51);
8557
8598
  parser.flags &= -129;
8558
- const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, value) : void 0;
8559
- return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start);
8599
+ const scope = parser.options.lexical
8600
+ ? createArrowHeadParsingScope(parser, context, value, start, parser.currentLocation)
8601
+ : void 0;
8602
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start, origin);
8560
8603
  }
8561
- function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start) {
8604
+ function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start, origin = 0) {
8562
8605
  if (!canAssign)
8563
8606
  parser.report(57);
8564
8607
  for (let i = 0; i < params.length; ++i)
8565
8608
  reinterpretToPattern(parser, params[i]);
8566
- return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start);
8609
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin);
8567
8610
  }
8568
- function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start) {
8611
+ function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin = 0) {
8569
8612
  if (parser.flags & 1)
8570
8613
  parser.report(48);
8571
8614
  consume(parser, context | 32, 10);
@@ -8583,7 +8626,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8583
8626
  else {
8584
8627
  scope = scope?.createChildScope(64);
8585
8628
  const modifierFlags = 4 | 131072 | 8;
8586
- 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);
8587
8630
  switch (parser.getToken()) {
8588
8631
  case 69271571:
8589
8632
  if ((parser.flags & 1) === 0) {
@@ -8602,8 +8645,11 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8602
8645
  parser.flags |= 1024;
8603
8646
  break;
8604
8647
  }
8605
- if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0)
8606
- 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
+ }
8607
8653
  if ((parser.getToken() & 33619968) === 33619968)
8608
8654
  parser.report(127);
8609
8655
  }
@@ -8621,6 +8667,7 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
8621
8667
  consume(parser, context, 67174411);
8622
8668
  parser.flags = (parser.flags | 128) ^ 128;
8623
8669
  parser.strictReservedRange = null;
8670
+ parser.firstAwaitLocation = null;
8624
8671
  const params = [];
8625
8672
  if (consumeOpt(parser, context, 16))
8626
8673
  return params;
@@ -8640,17 +8687,17 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
8640
8687
  parser.flags |= 512;
8641
8688
  }
8642
8689
  }
8643
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8690
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8644
8691
  }
8645
8692
  else {
8646
8693
  if (token === 2162700) {
8647
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8694
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8648
8695
  }
8649
8696
  else if (token === 69271571) {
8650
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8697
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8651
8698
  }
8652
8699
  else if (token === 14) {
8653
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 0, inGroup, 1);
8700
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, inGroup, 1);
8654
8701
  }
8655
8702
  else {
8656
8703
  parser.report(30, KeywordDescTable[token & 255]);
@@ -8774,9 +8821,11 @@ function parseAsyncArrowAfterIdent(parser, context, privateScope, canAssign, sta
8774
8821
  }
8775
8822
  return parseArrowFromIdentifier(parser, (context & -524289) | 2048, privateScope, parser.tokenValue, parseIdentifier(parser, context), 0, canAssign, 1, start);
8776
8823
  }
8777
- function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, origin, flags, start) {
8824
+ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, flags, start) {
8778
8825
  nextToken(parser, context | 32);
8779
8826
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8827
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8828
+ parser.firstAwaitLocation = null;
8780
8829
  context = (context | 131072) ^ 131072;
8781
8830
  if (consumeOpt(parser, context, 16)) {
8782
8831
  if (parser.getToken() === 10) {
@@ -8790,6 +8839,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8790
8839
  else {
8791
8840
  parser.assignable = 2;
8792
8841
  }
8842
+ if (previousFirstAwaitLocation)
8843
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8793
8844
  return parser.finishNode({
8794
8845
  type: 'CallExpression',
8795
8846
  callee,
@@ -8805,10 +8856,10 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8805
8856
  (256 | 128);
8806
8857
  const params = [];
8807
8858
  while (parser.getToken() !== 16) {
8808
- const { tokenStart } = parser;
8859
+ const { tokenStart, currentLocation } = parser;
8809
8860
  const token = parser.getToken();
8810
8861
  if (token & 143360) {
8811
- scope?.addBlockName(context, parser.tokenValue, kind, 0);
8862
+ scope?.addBlockName(context, parser.tokenValue, kind, tokenStart, currentLocation);
8812
8863
  if ((token & 537079808) === 537079808) {
8813
8864
  parser.flags |= 512;
8814
8865
  }
@@ -8838,8 +8889,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8838
8889
  else if (token & 2097152) {
8839
8890
  expr =
8840
8891
  token === 2162700
8841
- ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin)
8842
- : 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);
8843
8894
  destructible |= parser.destructible;
8844
8895
  isNonSimpleParameterList = 1;
8845
8896
  if (parser.getToken() !== 16 && parser.getToken() !== 18) {
@@ -8856,7 +8907,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8856
8907
  }
8857
8908
  }
8858
8909
  else if (token === 14) {
8859
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 1, 1, 0);
8910
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 1, 1, 0);
8860
8911
  destructible |=
8861
8912
  (parser.getToken() === 16 ? 0 : 16) | parser.destructible;
8862
8913
  isNonSimpleParameterList = 1;
@@ -8877,6 +8928,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8877
8928
  else {
8878
8929
  parser.assignable = 2;
8879
8930
  }
8931
+ if (previousFirstAwaitLocation)
8932
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8880
8933
  return parser.finishNode({
8881
8934
  type: 'CallExpression',
8882
8935
  callee,
@@ -8900,8 +8953,12 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8900
8953
  parser.report(27);
8901
8954
  if (parser.flags & 1 || flags & 1)
8902
8955
  parser.report(48);
8903
- if (destructible & 128)
8956
+ if (destructible & 128) {
8957
+ const loc = parser.firstAwaitLocation;
8958
+ if (loc)
8959
+ throw new ParseError(loc.start, loc.end, 31);
8904
8960
  parser.report(31);
8961
+ }
8905
8962
  if (context & (1 | 1024) && destructible & 256)
8906
8963
  parser.report(32);
8907
8964
  if (isNonSimpleParameterList)
@@ -8920,6 +8977,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8920
8977
  else {
8921
8978
  parser.assignable = 2;
8922
8979
  }
8980
+ if (previousFirstAwaitLocation)
8981
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8923
8982
  return parser.finishNode({
8924
8983
  type: 'CallExpression',
8925
8984
  callee,
@@ -8957,7 +9016,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8957
9016
  consume(parser, context, 86094);
8958
9017
  let id = null;
8959
9018
  let superClass = null;
8960
- const { tokenValue } = parser;
9019
+ const { tokenValue, tokenStart, currentLocation } = parser;
8961
9020
  if (parser.getToken() & 4096 && parser.getToken() !== 20565) {
8962
9021
  if (isStrictReservedWord(parser, context, parser.getToken())) {
8963
9022
  parser.report(120);
@@ -8966,7 +9025,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8966
9025
  parser.report(121);
8967
9026
  }
8968
9027
  if (scope) {
8969
- scope.addBlockName(context, tokenValue, 32, 0);
9028
+ scope.addBlockName(context, tokenValue, 32, tokenStart, currentLocation);
8970
9029
  if (flags) {
8971
9030
  if (flags & 2) {
8972
9031
  parser.declareUnboundVariable(tokenValue);
@@ -8987,7 +9046,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8987
9046
  else {
8988
9047
  inheritedContext = (inheritedContext | 512) ^ 512;
8989
9048
  }
8990
- const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 8, 0);
9049
+ const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 0, 8);
8991
9050
  return parser.finishNode({
8992
9051
  type: 'ClassDeclaration',
8993
9052
  id,
@@ -9018,7 +9077,7 @@ function parseClassExpression(parser, context, privateScope, inGroup, start) {
9018
9077
  else {
9019
9078
  inheritedContext = (inheritedContext | 512) ^ 512;
9020
9079
  }
9021
- const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, 0, inGroup);
9080
+ const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, inGroup);
9022
9081
  parser.assignable = 2;
9023
9082
  return parser.finishNode({
9024
9083
  type: 'ClassExpression',
@@ -9085,7 +9144,7 @@ function parseDecorator(parser, context, privateScope) {
9085
9144
  expression,
9086
9145
  }, start);
9087
9146
  }
9088
- function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, origin, inGroup) {
9147
+ function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, inGroup, origin = 0) {
9089
9148
  const { tokenStart } = parser;
9090
9149
  const privateScope = parser.createPrivateScopeIfLexical(parentScope);
9091
9150
  consume(parser, context | 32, 2162700);
@@ -9325,22 +9384,22 @@ function parsePropertyDefinition(parser, context, privateScope, key, state, deco
9325
9384
  ...(parser.features & 1 ? { decorators } : null),
9326
9385
  }, start);
9327
9386
  }
9328
- function parseBindingPattern(parser, context, scope, privateScope, type, origin) {
9387
+ function parseBindingPattern(parser, context, scope, privateScope, kind, origin = 0) {
9329
9388
  if (parser.getToken() & 143360 ||
9330
9389
  ((context & 1) === 0 && parser.getToken() === -2147483526))
9331
- return parseAndClassifyIdentifier(parser, context, scope, type, origin);
9390
+ return parseAndClassifyIdentifier(parser, context, scope, kind, origin);
9332
9391
  if ((parser.getToken() & 2097152) !== 2097152)
9333
9392
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
9334
9393
  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);
9394
+ ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin)
9395
+ : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin);
9337
9396
  if (parser.destructible & 16)
9338
9397
  parser.report(50);
9339
9398
  if (parser.destructible & 32)
9340
9399
  parser.report(50);
9341
9400
  return left;
9342
9401
  }
9343
- function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
9402
+ function parseAndClassifyIdentifier(parser, context, scope, kind, origin = 0) {
9344
9403
  const token = parser.getToken();
9345
9404
  if (context & 1) {
9346
9405
  if ((token & 537079808) === 537079808) {
@@ -9369,13 +9428,13 @@ function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
9369
9428
  if (context & 2)
9370
9429
  parser.report(112);
9371
9430
  }
9372
- const { tokenValue, tokenStart: start } = parser;
9431
+ const { tokenValue, tokenStart, currentLocation } = parser;
9373
9432
  nextToken(parser, context);
9374
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
9433
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
9375
9434
  return parser.finishNode({
9376
9435
  type: 'Identifier',
9377
9436
  name: tokenValue,
9378
- }, start);
9437
+ }, tokenStart);
9379
9438
  }
9380
9439
  function parseJSXRootElementOrFragment(parser, context, privateScope, inJSXChild, start) {
9381
9440
  if (!inJSXChild)
@@ -9468,7 +9527,7 @@ function parseJSXChildrenAndClosingFragment(parser, context, privateScope, inJSX
9468
9527
  }
9469
9528
  function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild) {
9470
9529
  if (parser.getToken() === 138)
9471
- return parseJSXText(parser, context);
9530
+ return parseJSXText(parser);
9472
9531
  if (parser.getToken() === 2162700)
9473
9532
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9474
9533
  if (parser.getToken() === 8456256) {
@@ -9482,7 +9541,7 @@ function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild
9482
9541
  }
9483
9542
  function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChild) {
9484
9543
  if (parser.getToken() === 138)
9485
- return parseJSXText(parser, context);
9544
+ return parseJSXText(parser);
9486
9545
  if (parser.getToken() === 2162700)
9487
9546
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9488
9547
  if (parser.getToken() === 8456256) {
@@ -9494,9 +9553,9 @@ function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChil
9494
9553
  }
9495
9554
  parser.report(0);
9496
9555
  }
9497
- function parseJSXText(parser, context) {
9556
+ function parseJSXText(parser) {
9498
9557
  const start = parser.tokenStart;
9499
- nextToken(parser, context);
9558
+ nextJSXToken(parser);
9500
9559
  const node = {
9501
9560
  type: 'JSXText',
9502
9561
  value: parser.tokenValue,
@@ -9514,7 +9573,7 @@ function parseJSXOpeningElementOrSelfCloseElement(parser, context, privateScope,
9514
9573
  const attributes = parseJSXAttributes(parser, context, privateScope);
9515
9574
  const selfClosing = parser.getToken() === 8457014;
9516
9575
  if (selfClosing)
9517
- consume(parser, context, 8457014);
9576
+ consume(parser, context | 1048576, 8457014);
9518
9577
  if (parser.getToken() !== 8390721) {
9519
9578
  parser.report(25, KeywordDescTable[8390721 & 255]);
9520
9579
  }
@@ -9665,7 +9724,7 @@ function parseJSXIdentifier(parser, context) {
9665
9724
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
9666
9725
  }
9667
9726
  const { tokenValue } = parser;
9668
- nextToken(parser, context);
9727
+ nextToken(parser, context | 1048576);
9669
9728
  return parser.finishNode({
9670
9729
  type: 'JSXIdentifier',
9671
9730
  name: tokenValue,