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.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version$1 = "7.3.0";
3
+ var version$1 = "7.3.2";
4
4
  var packageJson = {
5
5
  version: version$1};
6
6
 
@@ -93,7 +93,7 @@ const CharTypes = [
93
93
  0,
94
94
  16384,
95
95
  0,
96
- 0,
96
+ 16384,
97
97
  0,
98
98
  0,
99
99
  1 | 2 | 64,
@@ -156,7 +156,7 @@ const CharTypes = [
156
156
  1 | 2 | 4,
157
157
  16384,
158
158
  0,
159
- 0,
159
+ 16384,
160
160
  0,
161
161
  0
162
162
  ];
@@ -790,6 +790,8 @@ const errorMessages = {
790
790
  [177]: "'import.meta' must not contain escaped characters",
791
791
  [178]: 'cannot use "await" as identifier inside an async function',
792
792
  [179]: 'cannot use "await" in static blocks',
793
+ [180]: "Unexpected token `}`. Did you mean `}` or `{'}'}`?",
794
+ [181]: "Unexpected token `>`. Did you mean `>` or `{'>'}`?",
793
795
  };
794
796
  class ParseError extends SyntaxError {
795
797
  start;
@@ -2040,6 +2042,9 @@ function scanSingleToken(parser, context, state) {
2040
2042
  }
2041
2043
  case 8390721: {
2042
2044
  advanceChar(parser);
2045
+ if (context & 1048576) {
2046
+ return 8390721;
2047
+ }
2043
2048
  const ch = parser.currentChar;
2044
2049
  if (ch === 61) {
2045
2050
  advanceChar(parser);
@@ -2247,6 +2252,9 @@ function isStrictReservedWord(parser, context, t) {
2247
2252
  if (t === 209006) {
2248
2253
  if (context & (2048 | 2))
2249
2254
  parser.report(112);
2255
+ if ((parser.destructible & 128) === 0) {
2256
+ parser.firstAwaitLocation ??= { start: parser.tokenStart, end: parser.currentLocation };
2257
+ }
2250
2258
  parser.destructible |= 128;
2251
2259
  }
2252
2260
  if (t === 241771 && context & 1024)
@@ -4528,6 +4536,12 @@ function nextJSXToken(parser) {
4528
4536
  parser.setToken(2162700);
4529
4537
  return;
4530
4538
  }
4539
+ if (parser.currentChar === 125) {
4540
+ parser.report(180);
4541
+ }
4542
+ if (parser.currentChar === 62) {
4543
+ parser.report(181);
4544
+ }
4531
4545
  let state = 0;
4532
4546
  while (parser.index < parser.end) {
4533
4547
  const type = CharTypes[parser.source.charCodeAt(parser.index)];
@@ -4554,7 +4568,7 @@ function nextJSXToken(parser) {
4554
4568
  parser.setToken(138);
4555
4569
  }
4556
4570
  function rescanJSXIdentifier(parser) {
4557
- if ((parser.getToken() & 143360) === 143360) {
4571
+ if (parser.getToken() & 143360) {
4558
4572
  const { index } = parser;
4559
4573
  let char = parser.currentChar;
4560
4574
  while (CharTypes[char] & (32768 | 2)) {
@@ -4659,18 +4673,18 @@ class Scope {
4659
4673
  createChildScope(type) {
4660
4674
  return new Scope(this.parser, type, this);
4661
4675
  }
4662
- addVarOrBlock(context, name, kind, origin) {
4676
+ addVarOrBlock(context, name, kind, tokenStart, tokenEnd, origin) {
4663
4677
  if (kind & 4) {
4664
- this.addVarName(context, name, kind);
4678
+ this.addVarName(context, name, kind, tokenStart, tokenEnd);
4665
4679
  }
4666
4680
  else {
4667
- this.addBlockName(context, name, kind, origin);
4681
+ this.addBlockName(context, name, kind, tokenStart, tokenEnd, origin);
4668
4682
  }
4669
4683
  if (origin & 64) {
4670
4684
  this.parser.declareUnboundVariable(name);
4671
4685
  }
4672
4686
  }
4673
- addVarName(context, name, kind) {
4687
+ addVarName(context, name, kind, tokenStart, tokenEnd) {
4674
4688
  const { parser } = this;
4675
4689
  let currentScope = this;
4676
4690
  while (currentScope && (currentScope.type & 128) === 0) {
@@ -4682,17 +4696,17 @@ class Scope {
4682
4696
  ((kind & 128 && value & 68) ||
4683
4697
  (value & 128 && kind & 68))) ;
4684
4698
  else {
4685
- parser.report(147, name);
4699
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4686
4700
  }
4687
4701
  }
4688
4702
  if (currentScope === this) {
4689
4703
  if (value && value & 1 && kind & 1) {
4690
- currentScope.recordScopeError(147, name);
4704
+ currentScope.recordScopeError(147, tokenStart, tokenEnd, name);
4691
4705
  }
4692
4706
  }
4693
4707
  if (value &&
4694
4708
  (value & 256 || (value & 512 && !parser.options.webcompat))) {
4695
- parser.report(147, name);
4709
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4696
4710
  }
4697
4711
  currentScope.variableBindings.set(name, kind);
4698
4712
  currentScope = currentScope.parent;
@@ -4701,12 +4715,12 @@ class Scope {
4701
4715
  hasVariable(name) {
4702
4716
  return this.variableBindings.has(name);
4703
4717
  }
4704
- addBlockName(context, name, kind, origin) {
4718
+ addBlockName(context, name, kind, tokenStart, tokenEnd, origin = 0) {
4705
4719
  const { parser } = this;
4706
4720
  const value = this.variableBindings.get(name);
4707
4721
  if (value && (value & 2) === 0) {
4708
4722
  if (kind & 1) {
4709
- this.recordScopeError(147, name);
4723
+ this.recordScopeError(147, tokenStart, tokenEnd, name);
4710
4724
  }
4711
4725
  else if (parser.options.webcompat &&
4712
4726
  (context & 1) === 0 &&
@@ -4714,31 +4728,31 @@ class Scope {
4714
4728
  value === 64 &&
4715
4729
  kind === 64) ;
4716
4730
  else {
4717
- parser.report(147, name);
4731
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4718
4732
  }
4719
4733
  }
4720
4734
  if (this.type & 64 &&
4721
4735
  this.parent?.hasVariable(name) &&
4722
4736
  (this.parent.variableBindings.get(name) & 2) === 0) {
4723
- parser.report(147, name);
4737
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4724
4738
  }
4725
4739
  if (this.type & 512 && value && (value & 2) === 0) {
4726
4740
  if (kind & 1) {
4727
- this.recordScopeError(147, name);
4741
+ this.recordScopeError(147, tokenStart, tokenEnd, name);
4728
4742
  }
4729
4743
  }
4730
4744
  if (this.type & 32) {
4731
4745
  if (this.parent.variableBindings.get(name) & 768)
4732
- parser.report(161, name);
4746
+ throw new ParseError(tokenStart, tokenEnd, 161, name);
4733
4747
  }
4734
4748
  this.variableBindings.set(name, kind);
4735
4749
  }
4736
- recordScopeError(type, ...params) {
4737
- this.scopeError = {
4750
+ recordScopeError(type, tokenStart, tokenEnd, ...params) {
4751
+ this.scopeError ??= {
4738
4752
  type,
4739
4753
  params,
4740
- start: this.parser.tokenStart,
4741
- end: this.parser.currentLocation,
4754
+ start: tokenStart,
4755
+ end: tokenEnd,
4742
4756
  };
4743
4757
  }
4744
4758
  reportScopeError() {
@@ -4749,9 +4763,9 @@ class Scope {
4749
4763
  throw new ParseError(scopeError.start, scopeError.end, scopeError.type, ...scopeError.params);
4750
4764
  }
4751
4765
  }
4752
- function createArrowHeadParsingScope(parser, context, value) {
4766
+ function createArrowHeadParsingScope(parser, context, value, tokenStart, tokenEnd) {
4753
4767
  const scope = parser.createScope().createChildScope(512);
4754
- scope.addBlockName(context, value, 1, 0);
4768
+ scope.addBlockName(context, value, 1, tokenStart, tokenEnd);
4755
4769
  return scope;
4756
4770
  }
4757
4771
 
@@ -4781,6 +4795,7 @@ class Parser {
4781
4795
  assignable = 0;
4782
4796
  destructible = 0;
4783
4797
  strictReservedRange = null;
4798
+ firstAwaitLocation = null;
4784
4799
  leadingDecorators = { decorators: [] };
4785
4800
  constructor(source, rawOptions = {}) {
4786
4801
  this.source = source;
@@ -4989,7 +5004,7 @@ function parseStatementList(parser, context, scope) {
4989
5004
  statements.push(parseDirective(parser, context, expr, token, tokenStart));
4990
5005
  }
4991
5006
  while (parser.getToken() !== 1048576) {
4992
- statements.push(parseStatementListItem(parser, context, scope, undefined, 4, {}));
5007
+ statements.push(parseStatementListItem(parser, context, scope, undefined, {}, 4));
4993
5008
  }
4994
5009
  return statements;
4995
5010
  }
@@ -5025,18 +5040,18 @@ function parseModuleItem(parser, context, scope) {
5025
5040
  moduleItem = parseImportDeclaration(parser, context, scope);
5026
5041
  break;
5027
5042
  default:
5028
- moduleItem = parseStatementListItem(parser, context, scope, undefined, 4, {});
5043
+ moduleItem = parseStatementListItem(parser, context, scope, undefined, {}, 4);
5029
5044
  }
5030
5045
  return moduleItem;
5031
5046
  }
5032
- function parseStatementListItem(parser, context, scope, privateScope, origin, labels) {
5047
+ function parseStatementListItem(parser, context, scope, privateScope, labels, origin = 2) {
5033
5048
  const start = parser.tokenStart;
5034
5049
  if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
5035
5050
  parser.report(172);
5036
5051
  }
5037
5052
  switch (parser.getToken()) {
5038
5053
  case 86104:
5039
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 0, start);
5054
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 0, start, origin);
5040
5055
  case 133:
5041
5056
  if (!(parser.features & 1)) {
5042
5057
  parser.report(30, '@');
@@ -5044,17 +5059,17 @@ function parseStatementListItem(parser, context, scope, privateScope, origin, la
5044
5059
  case 86094:
5045
5060
  return parseClassDeclaration(parser, context, scope, privateScope, 0);
5046
5061
  case 86090:
5047
- return parseLexicalDeclaration(parser, context, scope, privateScope, 16, 0);
5062
+ return parseLexicalDeclaration(parser, context, scope, privateScope, 16);
5048
5063
  case 241737:
5049
5064
  return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin);
5050
5065
  case 209013:
5051
- return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5066
+ return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5052
5067
  case 209006:
5053
5068
  if ((context & 2048 || (context & 2 && context & 8)) &&
5054
5069
  nextTokenIsUsingOnSameLine(parser)) {
5055
- return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5070
+ return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5056
5071
  }
5057
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5072
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5058
5073
  case 20564:
5059
5074
  parser.report(103, 'export');
5060
5075
  case 86106:
@@ -5068,15 +5083,15 @@ function parseStatementListItem(parser, context, scope, privateScope, origin, la
5068
5083
  parser.report(103, 'import');
5069
5084
  }
5070
5085
  case 209005:
5071
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 1);
5086
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 1, origin);
5072
5087
  default:
5073
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5088
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5074
5089
  }
5075
5090
  }
5076
- function parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5091
+ function parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin = 0) {
5077
5092
  switch (parser.getToken()) {
5078
5093
  case 86088:
5079
- return parseVariableStatement(parser, context, scope, privateScope, 0);
5094
+ return parseVariableStatement(parser, context, scope, privateScope);
5080
5095
  case 20572:
5081
5096
  return parseReturnStatement(parser, context, privateScope);
5082
5097
  case 20569:
@@ -5106,7 +5121,7 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
5106
5121
  case 20560:
5107
5122
  return parseDebuggerStatement(parser, context);
5108
5123
  case 209005:
5109
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 0);
5124
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 0, origin);
5110
5125
  case 20557:
5111
5126
  parser.report(164);
5112
5127
  case 20566:
@@ -5120,10 +5135,10 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
5120
5135
  case 86094:
5121
5136
  parser.report(79);
5122
5137
  default:
5123
- return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5138
+ return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5124
5139
  }
5125
5140
  }
5126
- function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5141
+ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5127
5142
  const { tokenValue, tokenStart } = parser;
5128
5143
  const token = parser.getToken();
5129
5144
  let expr;
@@ -5138,11 +5153,11 @@ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope
5138
5153
  default:
5139
5154
  expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart);
5140
5155
  }
5141
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, expr, token, tokenValue, tokenStart);
5156
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, expr, token, tokenValue, tokenStart, origin);
5142
5157
  }
5143
- function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart) {
5158
+ function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart, origin) {
5144
5159
  if (token & 143360 && parser.getToken() === 21) {
5145
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart);
5160
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart, origin);
5146
5161
  }
5147
5162
  let expression = parseMemberOrUpdateExpression(parser, context, privateScope, initialExpression, 0, 0, tokenStart);
5148
5163
  expression = parseAssignmentExpression(parser, context, privateScope, 0, 0, tokenStart, expression);
@@ -5155,7 +5170,7 @@ function parseBlock(parser, context, scope, privateScope, labels, start = parser
5155
5170
  const body = [];
5156
5171
  consume(parser, context | 32, 2162700);
5157
5172
  while (parser.getToken() !== 1074790415) {
5158
- body.push(parseStatementListItem(parser, context, scope, privateScope, 2, { $: labels }));
5173
+ body.push(parseStatementListItem(parser, context, scope, privateScope, { $: labels }));
5159
5174
  }
5160
5175
  consume(parser, context | 32, 1074790415);
5161
5176
  return parser.finishNode({
@@ -5184,7 +5199,7 @@ function parseExpressionStatement(parser, context, expression, start) {
5184
5199
  expression,
5185
5200
  }, start);
5186
5201
  }
5187
- function parseLabelledStatement(parser, context, scope, privateScope, origin, labels, value, expr, token, allowFuncDecl, start) {
5202
+ function parseLabelledStatement(parser, context, scope, privateScope, labels, value, expr, token, allowFuncDecl, start, origin) {
5188
5203
  validateBindingIdentifier(parser, context, 0, token, 1);
5189
5204
  validateAndDeclareLabel(parser, labels, value);
5190
5205
  nextToken(parser, context | 32);
@@ -5192,27 +5207,27 @@ function parseLabelledStatement(parser, context, scope, privateScope, origin, la
5192
5207
  (context & 1) === 0 &&
5193
5208
  parser.options.webcompat &&
5194
5209
  parser.getToken() === 86104
5195
- ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, origin, 0, 0, 0, parser.tokenStart)
5196
- : parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5210
+ ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, parser.tokenStart, origin)
5211
+ : parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5197
5212
  return parser.finishNode({
5198
5213
  type: 'LabeledStatement',
5199
5214
  label: expr,
5200
5215
  body,
5201
5216
  }, start);
5202
5217
  }
5203
- function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5218
+ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5204
5219
  const { tokenValue, tokenStart: start } = parser;
5205
5220
  const token = parser.getToken();
5206
5221
  let expr = parseIdentifier(parser, context);
5207
5222
  if (parser.getToken() === 21) {
5208
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, expr, token, 1, start);
5223
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, 1, start, origin);
5209
5224
  }
5210
5225
  const asyncNewLine = parser.flags & 1;
5211
5226
  if (!asyncNewLine) {
5212
5227
  if (parser.getToken() === 86104) {
5213
5228
  if (!allowFuncDecl)
5214
5229
  parser.report(125);
5215
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 1, start);
5230
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 1, start, origin);
5216
5231
  }
5217
5232
  if (isValidIdentifier(context, parser.getToken())) {
5218
5233
  expr = parseAsyncArrowAfterIdent(parser, context, privateScope, 1, start);
@@ -5222,7 +5237,7 @@ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, priva
5222
5237
  }
5223
5238
  }
5224
5239
  if (parser.getToken() === 67174411) {
5225
- expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, 0, asyncNewLine, start);
5240
+ expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, asyncNewLine, start);
5226
5241
  }
5227
5242
  else {
5228
5243
  if (parser.getToken() === 10) {
@@ -5308,8 +5323,8 @@ function parseConsequentOrAlternative(parser, context, scope, privateScope, labe
5308
5323
  return context & 1 ||
5309
5324
  !parser.options.webcompat ||
5310
5325
  parser.getToken() !== 86104
5311
- ? parseStatement(parser, context, scope, privateScope, 0, { $: labels }, 0)
5312
- : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, 0, tokenStart);
5326
+ ? parseStatement(parser, context, scope, privateScope, { $: labels }, 0)
5327
+ : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, tokenStart);
5313
5328
  }
5314
5329
  function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5315
5330
  const start = parser.tokenStart;
@@ -5338,7 +5353,7 @@ function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5338
5353
  while (parser.getToken() !== 20556 &&
5339
5354
  parser.getToken() !== 1074790415 &&
5340
5355
  parser.getToken() !== 20561) {
5341
- const statement = parseStatementListItem(parser, context | 4, scope, privateScope, 2, {
5356
+ const statement = parseStatementListItem(parser, context | 4, scope, privateScope, {
5342
5357
  $: labels,
5343
5358
  });
5344
5359
  if (statement.type === 'VariableDeclaration' &&
@@ -5374,7 +5389,7 @@ function parseWhileStatement(parser, context, scope, privateScope, labels) {
5374
5389
  }, start);
5375
5390
  }
5376
5391
  function parseIterationStatementBody(parser, context, scope, privateScope, labels) {
5377
- return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, 0, { loop: 1, $: labels }, 0);
5392
+ return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, { loop: 1, $: labels }, 0);
5378
5393
  }
5379
5394
  function parseContinueStatement(parser, context, labels) {
5380
5395
  if ((context & 128) === 0)
@@ -5421,7 +5436,7 @@ function parseWithStatement(parser, context, scope, privateScope, labels) {
5421
5436
  consume(parser, context | 32, 67174411);
5422
5437
  const object = parseExpressions(parser, context, privateScope, 0, 1, parser.tokenStart);
5423
5438
  consume(parser, context | 32, 16);
5424
- const body = parseStatement(parser, context, scope, privateScope, 2, labels, 0);
5439
+ const body = parseStatement(parser, context, scope, privateScope, labels, 0, 2);
5425
5440
  return parser.finishNode({
5426
5441
  type: 'WithStatement',
5427
5442
  object,
@@ -5468,7 +5483,7 @@ function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
5468
5483
  scope = scope?.createChildScope(4);
5469
5484
  param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
5470
5485
  ? 256
5471
- : 512, 0);
5486
+ : 512);
5472
5487
  if (parser.getToken() === 18) {
5473
5488
  parser.report(86);
5474
5489
  }
@@ -5512,12 +5527,12 @@ function parseDoWhileStatement(parser, context, scope, privateScope, labels) {
5512
5527
  }, start);
5513
5528
  }
5514
5529
  function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin) {
5515
- const { tokenValue, tokenStart } = parser;
5530
+ const { tokenValue, tokenStart, currentLocation } = parser;
5516
5531
  const token = parser.getToken();
5517
5532
  let expr = parseIdentifier(parser, context);
5518
5533
  if (parser.getToken() & (143360 | 2097152) &&
5519
5534
  (parser.getToken() & 20480) !== 20480) {
5520
- const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8, 0);
5535
+ const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8);
5521
5536
  matchOrInsertSemicolon(parser, context | 32);
5522
5537
  return parser.finishNode({
5523
5538
  type: 'VariableDeclaration',
@@ -5529,12 +5544,12 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
5529
5544
  if (context & 1)
5530
5545
  parser.report(85);
5531
5546
  if (parser.getToken() === 21) {
5532
- return parseLabelledStatement(parser, context, scope, privateScope, origin, {}, tokenValue, expr, token, 0, tokenStart);
5547
+ return parseLabelledStatement(parser, context, scope, privateScope, {}, tokenValue, expr, token, 0, tokenStart, origin);
5533
5548
  }
5534
5549
  if (parser.getToken() === 10) {
5535
5550
  let scope = void 0;
5536
5551
  if (parser.options.lexical)
5537
- scope = createArrowHeadParsingScope(parser, context, tokenValue);
5552
+ scope = createArrowHeadParsingScope(parser, context, tokenValue, tokenStart, currentLocation);
5538
5553
  parser.flags = (parser.flags | 128) ^ 128;
5539
5554
  expr = parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, tokenStart);
5540
5555
  }
@@ -5583,20 +5598,23 @@ function nextTokenIsUsingOnSameLine(parser) {
5583
5598
  function isResourceBindingStart(token) {
5584
5599
  return (token & 143360) === 143360 && (token & 20480) !== 20480;
5585
5600
  }
5586
- function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5601
+ function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5587
5602
  const { tokenStart, tokenValue } = parser;
5588
5603
  const token = parser.getToken();
5589
5604
  const expression = parseIdentifier(parser, context);
5590
5605
  if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
5591
- if (origin & 4 && context & 8 && (context & 2) === 0) {
5606
+ if (origin & 4 &&
5607
+ context & 8 &&
5608
+ (context & 2) === 0 &&
5609
+ (context & 4096) === 0) {
5592
5610
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5593
5611
  }
5594
5612
  return parseLexicalDeclaration(parser, context, scope, privateScope, 16, origin, 'using', tokenStart, 1);
5595
5613
  }
5596
5614
  parser.assignable = 1;
5597
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 1, expression, token, tokenValue, tokenStart);
5615
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 1, expression, token, tokenValue, tokenStart, origin);
5598
5616
  }
5599
- function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5617
+ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5600
5618
  const start = parser.tokenStart;
5601
5619
  if (context & 524288)
5602
5620
  parser.report(179);
@@ -5620,9 +5638,9 @@ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope,
5620
5638
  type: 'AwaitExpression',
5621
5639
  argument,
5622
5640
  }, start);
5623
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 0, expression, 1048576, '', start);
5641
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 0, expression, 1048576, '', start, origin);
5624
5642
  }
5625
- function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5643
+ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin = 0, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5626
5644
  const start = declarationStart;
5627
5645
  if (!keywordConsumed)
5628
5646
  nextToken(parser, context);
@@ -5634,7 +5652,7 @@ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, ori
5634
5652
  declarations,
5635
5653
  }, start);
5636
5654
  }
5637
- function parseVariableStatement(parser, context, scope, privateScope, origin) {
5655
+ function parseVariableStatement(parser, context, scope, privateScope, origin = 0) {
5638
5656
  const start = parser.tokenStart;
5639
5657
  nextToken(parser, context);
5640
5658
  const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 4, origin);
@@ -5645,7 +5663,7 @@ function parseVariableStatement(parser, context, scope, privateScope, origin) {
5645
5663
  declarations,
5646
5664
  }, start);
5647
5665
  }
5648
- function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin, declarationKind) {
5666
+ function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin = 0, declarationKind) {
5649
5667
  let bindingCount = 1;
5650
5668
  const firstDeclaration = parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind);
5651
5669
  const list = [firstDeclaration];
@@ -5676,11 +5694,14 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
5676
5694
  const id = parseBindingPattern(parser, context, scope, privateScope, kind, origin);
5677
5695
  if (parser.getToken() === 1077936155) {
5678
5696
  nextToken(parser, context | 32);
5679
- init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5697
+ init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart, origin);
5680
5698
  if (origin & 32) {
5681
5699
  if (parser.getToken() === 471156 ||
5682
5700
  (parser.getToken() === 8673330 &&
5683
- (token & 2097152 || (kind & 4) === 0 || context & 1))) {
5701
+ (token & 2097152 ||
5702
+ (kind & 4) === 0 ||
5703
+ context & 1 ||
5704
+ !parser.options.webcompat))) {
5684
5705
  throw new ParseError(tokenStart, parser.currentLocation, 60, parser.getToken() === 471156 ? 'of' : 'in');
5685
5706
  }
5686
5707
  }
@@ -5747,6 +5768,7 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5747
5768
  }
5748
5769
  else if (parser.getToken() === 471156) {
5749
5770
  const ofStart = parser.tokenStart;
5771
+ const ofEnd = parser.currentLocation;
5750
5772
  const ofToken = parser.getToken();
5751
5773
  const ofValue = parser.tokenValue;
5752
5774
  const ofIdentifier = parseIdentifier(parser, context);
@@ -5762,7 +5784,7 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5762
5784
  else {
5763
5785
  resourceDeclarationKind = 'using';
5764
5786
  validateBindingIdentifier(parser, context, 16, ofToken, 0);
5765
- scope?.addBlockName(context, ofValue, 16, 32);
5787
+ scope?.addBlockName(context, ofValue, 16, ofStart, ofEnd, 32);
5766
5788
  let declarationInitializer = null;
5767
5789
  if (parser.getToken() === 1077936155) {
5768
5790
  nextToken(parser, context | 32);
@@ -5953,7 +5975,7 @@ function parseRestrictedIdentifier(parser, context, scope) {
5953
5975
  parser.report(120);
5954
5976
  if ((parser.getToken() & 537079808) === 537079808)
5955
5977
  parser.report(121);
5956
- scope?.addBlockName(context, parser.tokenValue, 8, 0);
5978
+ scope?.addBlockName(context, parser.tokenValue, 8, parser.tokenStart, parser.currentLocation);
5957
5979
  return parseIdentifier(parser, context);
5958
5980
  }
5959
5981
  function parseImportDeclaration(parser, context, scope) {
@@ -5970,7 +5992,7 @@ function parseImportDeclaration(parser, context, scope) {
5970
5992
  else {
5971
5993
  if (parser.getToken() & 143360) {
5972
5994
  const token = parser.getToken();
5973
- const { tokenValue } = parser;
5995
+ const { tokenValue, tokenStart: start, currentLocation } = parser;
5974
5996
  const isPhaseDefer = parser.features & 2 && (token & -2147483648) === 0 && tokenValue == 'defer';
5975
5997
  const isPhaseSource = parser.features & 4 && (token & -2147483648) === 0 && tokenValue == 'source';
5976
5998
  if (isPhaseDefer || isPhaseSource) {
@@ -5981,7 +6003,7 @@ function parseImportDeclaration(parser, context, scope) {
5981
6003
  specifiers = [parseImportNamespaceSpecifier(parser, context, scope)];
5982
6004
  }
5983
6005
  else if (parser.getToken() === 209011 || parser.getToken() === 18) {
5984
- scope?.addBlockName(context, tokenValue, 8, 0);
6006
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
5985
6007
  specifiers = [
5986
6008
  parser.finishNode({
5987
6009
  type: 'ImportDefaultSpecifier',
@@ -5996,10 +6018,11 @@ function parseImportDeclaration(parser, context, scope) {
5996
6018
  else if (parser.getToken() === 209011) {
5997
6019
  const fromToken = parser.getToken();
5998
6020
  const fromStart = parser.tokenStart;
6021
+ const fromEnd = parser.currentLocation;
5999
6022
  const fromLocal = parseIdentifier(parser, context);
6000
6023
  if (parser.getToken() === 209011) {
6001
6024
  validateBindingIdentifier(parser, context, 16, fromToken, 0);
6002
- scope?.addBlockName(context, fromLocal.name, 8, 0);
6025
+ scope?.addBlockName(context, fromLocal.name, 8, fromStart, fromEnd);
6003
6026
  phase = 'source';
6004
6027
  specifiers = [
6005
6028
  parser.finishNode({
@@ -6009,7 +6032,7 @@ function parseImportDeclaration(parser, context, scope) {
6009
6032
  ];
6010
6033
  }
6011
6034
  else {
6012
- scope?.addBlockName(context, tokenValue, 8, 0);
6035
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
6013
6036
  specifiers = [
6014
6037
  parser.finishNode({
6015
6038
  type: 'ImportDefaultSpecifier',
@@ -6034,7 +6057,7 @@ function parseImportDeclaration(parser, context, scope) {
6034
6057
  ];
6035
6058
  }
6036
6059
  else if (parser.getToken() === 18) {
6037
- scope?.addBlockName(context, tokenValue, 8, 0);
6060
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
6038
6061
  specifiers = [
6039
6062
  parser.finishNode({
6040
6063
  type: 'ImportDefaultSpecifier',
@@ -6119,7 +6142,8 @@ function parseModuleSpecifier(parser, context) {
6119
6142
  function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers) {
6120
6143
  nextToken(parser, context);
6121
6144
  while (parser.getToken() & 143360 || parser.getToken() === 134283267) {
6122
- let { tokenValue, tokenStart } = parser;
6145
+ let { tokenValue, tokenStart, currentLocation } = parser;
6146
+ const start = tokenStart;
6123
6147
  const token = parser.getToken();
6124
6148
  const imported = parseModuleExportName(parser, context);
6125
6149
  let local;
@@ -6132,6 +6156,8 @@ function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers)
6132
6156
  validateBindingIdentifier(parser, context, 16, parser.getToken(), 0);
6133
6157
  }
6134
6158
  tokenValue = parser.tokenValue;
6159
+ tokenStart = parser.tokenStart;
6160
+ currentLocation = parser.currentLocation;
6135
6161
  local = parseIdentifier(parser, context);
6136
6162
  }
6137
6163
  else if (imported.type === 'Identifier') {
@@ -6141,12 +6167,12 @@ function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers)
6141
6167
  else {
6142
6168
  parser.report(25, KeywordDescTable[77932 & 255]);
6143
6169
  }
6144
- scope?.addBlockName(context, tokenValue, 8, 0);
6170
+ scope?.addBlockName(context, tokenValue, 8, tokenStart, currentLocation);
6145
6171
  specifiers.push(parser.finishNode({
6146
6172
  type: 'ImportSpecifier',
6147
6173
  local,
6148
6174
  imported,
6149
- }, tokenStart));
6175
+ }, start));
6150
6176
  if (parser.getToken() !== 1074790415)
6151
6177
  consume(parser, context, 18);
6152
6178
  }
@@ -6187,7 +6213,7 @@ function parseExportDeclaration(parser, context, scope) {
6187
6213
  if (isDefaultExport) {
6188
6214
  switch (parser.getToken()) {
6189
6215
  case 86104: {
6190
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 0, parser.tokenStart);
6216
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 0, parser.tokenStart, 4);
6191
6217
  break;
6192
6218
  }
6193
6219
  case 133:
@@ -6203,17 +6229,17 @@ function parseExportDeclaration(parser, context, scope) {
6203
6229
  const { flags } = parser;
6204
6230
  if ((flags & 1) === 0) {
6205
6231
  if (parser.getToken() === 86104) {
6206
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 1, tokenStart);
6232
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 1, tokenStart, 4);
6207
6233
  }
6208
6234
  else {
6209
6235
  if (parser.getToken() === 67174411) {
6210
- declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, 0, flags, tokenStart);
6236
+ declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, flags, tokenStart);
6211
6237
  declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
6212
6238
  declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
6213
6239
  }
6214
6240
  else if (parser.getToken() & 143360) {
6215
6241
  if (scope)
6216
- scope = createArrowHeadParsingScope(parser, context, parser.tokenValue);
6242
+ scope = createArrowHeadParsingScope(parser, context, parser.tokenValue, parser.tokenStart, parser.currentLocation);
6217
6243
  declaration = parseIdentifier(parser, context);
6218
6244
  declaration = parseArrowFunctionExpression(parser, context, scope, undefined, [declaration], 1, tokenStart);
6219
6245
  }
@@ -6324,7 +6350,7 @@ function parseExportDeclaration(parser, context, scope) {
6324
6350
  declaration = parseClassDeclaration(parser, context, scope, undefined, 2);
6325
6351
  break;
6326
6352
  case 86104:
6327
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 0, parser.tokenStart);
6353
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 0, parser.tokenStart, 4);
6328
6354
  break;
6329
6355
  case 241737:
6330
6356
  declaration = parseLexicalDeclaration(parser, context, scope, undefined, 8, 64);
@@ -6339,7 +6365,7 @@ function parseExportDeclaration(parser, context, scope) {
6339
6365
  const { tokenStart } = parser;
6340
6366
  nextToken(parser, context);
6341
6367
  if ((parser.flags & 1) === 0 && parser.getToken() === 86104) {
6342
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 1, tokenStart);
6368
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 1, tokenStart, 4);
6343
6369
  break;
6344
6370
  }
6345
6371
  }
@@ -6355,8 +6381,8 @@ function parseExportDeclaration(parser, context, scope) {
6355
6381
  };
6356
6382
  return parser.finishNode(node, start);
6357
6383
  }
6358
- function parseExpression(parser, context, privateScope, canAssign, inGroup, start) {
6359
- let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start);
6384
+ function parseExpression(parser, context, privateScope, canAssign, inGroup, start, origin = 0) {
6385
+ let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start, origin);
6360
6386
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGroup, 0, start);
6361
6387
  return parseAssignmentExpression(parser, context, privateScope, inGroup, 0, start, expr);
6362
6388
  }
@@ -6511,7 +6537,7 @@ function parseAsyncExpression(parser, context, privateScope, inGroup, isLHS, can
6511
6537
  }
6512
6538
  }
6513
6539
  if (!inNew && parser.getToken() === 67174411) {
6514
- return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, 0, flags, start);
6540
+ return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, flags, start);
6515
6541
  }
6516
6542
  if (parser.getToken() === 10) {
6517
6543
  classifyIdentifier(parser, context, token);
@@ -6559,8 +6585,12 @@ function parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup
6559
6585
  return parseIdentifierOrArrow(parser, context, privateScope);
6560
6586
  }
6561
6587
  function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, start) {
6562
- if (inGroup)
6588
+ if (inGroup) {
6589
+ if ((parser.destructible & 128) === 0) {
6590
+ parser.firstAwaitLocation ??= { start, end: parser.currentLocation };
6591
+ }
6563
6592
  parser.destructible |= 128;
6593
+ }
6564
6594
  if (context & 524288)
6565
6595
  parser.report(179);
6566
6596
  const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope);
@@ -6594,7 +6624,7 @@ function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew,
6594
6624
  throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 98);
6595
6625
  return possibleIdentifierOrArrowFunc;
6596
6626
  }
6597
- function parseFunctionBody(parser, context, scope, privateScope, origin, funcNameToken, functionScope) {
6627
+ function parseFunctionBody(parser, context, scope, privateScope, funcNameToken, functionScope, origin = 0) {
6598
6628
  const { tokenStart } = parser;
6599
6629
  parser.flags &= -4161;
6600
6630
  consume(parser, context | 32, 2162700);
@@ -6643,7 +6673,7 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
6643
6673
  (512 | 256 | 64 | 4096);
6644
6674
  parser.destructible = (parser.destructible | 256) ^ 256;
6645
6675
  while (parser.getToken() !== 1074790415) {
6646
- body.push(parseStatementListItem(parser, context, scope, privateScope, 4, {}));
6676
+ body.push(parseStatementListItem(parser, context, scope, privateScope, {}, 4));
6647
6677
  }
6648
6678
  consume(parser, origin & (16 | 8) ? context | 32 : context, 1074790415);
6649
6679
  parser.flags &= -4289;
@@ -6892,7 +6922,7 @@ function parseUpdateExpressionPrefixed(parser, context, privateScope, inNew, isL
6892
6922
  prefix: true,
6893
6923
  }, start);
6894
6924
  }
6895
- function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start) {
6925
+ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start, origin = 0) {
6896
6926
  if ((parser.getToken() & 143360) === 143360) {
6897
6927
  switch (parser.getToken()) {
6898
6928
  case 209006:
@@ -6912,7 +6942,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6912
6942
  if ((token & 36864) === 36864) {
6913
6943
  parser.flags |= 256;
6914
6944
  }
6915
- return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start);
6945
+ return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start, origin);
6916
6946
  }
6917
6947
  if (context & 16 &&
6918
6948
  !(context & 32768) &&
@@ -6953,7 +6983,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6953
6983
  case 69271571:
6954
6984
  return parseArrayLiteral(parser, context, privateScope, canAssign ? 0 : 1, inGroup);
6955
6985
  case 67174411:
6956
- return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, 0, start);
6986
+ return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, start, origin);
6957
6987
  case 86021:
6958
6988
  case 86022:
6959
6989
  case 86023:
@@ -7282,7 +7312,7 @@ function parseThisExpression(parser, context) {
7282
7312
  type: 'ThisExpression',
7283
7313
  }, tokenStart);
7284
7314
  }
7285
- function parseFunctionDeclaration(parser, context, scope, privateScope, origin, allowGen, flags, isAsync, start) {
7315
+ function parseFunctionDeclaration(parser, context, scope, privateScope, allowGen, flags, isAsync, start, origin = 0) {
7286
7316
  nextToken(parser, context | 32);
7287
7317
  const isGenerator = allowGen ? optionalBit(parser, context, 8391476) : 0;
7288
7318
  let id = null;
@@ -7298,12 +7328,7 @@ function parseFunctionDeclaration(parser, context, scope, privateScope, origin,
7298
7328
  : 64 | (isAsync ? 1024 : 0) | (isGenerator ? 1024 : 0);
7299
7329
  validateFunctionName(parser, context, parser.getToken());
7300
7330
  if (scope) {
7301
- if (kind & 4) {
7302
- scope.addVarName(context, parser.tokenValue, kind);
7303
- }
7304
- else {
7305
- scope.addBlockName(context, parser.tokenValue, kind, origin);
7306
- }
7331
+ scope.addVarOrBlock(context, parser.tokenValue, kind, parser.tokenStart, parser.currentLocation, origin);
7307
7332
  functionScope = functionScope?.createChildScope(128);
7308
7333
  if (flags) {
7309
7334
  if (flags & 2) {
@@ -7336,7 +7361,7 @@ function parseFunctionDeclaration(parser, context, scope, privateScope, origin,
7336
7361
  functionScope = functionScope?.createChildScope(256);
7337
7362
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, functionScope, privateScope, 0, 1);
7338
7363
  const modifierFlags = 8 | 4 | 128 | 524288;
7339
- const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, 8, funcNameToken, functionScope);
7364
+ const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, funcNameToken, functionScope, 8);
7340
7365
  return parser.finishNode({
7341
7366
  type: 'FunctionDeclaration',
7342
7367
  id,
@@ -7375,7 +7400,7 @@ function parseFunctionExpression(parser, context, privateScope, isAsync, inGroup
7375
7400
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, scope, privateScope, inGroup, 1);
7376
7401
  const body = parseFunctionBody(parser, (context & -131229) |
7377
7402
  32768 |
7378
- 4096, scope?.createChildScope(64), privateScope, 0, funcNameToken, scope);
7403
+ 4096, scope?.createChildScope(64), privateScope, funcNameToken, scope);
7379
7404
  parser.assignable = 2;
7380
7405
  return parser.finishNode({
7381
7406
  type: 'FunctionExpression',
@@ -7387,7 +7412,7 @@ function parseFunctionExpression(parser, context, privateScope, isAsync, inGroup
7387
7412
  }, start);
7388
7413
  }
7389
7414
  function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7390
- const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7415
+ const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7391
7416
  if (parser.destructible & 64) {
7392
7417
  parser.report(63);
7393
7418
  }
@@ -7396,7 +7421,7 @@ function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGro
7396
7421
  }
7397
7422
  return expr;
7398
7423
  }
7399
- function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7424
+ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7400
7425
  const { tokenStart: start } = parser;
7401
7426
  nextToken(parser, context | 32);
7402
7427
  const elements = [];
@@ -7408,7 +7433,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7408
7433
  }
7409
7434
  else {
7410
7435
  let left;
7411
- const { tokenStart, tokenValue } = parser;
7436
+ const { tokenStart, tokenValue, currentLocation } = parser;
7412
7437
  const token = parser.getToken();
7413
7438
  if (token & 143360) {
7414
7439
  left = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
@@ -7416,7 +7441,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7416
7441
  if (parser.assignable & 2)
7417
7442
  parser.report(26);
7418
7443
  nextToken(parser, context | 32);
7419
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7444
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7420
7445
  const right = parseExpression(parser, context, privateScope, 1, inGroup, parser.tokenStart);
7421
7446
  left = parser.finishNode(isPattern
7422
7447
  ? {
@@ -7442,7 +7467,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7442
7467
  destructible |= 16;
7443
7468
  }
7444
7469
  else {
7445
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7470
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7446
7471
  }
7447
7472
  destructible |=
7448
7473
  parser.destructible & 256
@@ -7505,7 +7530,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
7505
7530
  }
7506
7531
  }
7507
7532
  else if (token === 14) {
7508
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, origin, 0, inGroup, isPattern);
7533
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, 0, inGroup, isPattern, origin);
7509
7534
  destructible |= parser.destructible;
7510
7535
  if (parser.getToken() !== 18 && parser.getToken() !== 20)
7511
7536
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
@@ -7575,12 +7600,12 @@ function parseArrayOrObjectAssignmentPattern(parser, context, privateScope, dest
7575
7600
  right,
7576
7601
  }, start);
7577
7602
  }
7578
- function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, origin, isAsync, inGroup, isPattern) {
7603
+ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, isAsync, inGroup, isPattern, origin = 0) {
7579
7604
  const { tokenStart: start } = parser;
7580
7605
  nextToken(parser, context | 32);
7581
7606
  let argument = null;
7582
7607
  let destructible = 0;
7583
- const { tokenValue, tokenStart } = parser;
7608
+ const { tokenValue, tokenStart, currentLocation } = parser;
7584
7609
  let token = parser.getToken();
7585
7610
  if (token & 143360) {
7586
7611
  parser.assignable = 1;
@@ -7597,7 +7622,7 @@ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingT
7597
7622
  destructible |= 16;
7598
7623
  }
7599
7624
  else if (token === closingToken || token === 18) {
7600
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7625
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7601
7626
  }
7602
7627
  else {
7603
7628
  destructible |= 32;
@@ -7724,7 +7749,7 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
7724
7749
  scope = scope?.createChildScope(64);
7725
7750
  const body = parseFunctionBody(parser, (context & -655373) |
7726
7751
  32768 |
7727
- 4096, scope, privateScope, 0, void 0, scope?.parent);
7752
+ 4096, scope, privateScope, void 0, scope?.parent);
7728
7753
  return parser.finishNode({
7729
7754
  type: 'FunctionExpression',
7730
7755
  params,
@@ -7735,7 +7760,7 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
7735
7760
  }, start);
7736
7761
  }
7737
7762
  function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7738
- const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7763
+ const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7739
7764
  if (parser.destructible & 64) {
7740
7765
  parser.report(63);
7741
7766
  }
@@ -7744,7 +7769,7 @@ function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGr
7744
7769
  }
7745
7770
  return expr;
7746
7771
  }
7747
- function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7772
+ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7748
7773
  const { tokenStart: start } = parser;
7749
7774
  nextToken(parser, context);
7750
7775
  const properties = [];
@@ -7752,10 +7777,10 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7752
7777
  let prototypeCount = 0;
7753
7778
  context = (context | 131072) ^ 131072;
7754
7779
  while (parser.getToken() !== 1074790415) {
7755
- const { tokenValue, tokenStart } = parser;
7780
+ const { tokenValue, tokenStart, currentLocation } = parser;
7756
7781
  const token = parser.getToken();
7757
7782
  if (token === 14) {
7758
- properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, origin, 0, inGroup, isPattern));
7783
+ properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, 0, inGroup, isPattern, origin));
7759
7784
  }
7760
7785
  else {
7761
7786
  let state = 0;
@@ -7777,7 +7802,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7777
7802
  else {
7778
7803
  validateBindingIdentifier(parser, context, kind, token, 0);
7779
7804
  }
7780
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7805
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7781
7806
  if (consumeOpt(parser, context | 32, 1077936155)) {
7782
7807
  destructible |= 8;
7783
7808
  const right = parseExpression(parser, context, privateScope, 1, inGroup, parser.tokenStart);
@@ -7801,7 +7826,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7801
7826
  }
7802
7827
  }
7803
7828
  else if (consumeOpt(parser, context | 32, 21)) {
7804
- const { tokenStart } = parser;
7829
+ const { tokenStart, currentLocation } = parser;
7805
7830
  if (tokenValue === '__proto__')
7806
7831
  prototypeCount++;
7807
7832
  if (parser.getToken() & 143360) {
@@ -7817,7 +7842,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7817
7842
  destructible |= 16;
7818
7843
  }
7819
7844
  else if ((tokenAfterColon & 143360) === 143360) {
7820
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
7845
+ scope?.addVarOrBlock(context, valueAfterColon, kind, tokenStart, currentLocation, origin);
7821
7846
  }
7822
7847
  }
7823
7848
  else {
@@ -7835,7 +7860,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7835
7860
  destructible |= 32;
7836
7861
  }
7837
7862
  else {
7838
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
7863
+ scope?.addVarOrBlock(context, valueAfterColon, kind, tokenStart, currentLocation, origin);
7839
7864
  }
7840
7865
  value = parseAssignmentExpression(parser, context, privateScope, inGroup, isPattern, tokenStart, value);
7841
7866
  }
@@ -8003,7 +8028,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
8003
8028
  prototypeCount++;
8004
8029
  if (parser.getToken() & 143360) {
8005
8030
  value = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
8006
- const { tokenValue: valueAfterColon } = parser;
8031
+ const { tokenValue: valueAfterColon, tokenStart: start, currentLocation } = parser;
8007
8032
  const token = parser.getToken();
8008
8033
  value = parseMemberOrUpdateExpression(parser, context, privateScope, value, inGroup, 0, tokenStart);
8009
8034
  if (parser.getToken() === 18 || parser.getToken() === 1074790415) {
@@ -8012,7 +8037,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
8012
8037
  destructible |= 16;
8013
8038
  }
8014
8039
  else {
8015
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
8040
+ scope?.addVarOrBlock(context, valueAfterColon, kind, start, currentLocation, origin);
8016
8041
  }
8017
8042
  }
8018
8043
  else {
@@ -8104,7 +8129,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
8104
8129
  state |= 2;
8105
8130
  if (parser.getToken() === 21) {
8106
8131
  nextToken(parser, context | 32);
8107
- const { tokenStart, tokenValue } = parser;
8132
+ const { tokenStart, tokenValue, currentLocation } = parser;
8108
8133
  const tokenAfterColon = parser.getToken();
8109
8134
  if (parser.getToken() & 143360) {
8110
8135
  value = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
@@ -8125,7 +8150,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
8125
8150
  destructible |= 16;
8126
8151
  }
8127
8152
  else if ((tokenAfterColon & 143360) === 143360) {
8128
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
8153
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
8129
8154
  }
8130
8155
  }
8131
8156
  else {
@@ -8283,6 +8308,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
8283
8308
  const params = [];
8284
8309
  parser.flags = (parser.flags | 128) ^ 128;
8285
8310
  parser.strictReservedRange = null;
8311
+ parser.firstAwaitLocation = null;
8286
8312
  if (parser.getToken() === 16) {
8287
8313
  if (kind & 512) {
8288
8314
  parser.report(37, 'Setter', 'one', '');
@@ -8312,17 +8338,17 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
8312
8338
  parser.flags |= 512;
8313
8339
  }
8314
8340
  }
8315
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8341
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8316
8342
  }
8317
8343
  else {
8318
8344
  if (parser.getToken() === 2162700) {
8319
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8345
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8320
8346
  }
8321
8347
  else if (parser.getToken() === 69271571) {
8322
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8348
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8323
8349
  }
8324
8350
  else if (parser.getToken() === 14) {
8325
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, 0, inGroup, 1);
8351
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, inGroup, 1);
8326
8352
  }
8327
8353
  isNonSimpleParameterList = 1;
8328
8354
  if (parser.destructible & (32 | 16))
@@ -8361,17 +8387,20 @@ function parseComputedPropertyName(parser, context, privateScope, inGroup) {
8361
8387
  consume(parser, context, 20);
8362
8388
  return key;
8363
8389
  }
8364
- function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, origin, start) {
8390
+ function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, start, origin) {
8365
8391
  parser.flags = (parser.flags | 128) ^ 128;
8366
8392
  const parenthesesStart = parser.tokenStart;
8367
8393
  nextToken(parser, context | 32 | 262144);
8368
8394
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8369
8395
  context = (context | 131072) ^ 131072;
8370
8396
  if (consumeOpt(parser, context, 16)) {
8371
- return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start);
8397
+ return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start, origin);
8372
8398
  }
8373
8399
  let destructible = 0;
8400
+ const previousAwaitYield = parser.destructible & (256 | 128);
8374
8401
  parser.destructible &= -385;
8402
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8403
+ parser.firstAwaitLocation = null;
8375
8404
  let expr;
8376
8405
  let expressions = [];
8377
8406
  let isSequence = 0;
@@ -8380,17 +8409,17 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8380
8409
  const tokenAfterParenthesesStart = parser.tokenStart;
8381
8410
  parser.assignable = 1;
8382
8411
  while (parser.getToken() !== 16) {
8383
- const { tokenStart } = parser;
8412
+ const { tokenStart, currentLocation } = parser;
8384
8413
  const token = parser.getToken();
8385
8414
  if (token & 143360) {
8386
- scope?.addBlockName(context, parser.tokenValue, 1, 0);
8415
+ scope?.addBlockName(context, parser.tokenValue, 1, tokenStart, currentLocation);
8387
8416
  if ((token & 537079808) === 537079808) {
8388
8417
  isNonSimpleParameterList = 1;
8389
8418
  }
8390
8419
  else if ((token & 36864) === 36864) {
8391
8420
  hasStrictReserved = 1;
8392
8421
  }
8393
- expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart);
8422
+ expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart, 0);
8394
8423
  if (parser.getToken() === 16 || parser.getToken() === 18) {
8395
8424
  if (parser.assignable & 2) {
8396
8425
  destructible |= 16;
@@ -8413,8 +8442,8 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8413
8442
  else if ((token & 2097152) === 2097152) {
8414
8443
  expr =
8415
8444
  token === 2162700
8416
- ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind, origin)
8417
- : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind, origin);
8445
+ ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind)
8446
+ : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind);
8418
8447
  destructible |= parser.destructible;
8419
8448
  isNonSimpleParameterList = 1;
8420
8449
  parser.assignable = 2;
@@ -8429,7 +8458,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8429
8458
  }
8430
8459
  }
8431
8460
  else if (token === 14) {
8432
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 0, 1, 0);
8461
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 1, 0);
8433
8462
  if (parser.destructible & 16)
8434
8463
  parser.report(74);
8435
8464
  isNonSimpleParameterList = 1;
@@ -8462,7 +8491,10 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8462
8491
  }, tokenAfterParenthesesStart);
8463
8492
  }
8464
8493
  consume(parser, context, 16);
8465
- parser.destructible = destructible;
8494
+ parser.destructible = destructible | previousAwaitYield;
8495
+ if (previousFirstAwaitLocation) {
8496
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8497
+ }
8466
8498
  return parser.options.preserveParens
8467
8499
  ? parser.finishNode({
8468
8500
  type: 'ParenthesizedExpression',
@@ -8503,8 +8535,12 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8503
8535
  if (parser.getToken() === 10) {
8504
8536
  if (destructible & (32 | 16))
8505
8537
  parser.report(49);
8506
- if (context & (2048 | 2) && destructible & 128)
8538
+ if (context & (2048 | 2) && destructible & 128) {
8539
+ const loc = parser.firstAwaitLocation;
8540
+ if (loc)
8541
+ throw new ParseError(loc.start, loc.end, 31);
8507
8542
  parser.report(31);
8543
+ }
8508
8544
  if (context & (1 | 1024) && destructible & 256) {
8509
8545
  parser.report(32);
8510
8546
  }
@@ -8512,7 +8548,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8512
8548
  parser.flags |= 128;
8513
8549
  if (hasStrictReserved)
8514
8550
  parser.flags |= 256;
8515
- return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start);
8551
+ return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start, origin);
8516
8552
  }
8517
8553
  if (destructible & 64) {
8518
8554
  parser.report(63);
@@ -8520,7 +8556,11 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8520
8556
  if (destructible & 8) {
8521
8557
  parser.report(146);
8522
8558
  }
8523
- parser.destructible = ((parser.destructible | 256) ^ 256) | destructible;
8559
+ parser.destructible =
8560
+ ((parser.destructible | 256) ^ 256) | destructible | previousAwaitYield;
8561
+ if (previousFirstAwaitLocation) {
8562
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8563
+ }
8524
8564
  return parser.options.preserveParens
8525
8565
  ? parser.finishNode({
8526
8566
  type: 'ParenthesizedExpression',
@@ -8529,8 +8569,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8529
8569
  : expr;
8530
8570
  }
8531
8571
  function parseIdentifierOrArrow(parser, context, privateScope) {
8532
- const { tokenStart: start } = parser;
8533
- const { tokenValue } = parser;
8572
+ const { tokenValue, tokenStart, currentLocation } = parser;
8534
8573
  let isNonSimpleParameterList = 0;
8535
8574
  let hasStrictReserved = 0;
8536
8575
  if ((parser.getToken() & 537079808) === 537079808) {
@@ -8542,32 +8581,36 @@ function parseIdentifierOrArrow(parser, context, privateScope) {
8542
8581
  const expr = parseIdentifier(parser, context);
8543
8582
  parser.assignable = 1;
8544
8583
  if (parser.getToken() === 10) {
8545
- const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, tokenValue) : undefined;
8584
+ const scope = parser.options.lexical
8585
+ ? createArrowHeadParsingScope(parser, context, tokenValue, tokenStart, currentLocation)
8586
+ : undefined;
8546
8587
  if (isNonSimpleParameterList)
8547
8588
  parser.flags |= 128;
8548
8589
  if (hasStrictReserved)
8549
8590
  parser.flags |= 256;
8550
- return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, start);
8591
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, tokenStart);
8551
8592
  }
8552
8593
  return expr;
8553
8594
  }
8554
- 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) {
8555
8596
  if (!canAssign)
8556
8597
  parser.report(57);
8557
8598
  if (inNew)
8558
8599
  parser.report(51);
8559
8600
  parser.flags &= -129;
8560
- const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, value) : void 0;
8561
- return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start);
8601
+ const scope = parser.options.lexical
8602
+ ? createArrowHeadParsingScope(parser, context, value, start, parser.currentLocation)
8603
+ : void 0;
8604
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start, origin);
8562
8605
  }
8563
- function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start) {
8606
+ function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start, origin = 0) {
8564
8607
  if (!canAssign)
8565
8608
  parser.report(57);
8566
8609
  for (let i = 0; i < params.length; ++i)
8567
8610
  reinterpretToPattern(parser, params[i]);
8568
- return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start);
8611
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin);
8569
8612
  }
8570
- function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start) {
8613
+ function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin = 0) {
8571
8614
  if (parser.flags & 1)
8572
8615
  parser.report(48);
8573
8616
  consume(parser, context | 32, 10);
@@ -8585,7 +8628,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8585
8628
  else {
8586
8629
  scope = scope?.createChildScope(64);
8587
8630
  const modifierFlags = 4 | 131072 | 8;
8588
- body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, 16, void 0, void 0);
8631
+ body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, void 0, void 0, 16);
8589
8632
  switch (parser.getToken()) {
8590
8633
  case 69271571:
8591
8634
  if ((parser.flags & 1) === 0) {
@@ -8604,8 +8647,11 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8604
8647
  parser.flags |= 1024;
8605
8648
  break;
8606
8649
  }
8607
- if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0)
8608
- parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8650
+ if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0) {
8651
+ if (parser.getToken() !== 8673330 || origin !== 32) {
8652
+ parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8653
+ }
8654
+ }
8609
8655
  if ((parser.getToken() & 33619968) === 33619968)
8610
8656
  parser.report(127);
8611
8657
  }
@@ -8623,6 +8669,7 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
8623
8669
  consume(parser, context, 67174411);
8624
8670
  parser.flags = (parser.flags | 128) ^ 128;
8625
8671
  parser.strictReservedRange = null;
8672
+ parser.firstAwaitLocation = null;
8626
8673
  const params = [];
8627
8674
  if (consumeOpt(parser, context, 16))
8628
8675
  return params;
@@ -8642,17 +8689,17 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
8642
8689
  parser.flags |= 512;
8643
8690
  }
8644
8691
  }
8645
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8692
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8646
8693
  }
8647
8694
  else {
8648
8695
  if (token === 2162700) {
8649
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8696
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8650
8697
  }
8651
8698
  else if (token === 69271571) {
8652
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8699
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8653
8700
  }
8654
8701
  else if (token === 14) {
8655
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 0, inGroup, 1);
8702
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, inGroup, 1);
8656
8703
  }
8657
8704
  else {
8658
8705
  parser.report(30, KeywordDescTable[token & 255]);
@@ -8776,9 +8823,11 @@ function parseAsyncArrowAfterIdent(parser, context, privateScope, canAssign, sta
8776
8823
  }
8777
8824
  return parseArrowFromIdentifier(parser, (context & -524289) | 2048, privateScope, parser.tokenValue, parseIdentifier(parser, context), 0, canAssign, 1, start);
8778
8825
  }
8779
- function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, origin, flags, start) {
8826
+ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, flags, start) {
8780
8827
  nextToken(parser, context | 32);
8781
8828
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8829
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8830
+ parser.firstAwaitLocation = null;
8782
8831
  context = (context | 131072) ^ 131072;
8783
8832
  if (consumeOpt(parser, context, 16)) {
8784
8833
  if (parser.getToken() === 10) {
@@ -8792,6 +8841,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8792
8841
  else {
8793
8842
  parser.assignable = 2;
8794
8843
  }
8844
+ if (previousFirstAwaitLocation)
8845
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8795
8846
  return parser.finishNode({
8796
8847
  type: 'CallExpression',
8797
8848
  callee,
@@ -8807,10 +8858,10 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8807
8858
  (256 | 128);
8808
8859
  const params = [];
8809
8860
  while (parser.getToken() !== 16) {
8810
- const { tokenStart } = parser;
8861
+ const { tokenStart, currentLocation } = parser;
8811
8862
  const token = parser.getToken();
8812
8863
  if (token & 143360) {
8813
- scope?.addBlockName(context, parser.tokenValue, kind, 0);
8864
+ scope?.addBlockName(context, parser.tokenValue, kind, tokenStart, currentLocation);
8814
8865
  if ((token & 537079808) === 537079808) {
8815
8866
  parser.flags |= 512;
8816
8867
  }
@@ -8840,8 +8891,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8840
8891
  else if (token & 2097152) {
8841
8892
  expr =
8842
8893
  token === 2162700
8843
- ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin)
8844
- : parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin);
8894
+ ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind)
8895
+ : parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind);
8845
8896
  destructible |= parser.destructible;
8846
8897
  isNonSimpleParameterList = 1;
8847
8898
  if (parser.getToken() !== 16 && parser.getToken() !== 18) {
@@ -8858,7 +8909,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8858
8909
  }
8859
8910
  }
8860
8911
  else if (token === 14) {
8861
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 1, 1, 0);
8912
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 1, 1, 0);
8862
8913
  destructible |=
8863
8914
  (parser.getToken() === 16 ? 0 : 16) | parser.destructible;
8864
8915
  isNonSimpleParameterList = 1;
@@ -8879,6 +8930,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8879
8930
  else {
8880
8931
  parser.assignable = 2;
8881
8932
  }
8933
+ if (previousFirstAwaitLocation)
8934
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8882
8935
  return parser.finishNode({
8883
8936
  type: 'CallExpression',
8884
8937
  callee,
@@ -8902,8 +8955,12 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8902
8955
  parser.report(27);
8903
8956
  if (parser.flags & 1 || flags & 1)
8904
8957
  parser.report(48);
8905
- if (destructible & 128)
8958
+ if (destructible & 128) {
8959
+ const loc = parser.firstAwaitLocation;
8960
+ if (loc)
8961
+ throw new ParseError(loc.start, loc.end, 31);
8906
8962
  parser.report(31);
8963
+ }
8907
8964
  if (context & (1 | 1024) && destructible & 256)
8908
8965
  parser.report(32);
8909
8966
  if (isNonSimpleParameterList)
@@ -8922,6 +8979,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8922
8979
  else {
8923
8980
  parser.assignable = 2;
8924
8981
  }
8982
+ if (previousFirstAwaitLocation)
8983
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8925
8984
  return parser.finishNode({
8926
8985
  type: 'CallExpression',
8927
8986
  callee,
@@ -8959,7 +9018,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8959
9018
  consume(parser, context, 86094);
8960
9019
  let id = null;
8961
9020
  let superClass = null;
8962
- const { tokenValue } = parser;
9021
+ const { tokenValue, tokenStart, currentLocation } = parser;
8963
9022
  if (parser.getToken() & 4096 && parser.getToken() !== 20565) {
8964
9023
  if (isStrictReservedWord(parser, context, parser.getToken())) {
8965
9024
  parser.report(120);
@@ -8968,7 +9027,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8968
9027
  parser.report(121);
8969
9028
  }
8970
9029
  if (scope) {
8971
- scope.addBlockName(context, tokenValue, 32, 0);
9030
+ scope.addBlockName(context, tokenValue, 32, tokenStart, currentLocation);
8972
9031
  if (flags) {
8973
9032
  if (flags & 2) {
8974
9033
  parser.declareUnboundVariable(tokenValue);
@@ -8989,7 +9048,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8989
9048
  else {
8990
9049
  inheritedContext = (inheritedContext | 512) ^ 512;
8991
9050
  }
8992
- const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 8, 0);
9051
+ const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 0, 8);
8993
9052
  return parser.finishNode({
8994
9053
  type: 'ClassDeclaration',
8995
9054
  id,
@@ -9020,7 +9079,7 @@ function parseClassExpression(parser, context, privateScope, inGroup, start) {
9020
9079
  else {
9021
9080
  inheritedContext = (inheritedContext | 512) ^ 512;
9022
9081
  }
9023
- const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, 0, inGroup);
9082
+ const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, inGroup);
9024
9083
  parser.assignable = 2;
9025
9084
  return parser.finishNode({
9026
9085
  type: 'ClassExpression',
@@ -9087,7 +9146,7 @@ function parseDecorator(parser, context, privateScope) {
9087
9146
  expression,
9088
9147
  }, start);
9089
9148
  }
9090
- function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, origin, inGroup) {
9149
+ function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, inGroup, origin = 0) {
9091
9150
  const { tokenStart } = parser;
9092
9151
  const privateScope = parser.createPrivateScopeIfLexical(parentScope);
9093
9152
  consume(parser, context | 32, 2162700);
@@ -9327,22 +9386,22 @@ function parsePropertyDefinition(parser, context, privateScope, key, state, deco
9327
9386
  ...(parser.features & 1 ? { decorators } : null),
9328
9387
  }, start);
9329
9388
  }
9330
- function parseBindingPattern(parser, context, scope, privateScope, type, origin) {
9389
+ function parseBindingPattern(parser, context, scope, privateScope, kind, origin = 0) {
9331
9390
  if (parser.getToken() & 143360 ||
9332
9391
  ((context & 1) === 0 && parser.getToken() === -2147483526))
9333
- return parseAndClassifyIdentifier(parser, context, scope, type, origin);
9392
+ return parseAndClassifyIdentifier(parser, context, scope, kind, origin);
9334
9393
  if ((parser.getToken() & 2097152) !== 2097152)
9335
9394
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
9336
9395
  const left = parser.getToken() === 69271571
9337
- ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, type, origin)
9338
- : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, type, origin);
9396
+ ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin)
9397
+ : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin);
9339
9398
  if (parser.destructible & 16)
9340
9399
  parser.report(50);
9341
9400
  if (parser.destructible & 32)
9342
9401
  parser.report(50);
9343
9402
  return left;
9344
9403
  }
9345
- function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
9404
+ function parseAndClassifyIdentifier(parser, context, scope, kind, origin = 0) {
9346
9405
  const token = parser.getToken();
9347
9406
  if (context & 1) {
9348
9407
  if ((token & 537079808) === 537079808) {
@@ -9371,13 +9430,13 @@ function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
9371
9430
  if (context & 2)
9372
9431
  parser.report(112);
9373
9432
  }
9374
- const { tokenValue, tokenStart: start } = parser;
9433
+ const { tokenValue, tokenStart, currentLocation } = parser;
9375
9434
  nextToken(parser, context);
9376
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
9435
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
9377
9436
  return parser.finishNode({
9378
9437
  type: 'Identifier',
9379
9438
  name: tokenValue,
9380
- }, start);
9439
+ }, tokenStart);
9381
9440
  }
9382
9441
  function parseJSXRootElementOrFragment(parser, context, privateScope, inJSXChild, start) {
9383
9442
  if (!inJSXChild)
@@ -9470,7 +9529,7 @@ function parseJSXChildrenAndClosingFragment(parser, context, privateScope, inJSX
9470
9529
  }
9471
9530
  function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild) {
9472
9531
  if (parser.getToken() === 138)
9473
- return parseJSXText(parser, context);
9532
+ return parseJSXText(parser);
9474
9533
  if (parser.getToken() === 2162700)
9475
9534
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9476
9535
  if (parser.getToken() === 8456256) {
@@ -9484,7 +9543,7 @@ function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild
9484
9543
  }
9485
9544
  function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChild) {
9486
9545
  if (parser.getToken() === 138)
9487
- return parseJSXText(parser, context);
9546
+ return parseJSXText(parser);
9488
9547
  if (parser.getToken() === 2162700)
9489
9548
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9490
9549
  if (parser.getToken() === 8456256) {
@@ -9496,9 +9555,9 @@ function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChil
9496
9555
  }
9497
9556
  parser.report(0);
9498
9557
  }
9499
- function parseJSXText(parser, context) {
9558
+ function parseJSXText(parser) {
9500
9559
  const start = parser.tokenStart;
9501
- nextToken(parser, context);
9560
+ nextJSXToken(parser);
9502
9561
  const node = {
9503
9562
  type: 'JSXText',
9504
9563
  value: parser.tokenValue,
@@ -9516,7 +9575,7 @@ function parseJSXOpeningElementOrSelfCloseElement(parser, context, privateScope,
9516
9575
  const attributes = parseJSXAttributes(parser, context, privateScope);
9517
9576
  const selfClosing = parser.getToken() === 8457014;
9518
9577
  if (selfClosing)
9519
- consume(parser, context, 8457014);
9578
+ consume(parser, context | 1048576, 8457014);
9520
9579
  if (parser.getToken() !== 8390721) {
9521
9580
  parser.report(25, KeywordDescTable[8390721 & 255]);
9522
9581
  }
@@ -9667,7 +9726,7 @@ function parseJSXIdentifier(parser, context) {
9667
9726
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
9668
9727
  }
9669
9728
  const { tokenValue } = parser;
9670
- nextToken(parser, context);
9729
+ nextToken(parser, context | 1048576);
9671
9730
  return parser.finishNode({
9672
9731
  type: 'JSXIdentifier',
9673
9732
  name: tokenValue,