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.
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.meriyah = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- var version$1 = "7.3.0";
7
+ var version$1 = "7.3.2";
8
8
  var packageJson = {
9
9
  version: version$1};
10
10
 
@@ -97,7 +97,7 @@
97
97
  0,
98
98
  16384,
99
99
  0,
100
- 0,
100
+ 16384,
101
101
  0,
102
102
  0,
103
103
  1 | 2 | 64,
@@ -160,7 +160,7 @@
160
160
  1 | 2 | 4,
161
161
  16384,
162
162
  0,
163
- 0,
163
+ 16384,
164
164
  0,
165
165
  0
166
166
  ];
@@ -794,6 +794,8 @@
794
794
  [177]: "'import.meta' must not contain escaped characters",
795
795
  [178]: 'cannot use "await" as identifier inside an async function',
796
796
  [179]: 'cannot use "await" in static blocks',
797
+ [180]: "Unexpected token `}`. Did you mean `}` or `{'}'}`?",
798
+ [181]: "Unexpected token `>`. Did you mean `>` or `{'>'}`?",
797
799
  };
798
800
  class ParseError extends SyntaxError {
799
801
  start;
@@ -2044,6 +2046,9 @@
2044
2046
  }
2045
2047
  case 8390721: {
2046
2048
  advanceChar(parser);
2049
+ if (context & 1048576) {
2050
+ return 8390721;
2051
+ }
2047
2052
  const ch = parser.currentChar;
2048
2053
  if (ch === 61) {
2049
2054
  advanceChar(parser);
@@ -2251,6 +2256,9 @@
2251
2256
  if (t === 209006) {
2252
2257
  if (context & (2048 | 2))
2253
2258
  parser.report(112);
2259
+ if ((parser.destructible & 128) === 0) {
2260
+ parser.firstAwaitLocation ??= { start: parser.tokenStart, end: parser.currentLocation };
2261
+ }
2254
2262
  parser.destructible |= 128;
2255
2263
  }
2256
2264
  if (t === 241771 && context & 1024)
@@ -4532,6 +4540,12 @@
4532
4540
  parser.setToken(2162700);
4533
4541
  return;
4534
4542
  }
4543
+ if (parser.currentChar === 125) {
4544
+ parser.report(180);
4545
+ }
4546
+ if (parser.currentChar === 62) {
4547
+ parser.report(181);
4548
+ }
4535
4549
  let state = 0;
4536
4550
  while (parser.index < parser.end) {
4537
4551
  const type = CharTypes[parser.source.charCodeAt(parser.index)];
@@ -4558,7 +4572,7 @@
4558
4572
  parser.setToken(138);
4559
4573
  }
4560
4574
  function rescanJSXIdentifier(parser) {
4561
- if ((parser.getToken() & 143360) === 143360) {
4575
+ if (parser.getToken() & 143360) {
4562
4576
  const { index } = parser;
4563
4577
  let char = parser.currentChar;
4564
4578
  while (CharTypes[char] & (32768 | 2)) {
@@ -4663,18 +4677,18 @@
4663
4677
  createChildScope(type) {
4664
4678
  return new Scope(this.parser, type, this);
4665
4679
  }
4666
- addVarOrBlock(context, name, kind, origin) {
4680
+ addVarOrBlock(context, name, kind, tokenStart, tokenEnd, origin) {
4667
4681
  if (kind & 4) {
4668
- this.addVarName(context, name, kind);
4682
+ this.addVarName(context, name, kind, tokenStart, tokenEnd);
4669
4683
  }
4670
4684
  else {
4671
- this.addBlockName(context, name, kind, origin);
4685
+ this.addBlockName(context, name, kind, tokenStart, tokenEnd, origin);
4672
4686
  }
4673
4687
  if (origin & 64) {
4674
4688
  this.parser.declareUnboundVariable(name);
4675
4689
  }
4676
4690
  }
4677
- addVarName(context, name, kind) {
4691
+ addVarName(context, name, kind, tokenStart, tokenEnd) {
4678
4692
  const { parser } = this;
4679
4693
  let currentScope = this;
4680
4694
  while (currentScope && (currentScope.type & 128) === 0) {
@@ -4686,17 +4700,17 @@
4686
4700
  ((kind & 128 && value & 68) ||
4687
4701
  (value & 128 && kind & 68))) ;
4688
4702
  else {
4689
- parser.report(147, name);
4703
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4690
4704
  }
4691
4705
  }
4692
4706
  if (currentScope === this) {
4693
4707
  if (value && value & 1 && kind & 1) {
4694
- currentScope.recordScopeError(147, name);
4708
+ currentScope.recordScopeError(147, tokenStart, tokenEnd, name);
4695
4709
  }
4696
4710
  }
4697
4711
  if (value &&
4698
4712
  (value & 256 || (value & 512 && !parser.options.webcompat))) {
4699
- parser.report(147, name);
4713
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4700
4714
  }
4701
4715
  currentScope.variableBindings.set(name, kind);
4702
4716
  currentScope = currentScope.parent;
@@ -4705,12 +4719,12 @@
4705
4719
  hasVariable(name) {
4706
4720
  return this.variableBindings.has(name);
4707
4721
  }
4708
- addBlockName(context, name, kind, origin) {
4722
+ addBlockName(context, name, kind, tokenStart, tokenEnd, origin = 0) {
4709
4723
  const { parser } = this;
4710
4724
  const value = this.variableBindings.get(name);
4711
4725
  if (value && (value & 2) === 0) {
4712
4726
  if (kind & 1) {
4713
- this.recordScopeError(147, name);
4727
+ this.recordScopeError(147, tokenStart, tokenEnd, name);
4714
4728
  }
4715
4729
  else if (parser.options.webcompat &&
4716
4730
  (context & 1) === 0 &&
@@ -4718,31 +4732,31 @@
4718
4732
  value === 64 &&
4719
4733
  kind === 64) ;
4720
4734
  else {
4721
- parser.report(147, name);
4735
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4722
4736
  }
4723
4737
  }
4724
4738
  if (this.type & 64 &&
4725
4739
  this.parent?.hasVariable(name) &&
4726
4740
  (this.parent.variableBindings.get(name) & 2) === 0) {
4727
- parser.report(147, name);
4741
+ throw new ParseError(tokenStart, tokenEnd, 147, name);
4728
4742
  }
4729
4743
  if (this.type & 512 && value && (value & 2) === 0) {
4730
4744
  if (kind & 1) {
4731
- this.recordScopeError(147, name);
4745
+ this.recordScopeError(147, tokenStart, tokenEnd, name);
4732
4746
  }
4733
4747
  }
4734
4748
  if (this.type & 32) {
4735
4749
  if (this.parent.variableBindings.get(name) & 768)
4736
- parser.report(161, name);
4750
+ throw new ParseError(tokenStart, tokenEnd, 161, name);
4737
4751
  }
4738
4752
  this.variableBindings.set(name, kind);
4739
4753
  }
4740
- recordScopeError(type, ...params) {
4741
- this.scopeError = {
4754
+ recordScopeError(type, tokenStart, tokenEnd, ...params) {
4755
+ this.scopeError ??= {
4742
4756
  type,
4743
4757
  params,
4744
- start: this.parser.tokenStart,
4745
- end: this.parser.currentLocation,
4758
+ start: tokenStart,
4759
+ end: tokenEnd,
4746
4760
  };
4747
4761
  }
4748
4762
  reportScopeError() {
@@ -4753,9 +4767,9 @@
4753
4767
  throw new ParseError(scopeError.start, scopeError.end, scopeError.type, ...scopeError.params);
4754
4768
  }
4755
4769
  }
4756
- function createArrowHeadParsingScope(parser, context, value) {
4770
+ function createArrowHeadParsingScope(parser, context, value, tokenStart, tokenEnd) {
4757
4771
  const scope = parser.createScope().createChildScope(512);
4758
- scope.addBlockName(context, value, 1, 0);
4772
+ scope.addBlockName(context, value, 1, tokenStart, tokenEnd);
4759
4773
  return scope;
4760
4774
  }
4761
4775
 
@@ -4785,6 +4799,7 @@
4785
4799
  assignable = 0;
4786
4800
  destructible = 0;
4787
4801
  strictReservedRange = null;
4802
+ firstAwaitLocation = null;
4788
4803
  leadingDecorators = { decorators: [] };
4789
4804
  constructor(source, rawOptions = {}) {
4790
4805
  this.source = source;
@@ -4993,7 +5008,7 @@
4993
5008
  statements.push(parseDirective(parser, context, expr, token, tokenStart));
4994
5009
  }
4995
5010
  while (parser.getToken() !== 1048576) {
4996
- statements.push(parseStatementListItem(parser, context, scope, undefined, 4, {}));
5011
+ statements.push(parseStatementListItem(parser, context, scope, undefined, {}, 4));
4997
5012
  }
4998
5013
  return statements;
4999
5014
  }
@@ -5029,18 +5044,18 @@
5029
5044
  moduleItem = parseImportDeclaration(parser, context, scope);
5030
5045
  break;
5031
5046
  default:
5032
- moduleItem = parseStatementListItem(parser, context, scope, undefined, 4, {});
5047
+ moduleItem = parseStatementListItem(parser, context, scope, undefined, {}, 4);
5033
5048
  }
5034
5049
  return moduleItem;
5035
5050
  }
5036
- function parseStatementListItem(parser, context, scope, privateScope, origin, labels) {
5051
+ function parseStatementListItem(parser, context, scope, privateScope, labels, origin = 2) {
5037
5052
  const start = parser.tokenStart;
5038
5053
  if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
5039
5054
  parser.report(172);
5040
5055
  }
5041
5056
  switch (parser.getToken()) {
5042
5057
  case 86104:
5043
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 0, start);
5058
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 0, start, origin);
5044
5059
  case 133:
5045
5060
  if (!(parser.features & 1)) {
5046
5061
  parser.report(30, '@');
@@ -5048,17 +5063,17 @@
5048
5063
  case 86094:
5049
5064
  return parseClassDeclaration(parser, context, scope, privateScope, 0);
5050
5065
  case 86090:
5051
- return parseLexicalDeclaration(parser, context, scope, privateScope, 16, 0);
5066
+ return parseLexicalDeclaration(parser, context, scope, privateScope, 16);
5052
5067
  case 241737:
5053
5068
  return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin);
5054
5069
  case 209013:
5055
- return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5070
+ return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5056
5071
  case 209006:
5057
5072
  if ((context & 2048 || (context & 2 && context & 8)) &&
5058
5073
  nextTokenIsUsingOnSameLine(parser)) {
5059
- return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5074
+ return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
5060
5075
  }
5061
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5076
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5062
5077
  case 20564:
5063
5078
  parser.report(103, 'export');
5064
5079
  case 86106:
@@ -5072,15 +5087,15 @@
5072
5087
  parser.report(103, 'import');
5073
5088
  }
5074
5089
  case 209005:
5075
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 1);
5090
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 1, origin);
5076
5091
  default:
5077
- return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5092
+ return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
5078
5093
  }
5079
5094
  }
5080
- function parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5095
+ function parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin = 0) {
5081
5096
  switch (parser.getToken()) {
5082
5097
  case 86088:
5083
- return parseVariableStatement(parser, context, scope, privateScope, 0);
5098
+ return parseVariableStatement(parser, context, scope, privateScope);
5084
5099
  case 20572:
5085
5100
  return parseReturnStatement(parser, context, privateScope);
5086
5101
  case 20569:
@@ -5110,7 +5125,7 @@
5110
5125
  case 20560:
5111
5126
  return parseDebuggerStatement(parser, context);
5112
5127
  case 209005:
5113
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 0);
5128
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 0, origin);
5114
5129
  case 20557:
5115
5130
  parser.report(164);
5116
5131
  case 20566:
@@ -5124,10 +5139,10 @@
5124
5139
  case 86094:
5125
5140
  parser.report(79);
5126
5141
  default:
5127
- return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5142
+ return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5128
5143
  }
5129
5144
  }
5130
- function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5145
+ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5131
5146
  const { tokenValue, tokenStart } = parser;
5132
5147
  const token = parser.getToken();
5133
5148
  let expr;
@@ -5142,11 +5157,11 @@
5142
5157
  default:
5143
5158
  expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart);
5144
5159
  }
5145
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, expr, token, tokenValue, tokenStart);
5160
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, expr, token, tokenValue, tokenStart, origin);
5146
5161
  }
5147
- function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart) {
5162
+ function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart, origin) {
5148
5163
  if (token & 143360 && parser.getToken() === 21) {
5149
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart);
5164
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart, origin);
5150
5165
  }
5151
5166
  let expression = parseMemberOrUpdateExpression(parser, context, privateScope, initialExpression, 0, 0, tokenStart);
5152
5167
  expression = parseAssignmentExpression(parser, context, privateScope, 0, 0, tokenStart, expression);
@@ -5159,7 +5174,7 @@
5159
5174
  const body = [];
5160
5175
  consume(parser, context | 32, 2162700);
5161
5176
  while (parser.getToken() !== 1074790415) {
5162
- body.push(parseStatementListItem(parser, context, scope, privateScope, 2, { $: labels }));
5177
+ body.push(parseStatementListItem(parser, context, scope, privateScope, { $: labels }));
5163
5178
  }
5164
5179
  consume(parser, context | 32, 1074790415);
5165
5180
  return parser.finishNode({
@@ -5188,7 +5203,7 @@
5188
5203
  expression,
5189
5204
  }, start);
5190
5205
  }
5191
- function parseLabelledStatement(parser, context, scope, privateScope, origin, labels, value, expr, token, allowFuncDecl, start) {
5206
+ function parseLabelledStatement(parser, context, scope, privateScope, labels, value, expr, token, allowFuncDecl, start, origin) {
5192
5207
  validateBindingIdentifier(parser, context, 0, token, 1);
5193
5208
  validateAndDeclareLabel(parser, labels, value);
5194
5209
  nextToken(parser, context | 32);
@@ -5196,27 +5211,27 @@
5196
5211
  (context & 1) === 0 &&
5197
5212
  parser.options.webcompat &&
5198
5213
  parser.getToken() === 86104
5199
- ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, origin, 0, 0, 0, parser.tokenStart)
5200
- : parseStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl);
5214
+ ? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, parser.tokenStart, origin)
5215
+ : parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
5201
5216
  return parser.finishNode({
5202
5217
  type: 'LabeledStatement',
5203
5218
  label: expr,
5204
5219
  body,
5205
5220
  }, start);
5206
5221
  }
5207
- function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, allowFuncDecl) {
5222
+ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
5208
5223
  const { tokenValue, tokenStart: start } = parser;
5209
5224
  const token = parser.getToken();
5210
5225
  let expr = parseIdentifier(parser, context);
5211
5226
  if (parser.getToken() === 21) {
5212
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, expr, token, 1, start);
5227
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, 1, start, origin);
5213
5228
  }
5214
5229
  const asyncNewLine = parser.flags & 1;
5215
5230
  if (!asyncNewLine) {
5216
5231
  if (parser.getToken() === 86104) {
5217
5232
  if (!allowFuncDecl)
5218
5233
  parser.report(125);
5219
- return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 1, start);
5234
+ return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 1, start, origin);
5220
5235
  }
5221
5236
  if (isValidIdentifier(context, parser.getToken())) {
5222
5237
  expr = parseAsyncArrowAfterIdent(parser, context, privateScope, 1, start);
@@ -5226,7 +5241,7 @@
5226
5241
  }
5227
5242
  }
5228
5243
  if (parser.getToken() === 67174411) {
5229
- expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, 0, asyncNewLine, start);
5244
+ expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, asyncNewLine, start);
5230
5245
  }
5231
5246
  else {
5232
5247
  if (parser.getToken() === 10) {
@@ -5312,8 +5327,8 @@
5312
5327
  return context & 1 ||
5313
5328
  !parser.options.webcompat ||
5314
5329
  parser.getToken() !== 86104
5315
- ? parseStatement(parser, context, scope, privateScope, 0, { $: labels }, 0)
5316
- : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, 0, tokenStart);
5330
+ ? parseStatement(parser, context, scope, privateScope, { $: labels }, 0)
5331
+ : parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, tokenStart);
5317
5332
  }
5318
5333
  function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5319
5334
  const start = parser.tokenStart;
@@ -5342,7 +5357,7 @@
5342
5357
  while (parser.getToken() !== 20556 &&
5343
5358
  parser.getToken() !== 1074790415 &&
5344
5359
  parser.getToken() !== 20561) {
5345
- const statement = parseStatementListItem(parser, context | 4, scope, privateScope, 2, {
5360
+ const statement = parseStatementListItem(parser, context | 4, scope, privateScope, {
5346
5361
  $: labels,
5347
5362
  });
5348
5363
  if (statement.type === 'VariableDeclaration' &&
@@ -5378,7 +5393,7 @@
5378
5393
  }, start);
5379
5394
  }
5380
5395
  function parseIterationStatementBody(parser, context, scope, privateScope, labels) {
5381
- return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, 0, { loop: 1, $: labels }, 0);
5396
+ return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, { loop: 1, $: labels }, 0);
5382
5397
  }
5383
5398
  function parseContinueStatement(parser, context, labels) {
5384
5399
  if ((context & 128) === 0)
@@ -5425,7 +5440,7 @@
5425
5440
  consume(parser, context | 32, 67174411);
5426
5441
  const object = parseExpressions(parser, context, privateScope, 0, 1, parser.tokenStart);
5427
5442
  consume(parser, context | 32, 16);
5428
- const body = parseStatement(parser, context, scope, privateScope, 2, labels, 0);
5443
+ const body = parseStatement(parser, context, scope, privateScope, labels, 0, 2);
5429
5444
  return parser.finishNode({
5430
5445
  type: 'WithStatement',
5431
5446
  object,
@@ -5472,7 +5487,7 @@
5472
5487
  scope = scope?.createChildScope(4);
5473
5488
  param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
5474
5489
  ? 256
5475
- : 512, 0);
5490
+ : 512);
5476
5491
  if (parser.getToken() === 18) {
5477
5492
  parser.report(86);
5478
5493
  }
@@ -5516,12 +5531,12 @@
5516
5531
  }, start);
5517
5532
  }
5518
5533
  function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin) {
5519
- const { tokenValue, tokenStart } = parser;
5534
+ const { tokenValue, tokenStart, currentLocation } = parser;
5520
5535
  const token = parser.getToken();
5521
5536
  let expr = parseIdentifier(parser, context);
5522
5537
  if (parser.getToken() & (143360 | 2097152) &&
5523
5538
  (parser.getToken() & 20480) !== 20480) {
5524
- const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8, 0);
5539
+ const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8);
5525
5540
  matchOrInsertSemicolon(parser, context | 32);
5526
5541
  return parser.finishNode({
5527
5542
  type: 'VariableDeclaration',
@@ -5533,12 +5548,12 @@
5533
5548
  if (context & 1)
5534
5549
  parser.report(85);
5535
5550
  if (parser.getToken() === 21) {
5536
- return parseLabelledStatement(parser, context, scope, privateScope, origin, {}, tokenValue, expr, token, 0, tokenStart);
5551
+ return parseLabelledStatement(parser, context, scope, privateScope, {}, tokenValue, expr, token, 0, tokenStart, origin);
5537
5552
  }
5538
5553
  if (parser.getToken() === 10) {
5539
5554
  let scope = void 0;
5540
5555
  if (parser.options.lexical)
5541
- scope = createArrowHeadParsingScope(parser, context, tokenValue);
5556
+ scope = createArrowHeadParsingScope(parser, context, tokenValue, tokenStart, currentLocation);
5542
5557
  parser.flags = (parser.flags | 128) ^ 128;
5543
5558
  expr = parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, tokenStart);
5544
5559
  }
@@ -5587,20 +5602,23 @@
5587
5602
  function isResourceBindingStart(token) {
5588
5603
  return (token & 143360) === 143360 && (token & 20480) !== 20480;
5589
5604
  }
5590
- function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5605
+ function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5591
5606
  const { tokenStart, tokenValue } = parser;
5592
5607
  const token = parser.getToken();
5593
5608
  const expression = parseIdentifier(parser, context);
5594
5609
  if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
5595
- if (origin & 4 && context & 8 && (context & 2) === 0) {
5610
+ if (origin & 4 &&
5611
+ context & 8 &&
5612
+ (context & 2) === 0 &&
5613
+ (context & 4096) === 0) {
5596
5614
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5597
5615
  }
5598
5616
  return parseLexicalDeclaration(parser, context, scope, privateScope, 16, origin, 'using', tokenStart, 1);
5599
5617
  }
5600
5618
  parser.assignable = 1;
5601
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 1, expression, token, tokenValue, tokenStart);
5619
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 1, expression, token, tokenValue, tokenStart, origin);
5602
5620
  }
5603
- function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5621
+ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
5604
5622
  const start = parser.tokenStart;
5605
5623
  if (context & 524288)
5606
5624
  parser.report(179);
@@ -5624,9 +5642,9 @@
5624
5642
  type: 'AwaitExpression',
5625
5643
  argument,
5626
5644
  }, start);
5627
- return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 0, expression, 1048576, '', start);
5645
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 0, expression, 1048576, '', start, origin);
5628
5646
  }
5629
- function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5647
+ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin = 0, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5630
5648
  const start = declarationStart;
5631
5649
  if (!keywordConsumed)
5632
5650
  nextToken(parser, context);
@@ -5638,7 +5656,7 @@
5638
5656
  declarations,
5639
5657
  }, start);
5640
5658
  }
5641
- function parseVariableStatement(parser, context, scope, privateScope, origin) {
5659
+ function parseVariableStatement(parser, context, scope, privateScope, origin = 0) {
5642
5660
  const start = parser.tokenStart;
5643
5661
  nextToken(parser, context);
5644
5662
  const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 4, origin);
@@ -5649,7 +5667,7 @@
5649
5667
  declarations,
5650
5668
  }, start);
5651
5669
  }
5652
- function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin, declarationKind) {
5670
+ function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin = 0, declarationKind) {
5653
5671
  let bindingCount = 1;
5654
5672
  const firstDeclaration = parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind);
5655
5673
  const list = [firstDeclaration];
@@ -5680,11 +5698,14 @@
5680
5698
  const id = parseBindingPattern(parser, context, scope, privateScope, kind, origin);
5681
5699
  if (parser.getToken() === 1077936155) {
5682
5700
  nextToken(parser, context | 32);
5683
- init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5701
+ init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart, origin);
5684
5702
  if (origin & 32) {
5685
5703
  if (parser.getToken() === 471156 ||
5686
5704
  (parser.getToken() === 8673330 &&
5687
- (token & 2097152 || (kind & 4) === 0 || context & 1))) {
5705
+ (token & 2097152 ||
5706
+ (kind & 4) === 0 ||
5707
+ context & 1 ||
5708
+ !parser.options.webcompat))) {
5688
5709
  throw new ParseError(tokenStart, parser.currentLocation, 60, parser.getToken() === 471156 ? 'of' : 'in');
5689
5710
  }
5690
5711
  }
@@ -5751,6 +5772,7 @@
5751
5772
  }
5752
5773
  else if (parser.getToken() === 471156) {
5753
5774
  const ofStart = parser.tokenStart;
5775
+ const ofEnd = parser.currentLocation;
5754
5776
  const ofToken = parser.getToken();
5755
5777
  const ofValue = parser.tokenValue;
5756
5778
  const ofIdentifier = parseIdentifier(parser, context);
@@ -5766,7 +5788,7 @@
5766
5788
  else {
5767
5789
  resourceDeclarationKind = 'using';
5768
5790
  validateBindingIdentifier(parser, context, 16, ofToken, 0);
5769
- scope?.addBlockName(context, ofValue, 16, 32);
5791
+ scope?.addBlockName(context, ofValue, 16, ofStart, ofEnd, 32);
5770
5792
  let declarationInitializer = null;
5771
5793
  if (parser.getToken() === 1077936155) {
5772
5794
  nextToken(parser, context | 32);
@@ -5957,7 +5979,7 @@
5957
5979
  parser.report(120);
5958
5980
  if ((parser.getToken() & 537079808) === 537079808)
5959
5981
  parser.report(121);
5960
- scope?.addBlockName(context, parser.tokenValue, 8, 0);
5982
+ scope?.addBlockName(context, parser.tokenValue, 8, parser.tokenStart, parser.currentLocation);
5961
5983
  return parseIdentifier(parser, context);
5962
5984
  }
5963
5985
  function parseImportDeclaration(parser, context, scope) {
@@ -5974,7 +5996,7 @@
5974
5996
  else {
5975
5997
  if (parser.getToken() & 143360) {
5976
5998
  const token = parser.getToken();
5977
- const { tokenValue } = parser;
5999
+ const { tokenValue, tokenStart: start, currentLocation } = parser;
5978
6000
  const isPhaseDefer = parser.features & 2 && (token & -2147483648) === 0 && tokenValue == 'defer';
5979
6001
  const isPhaseSource = parser.features & 4 && (token & -2147483648) === 0 && tokenValue == 'source';
5980
6002
  if (isPhaseDefer || isPhaseSource) {
@@ -5985,7 +6007,7 @@
5985
6007
  specifiers = [parseImportNamespaceSpecifier(parser, context, scope)];
5986
6008
  }
5987
6009
  else if (parser.getToken() === 209011 || parser.getToken() === 18) {
5988
- scope?.addBlockName(context, tokenValue, 8, 0);
6010
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
5989
6011
  specifiers = [
5990
6012
  parser.finishNode({
5991
6013
  type: 'ImportDefaultSpecifier',
@@ -6000,10 +6022,11 @@
6000
6022
  else if (parser.getToken() === 209011) {
6001
6023
  const fromToken = parser.getToken();
6002
6024
  const fromStart = parser.tokenStart;
6025
+ const fromEnd = parser.currentLocation;
6003
6026
  const fromLocal = parseIdentifier(parser, context);
6004
6027
  if (parser.getToken() === 209011) {
6005
6028
  validateBindingIdentifier(parser, context, 16, fromToken, 0);
6006
- scope?.addBlockName(context, fromLocal.name, 8, 0);
6029
+ scope?.addBlockName(context, fromLocal.name, 8, fromStart, fromEnd);
6007
6030
  phase = 'source';
6008
6031
  specifiers = [
6009
6032
  parser.finishNode({
@@ -6013,7 +6036,7 @@
6013
6036
  ];
6014
6037
  }
6015
6038
  else {
6016
- scope?.addBlockName(context, tokenValue, 8, 0);
6039
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
6017
6040
  specifiers = [
6018
6041
  parser.finishNode({
6019
6042
  type: 'ImportDefaultSpecifier',
@@ -6038,7 +6061,7 @@
6038
6061
  ];
6039
6062
  }
6040
6063
  else if (parser.getToken() === 18) {
6041
- scope?.addBlockName(context, tokenValue, 8, 0);
6064
+ scope?.addBlockName(context, tokenValue, 8, start, currentLocation);
6042
6065
  specifiers = [
6043
6066
  parser.finishNode({
6044
6067
  type: 'ImportDefaultSpecifier',
@@ -6123,7 +6146,8 @@
6123
6146
  function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers) {
6124
6147
  nextToken(parser, context);
6125
6148
  while (parser.getToken() & 143360 || parser.getToken() === 134283267) {
6126
- let { tokenValue, tokenStart } = parser;
6149
+ let { tokenValue, tokenStart, currentLocation } = parser;
6150
+ const start = tokenStart;
6127
6151
  const token = parser.getToken();
6128
6152
  const imported = parseModuleExportName(parser, context);
6129
6153
  let local;
@@ -6136,6 +6160,8 @@
6136
6160
  validateBindingIdentifier(parser, context, 16, parser.getToken(), 0);
6137
6161
  }
6138
6162
  tokenValue = parser.tokenValue;
6163
+ tokenStart = parser.tokenStart;
6164
+ currentLocation = parser.currentLocation;
6139
6165
  local = parseIdentifier(parser, context);
6140
6166
  }
6141
6167
  else if (imported.type === 'Identifier') {
@@ -6145,12 +6171,12 @@
6145
6171
  else {
6146
6172
  parser.report(25, KeywordDescTable[77932 & 255]);
6147
6173
  }
6148
- scope?.addBlockName(context, tokenValue, 8, 0);
6174
+ scope?.addBlockName(context, tokenValue, 8, tokenStart, currentLocation);
6149
6175
  specifiers.push(parser.finishNode({
6150
6176
  type: 'ImportSpecifier',
6151
6177
  local,
6152
6178
  imported,
6153
- }, tokenStart));
6179
+ }, start));
6154
6180
  if (parser.getToken() !== 1074790415)
6155
6181
  consume(parser, context, 18);
6156
6182
  }
@@ -6191,7 +6217,7 @@
6191
6217
  if (isDefaultExport) {
6192
6218
  switch (parser.getToken()) {
6193
6219
  case 86104: {
6194
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 0, parser.tokenStart);
6220
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 0, parser.tokenStart, 4);
6195
6221
  break;
6196
6222
  }
6197
6223
  case 133:
@@ -6207,17 +6233,17 @@
6207
6233
  const { flags } = parser;
6208
6234
  if ((flags & 1) === 0) {
6209
6235
  if (parser.getToken() === 86104) {
6210
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 1, tokenStart);
6236
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 1, tokenStart, 4);
6211
6237
  }
6212
6238
  else {
6213
6239
  if (parser.getToken() === 67174411) {
6214
- declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, 0, flags, tokenStart);
6240
+ declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, flags, tokenStart);
6215
6241
  declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
6216
6242
  declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
6217
6243
  }
6218
6244
  else if (parser.getToken() & 143360) {
6219
6245
  if (scope)
6220
- scope = createArrowHeadParsingScope(parser, context, parser.tokenValue);
6246
+ scope = createArrowHeadParsingScope(parser, context, parser.tokenValue, parser.tokenStart, parser.currentLocation);
6221
6247
  declaration = parseIdentifier(parser, context);
6222
6248
  declaration = parseArrowFunctionExpression(parser, context, scope, undefined, [declaration], 1, tokenStart);
6223
6249
  }
@@ -6328,7 +6354,7 @@
6328
6354
  declaration = parseClassDeclaration(parser, context, scope, undefined, 2);
6329
6355
  break;
6330
6356
  case 86104:
6331
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 0, parser.tokenStart);
6357
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 0, parser.tokenStart, 4);
6332
6358
  break;
6333
6359
  case 241737:
6334
6360
  declaration = parseLexicalDeclaration(parser, context, scope, undefined, 8, 64);
@@ -6343,7 +6369,7 @@
6343
6369
  const { tokenStart } = parser;
6344
6370
  nextToken(parser, context);
6345
6371
  if ((parser.flags & 1) === 0 && parser.getToken() === 86104) {
6346
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 2, 1, tokenStart);
6372
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 1, tokenStart, 4);
6347
6373
  break;
6348
6374
  }
6349
6375
  }
@@ -6359,8 +6385,8 @@
6359
6385
  };
6360
6386
  return parser.finishNode(node, start);
6361
6387
  }
6362
- function parseExpression(parser, context, privateScope, canAssign, inGroup, start) {
6363
- let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start);
6388
+ function parseExpression(parser, context, privateScope, canAssign, inGroup, start, origin = 0) {
6389
+ let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start, origin);
6364
6390
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGroup, 0, start);
6365
6391
  return parseAssignmentExpression(parser, context, privateScope, inGroup, 0, start, expr);
6366
6392
  }
@@ -6515,7 +6541,7 @@
6515
6541
  }
6516
6542
  }
6517
6543
  if (!inNew && parser.getToken() === 67174411) {
6518
- return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, 0, flags, start);
6544
+ return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, flags, start);
6519
6545
  }
6520
6546
  if (parser.getToken() === 10) {
6521
6547
  classifyIdentifier(parser, context, token);
@@ -6563,8 +6589,12 @@
6563
6589
  return parseIdentifierOrArrow(parser, context, privateScope);
6564
6590
  }
6565
6591
  function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, start) {
6566
- if (inGroup)
6592
+ if (inGroup) {
6593
+ if ((parser.destructible & 128) === 0) {
6594
+ parser.firstAwaitLocation ??= { start, end: parser.currentLocation };
6595
+ }
6567
6596
  parser.destructible |= 128;
6597
+ }
6568
6598
  if (context & 524288)
6569
6599
  parser.report(179);
6570
6600
  const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope);
@@ -6598,7 +6628,7 @@
6598
6628
  throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 98);
6599
6629
  return possibleIdentifierOrArrowFunc;
6600
6630
  }
6601
- function parseFunctionBody(parser, context, scope, privateScope, origin, funcNameToken, functionScope) {
6631
+ function parseFunctionBody(parser, context, scope, privateScope, funcNameToken, functionScope, origin = 0) {
6602
6632
  const { tokenStart } = parser;
6603
6633
  parser.flags &= -4161;
6604
6634
  consume(parser, context | 32, 2162700);
@@ -6647,7 +6677,7 @@
6647
6677
  (512 | 256 | 64 | 4096);
6648
6678
  parser.destructible = (parser.destructible | 256) ^ 256;
6649
6679
  while (parser.getToken() !== 1074790415) {
6650
- body.push(parseStatementListItem(parser, context, scope, privateScope, 4, {}));
6680
+ body.push(parseStatementListItem(parser, context, scope, privateScope, {}, 4));
6651
6681
  }
6652
6682
  consume(parser, origin & (16 | 8) ? context | 32 : context, 1074790415);
6653
6683
  parser.flags &= -4289;
@@ -6896,7 +6926,7 @@
6896
6926
  prefix: true,
6897
6927
  }, start);
6898
6928
  }
6899
- function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start) {
6929
+ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start, origin = 0) {
6900
6930
  if ((parser.getToken() & 143360) === 143360) {
6901
6931
  switch (parser.getToken()) {
6902
6932
  case 209006:
@@ -6916,7 +6946,7 @@
6916
6946
  if ((token & 36864) === 36864) {
6917
6947
  parser.flags |= 256;
6918
6948
  }
6919
- return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start);
6949
+ return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start, origin);
6920
6950
  }
6921
6951
  if (context & 16 &&
6922
6952
  !(context & 32768) &&
@@ -6957,7 +6987,7 @@
6957
6987
  case 69271571:
6958
6988
  return parseArrayLiteral(parser, context, privateScope, canAssign ? 0 : 1, inGroup);
6959
6989
  case 67174411:
6960
- return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, 0, start);
6990
+ return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, start, origin);
6961
6991
  case 86021:
6962
6992
  case 86022:
6963
6993
  case 86023:
@@ -7286,7 +7316,7 @@
7286
7316
  type: 'ThisExpression',
7287
7317
  }, tokenStart);
7288
7318
  }
7289
- function parseFunctionDeclaration(parser, context, scope, privateScope, origin, allowGen, flags, isAsync, start) {
7319
+ function parseFunctionDeclaration(parser, context, scope, privateScope, allowGen, flags, isAsync, start, origin = 0) {
7290
7320
  nextToken(parser, context | 32);
7291
7321
  const isGenerator = allowGen ? optionalBit(parser, context, 8391476) : 0;
7292
7322
  let id = null;
@@ -7302,12 +7332,7 @@
7302
7332
  : 64 | (isAsync ? 1024 : 0) | (isGenerator ? 1024 : 0);
7303
7333
  validateFunctionName(parser, context, parser.getToken());
7304
7334
  if (scope) {
7305
- if (kind & 4) {
7306
- scope.addVarName(context, parser.tokenValue, kind);
7307
- }
7308
- else {
7309
- scope.addBlockName(context, parser.tokenValue, kind, origin);
7310
- }
7335
+ scope.addVarOrBlock(context, parser.tokenValue, kind, parser.tokenStart, parser.currentLocation, origin);
7311
7336
  functionScope = functionScope?.createChildScope(128);
7312
7337
  if (flags) {
7313
7338
  if (flags & 2) {
@@ -7340,7 +7365,7 @@
7340
7365
  functionScope = functionScope?.createChildScope(256);
7341
7366
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, functionScope, privateScope, 0, 1);
7342
7367
  const modifierFlags = 8 | 4 | 128 | 524288;
7343
- const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, 8, funcNameToken, functionScope);
7368
+ const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, funcNameToken, functionScope, 8);
7344
7369
  return parser.finishNode({
7345
7370
  type: 'FunctionDeclaration',
7346
7371
  id,
@@ -7379,7 +7404,7 @@
7379
7404
  const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, scope, privateScope, inGroup, 1);
7380
7405
  const body = parseFunctionBody(parser, (context & -131229) |
7381
7406
  32768 |
7382
- 4096, scope?.createChildScope(64), privateScope, 0, funcNameToken, scope);
7407
+ 4096, scope?.createChildScope(64), privateScope, funcNameToken, scope);
7383
7408
  parser.assignable = 2;
7384
7409
  return parser.finishNode({
7385
7410
  type: 'FunctionExpression',
@@ -7391,7 +7416,7 @@
7391
7416
  }, start);
7392
7417
  }
7393
7418
  function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7394
- const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7419
+ const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7395
7420
  if (parser.destructible & 64) {
7396
7421
  parser.report(63);
7397
7422
  }
@@ -7400,7 +7425,7 @@
7400
7425
  }
7401
7426
  return expr;
7402
7427
  }
7403
- function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7428
+ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7404
7429
  const { tokenStart: start } = parser;
7405
7430
  nextToken(parser, context | 32);
7406
7431
  const elements = [];
@@ -7412,7 +7437,7 @@
7412
7437
  }
7413
7438
  else {
7414
7439
  let left;
7415
- const { tokenStart, tokenValue } = parser;
7440
+ const { tokenStart, tokenValue, currentLocation } = parser;
7416
7441
  const token = parser.getToken();
7417
7442
  if (token & 143360) {
7418
7443
  left = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
@@ -7420,7 +7445,7 @@
7420
7445
  if (parser.assignable & 2)
7421
7446
  parser.report(26);
7422
7447
  nextToken(parser, context | 32);
7423
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7448
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7424
7449
  const right = parseExpression(parser, context, privateScope, 1, inGroup, parser.tokenStart);
7425
7450
  left = parser.finishNode(isPattern
7426
7451
  ? {
@@ -7446,7 +7471,7 @@
7446
7471
  destructible |= 16;
7447
7472
  }
7448
7473
  else {
7449
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7474
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7450
7475
  }
7451
7476
  destructible |=
7452
7477
  parser.destructible & 256
@@ -7509,7 +7534,7 @@
7509
7534
  }
7510
7535
  }
7511
7536
  else if (token === 14) {
7512
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, origin, 0, inGroup, isPattern);
7537
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, 0, inGroup, isPattern, origin);
7513
7538
  destructible |= parser.destructible;
7514
7539
  if (parser.getToken() !== 18 && parser.getToken() !== 20)
7515
7540
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
@@ -7579,12 +7604,12 @@
7579
7604
  right,
7580
7605
  }, start);
7581
7606
  }
7582
- function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, origin, isAsync, inGroup, isPattern) {
7607
+ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, isAsync, inGroup, isPattern, origin = 0) {
7583
7608
  const { tokenStart: start } = parser;
7584
7609
  nextToken(parser, context | 32);
7585
7610
  let argument = null;
7586
7611
  let destructible = 0;
7587
- const { tokenValue, tokenStart } = parser;
7612
+ const { tokenValue, tokenStart, currentLocation } = parser;
7588
7613
  let token = parser.getToken();
7589
7614
  if (token & 143360) {
7590
7615
  parser.assignable = 1;
@@ -7601,7 +7626,7 @@
7601
7626
  destructible |= 16;
7602
7627
  }
7603
7628
  else if (token === closingToken || token === 18) {
7604
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7629
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7605
7630
  }
7606
7631
  else {
7607
7632
  destructible |= 32;
@@ -7728,7 +7753,7 @@
7728
7753
  scope = scope?.createChildScope(64);
7729
7754
  const body = parseFunctionBody(parser, (context & -655373) |
7730
7755
  32768 |
7731
- 4096, scope, privateScope, 0, void 0, scope?.parent);
7756
+ 4096, scope, privateScope, void 0, scope?.parent);
7732
7757
  return parser.finishNode({
7733
7758
  type: 'FunctionExpression',
7734
7759
  params,
@@ -7739,7 +7764,7 @@
7739
7764
  }, start);
7740
7765
  }
7741
7766
  function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGroup) {
7742
- const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2, 0);
7767
+ const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
7743
7768
  if (parser.destructible & 64) {
7744
7769
  parser.report(63);
7745
7770
  }
@@ -7748,7 +7773,7 @@
7748
7773
  }
7749
7774
  return expr;
7750
7775
  }
7751
- function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
7776
+ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
7752
7777
  const { tokenStart: start } = parser;
7753
7778
  nextToken(parser, context);
7754
7779
  const properties = [];
@@ -7756,10 +7781,10 @@
7756
7781
  let prototypeCount = 0;
7757
7782
  context = (context | 131072) ^ 131072;
7758
7783
  while (parser.getToken() !== 1074790415) {
7759
- const { tokenValue, tokenStart } = parser;
7784
+ const { tokenValue, tokenStart, currentLocation } = parser;
7760
7785
  const token = parser.getToken();
7761
7786
  if (token === 14) {
7762
- properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, origin, 0, inGroup, isPattern));
7787
+ properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, 0, inGroup, isPattern, origin));
7763
7788
  }
7764
7789
  else {
7765
7790
  let state = 0;
@@ -7781,7 +7806,7 @@
7781
7806
  else {
7782
7807
  validateBindingIdentifier(parser, context, kind, token, 0);
7783
7808
  }
7784
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
7809
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
7785
7810
  if (consumeOpt(parser, context | 32, 1077936155)) {
7786
7811
  destructible |= 8;
7787
7812
  const right = parseExpression(parser, context, privateScope, 1, inGroup, parser.tokenStart);
@@ -7805,7 +7830,7 @@
7805
7830
  }
7806
7831
  }
7807
7832
  else if (consumeOpt(parser, context | 32, 21)) {
7808
- const { tokenStart } = parser;
7833
+ const { tokenStart, currentLocation } = parser;
7809
7834
  if (tokenValue === '__proto__')
7810
7835
  prototypeCount++;
7811
7836
  if (parser.getToken() & 143360) {
@@ -7821,7 +7846,7 @@
7821
7846
  destructible |= 16;
7822
7847
  }
7823
7848
  else if ((tokenAfterColon & 143360) === 143360) {
7824
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
7849
+ scope?.addVarOrBlock(context, valueAfterColon, kind, tokenStart, currentLocation, origin);
7825
7850
  }
7826
7851
  }
7827
7852
  else {
@@ -7839,7 +7864,7 @@
7839
7864
  destructible |= 32;
7840
7865
  }
7841
7866
  else {
7842
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
7867
+ scope?.addVarOrBlock(context, valueAfterColon, kind, tokenStart, currentLocation, origin);
7843
7868
  }
7844
7869
  value = parseAssignmentExpression(parser, context, privateScope, inGroup, isPattern, tokenStart, value);
7845
7870
  }
@@ -8007,7 +8032,7 @@
8007
8032
  prototypeCount++;
8008
8033
  if (parser.getToken() & 143360) {
8009
8034
  value = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
8010
- const { tokenValue: valueAfterColon } = parser;
8035
+ const { tokenValue: valueAfterColon, tokenStart: start, currentLocation } = parser;
8011
8036
  const token = parser.getToken();
8012
8037
  value = parseMemberOrUpdateExpression(parser, context, privateScope, value, inGroup, 0, tokenStart);
8013
8038
  if (parser.getToken() === 18 || parser.getToken() === 1074790415) {
@@ -8016,7 +8041,7 @@
8016
8041
  destructible |= 16;
8017
8042
  }
8018
8043
  else {
8019
- scope?.addVarOrBlock(context, valueAfterColon, kind, origin);
8044
+ scope?.addVarOrBlock(context, valueAfterColon, kind, start, currentLocation, origin);
8020
8045
  }
8021
8046
  }
8022
8047
  else {
@@ -8108,7 +8133,7 @@
8108
8133
  state |= 2;
8109
8134
  if (parser.getToken() === 21) {
8110
8135
  nextToken(parser, context | 32);
8111
- const { tokenStart, tokenValue } = parser;
8136
+ const { tokenStart, tokenValue, currentLocation } = parser;
8112
8137
  const tokenAfterColon = parser.getToken();
8113
8138
  if (parser.getToken() & 143360) {
8114
8139
  value = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, inGroup, 1, tokenStart);
@@ -8129,7 +8154,7 @@
8129
8154
  destructible |= 16;
8130
8155
  }
8131
8156
  else if ((tokenAfterColon & 143360) === 143360) {
8132
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
8157
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
8133
8158
  }
8134
8159
  }
8135
8160
  else {
@@ -8287,6 +8312,7 @@
8287
8312
  const params = [];
8288
8313
  parser.flags = (parser.flags | 128) ^ 128;
8289
8314
  parser.strictReservedRange = null;
8315
+ parser.firstAwaitLocation = null;
8290
8316
  if (parser.getToken() === 16) {
8291
8317
  if (kind & 512) {
8292
8318
  parser.report(37, 'Setter', 'one', '');
@@ -8316,17 +8342,17 @@
8316
8342
  parser.flags |= 512;
8317
8343
  }
8318
8344
  }
8319
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8345
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8320
8346
  }
8321
8347
  else {
8322
8348
  if (parser.getToken() === 2162700) {
8323
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8349
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8324
8350
  }
8325
8351
  else if (parser.getToken() === 69271571) {
8326
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type, 0);
8352
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
8327
8353
  }
8328
8354
  else if (parser.getToken() === 14) {
8329
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, 0, inGroup, 1);
8355
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, inGroup, 1);
8330
8356
  }
8331
8357
  isNonSimpleParameterList = 1;
8332
8358
  if (parser.destructible & (32 | 16))
@@ -8365,17 +8391,20 @@
8365
8391
  consume(parser, context, 20);
8366
8392
  return key;
8367
8393
  }
8368
- function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, origin, start) {
8394
+ function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, start, origin) {
8369
8395
  parser.flags = (parser.flags | 128) ^ 128;
8370
8396
  const parenthesesStart = parser.tokenStart;
8371
8397
  nextToken(parser, context | 32 | 262144);
8372
8398
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8373
8399
  context = (context | 131072) ^ 131072;
8374
8400
  if (consumeOpt(parser, context, 16)) {
8375
- return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start);
8401
+ return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start, origin);
8376
8402
  }
8377
8403
  let destructible = 0;
8404
+ const previousAwaitYield = parser.destructible & (256 | 128);
8378
8405
  parser.destructible &= -385;
8406
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8407
+ parser.firstAwaitLocation = null;
8379
8408
  let expr;
8380
8409
  let expressions = [];
8381
8410
  let isSequence = 0;
@@ -8384,17 +8413,17 @@
8384
8413
  const tokenAfterParenthesesStart = parser.tokenStart;
8385
8414
  parser.assignable = 1;
8386
8415
  while (parser.getToken() !== 16) {
8387
- const { tokenStart } = parser;
8416
+ const { tokenStart, currentLocation } = parser;
8388
8417
  const token = parser.getToken();
8389
8418
  if (token & 143360) {
8390
- scope?.addBlockName(context, parser.tokenValue, 1, 0);
8419
+ scope?.addBlockName(context, parser.tokenValue, 1, tokenStart, currentLocation);
8391
8420
  if ((token & 537079808) === 537079808) {
8392
8421
  isNonSimpleParameterList = 1;
8393
8422
  }
8394
8423
  else if ((token & 36864) === 36864) {
8395
8424
  hasStrictReserved = 1;
8396
8425
  }
8397
- expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart);
8426
+ expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart, 0);
8398
8427
  if (parser.getToken() === 16 || parser.getToken() === 18) {
8399
8428
  if (parser.assignable & 2) {
8400
8429
  destructible |= 16;
@@ -8417,8 +8446,8 @@
8417
8446
  else if ((token & 2097152) === 2097152) {
8418
8447
  expr =
8419
8448
  token === 2162700
8420
- ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind, origin)
8421
- : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind, origin);
8449
+ ? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind)
8450
+ : parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind);
8422
8451
  destructible |= parser.destructible;
8423
8452
  isNonSimpleParameterList = 1;
8424
8453
  parser.assignable = 2;
@@ -8433,7 +8462,7 @@
8433
8462
  }
8434
8463
  }
8435
8464
  else if (token === 14) {
8436
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 0, 1, 0);
8465
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 1, 0);
8437
8466
  if (parser.destructible & 16)
8438
8467
  parser.report(74);
8439
8468
  isNonSimpleParameterList = 1;
@@ -8466,7 +8495,10 @@
8466
8495
  }, tokenAfterParenthesesStart);
8467
8496
  }
8468
8497
  consume(parser, context, 16);
8469
- parser.destructible = destructible;
8498
+ parser.destructible = destructible | previousAwaitYield;
8499
+ if (previousFirstAwaitLocation) {
8500
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8501
+ }
8470
8502
  return parser.options.preserveParens
8471
8503
  ? parser.finishNode({
8472
8504
  type: 'ParenthesizedExpression',
@@ -8507,8 +8539,12 @@
8507
8539
  if (parser.getToken() === 10) {
8508
8540
  if (destructible & (32 | 16))
8509
8541
  parser.report(49);
8510
- if (context & (2048 | 2) && destructible & 128)
8542
+ if (context & (2048 | 2) && destructible & 128) {
8543
+ const loc = parser.firstAwaitLocation;
8544
+ if (loc)
8545
+ throw new ParseError(loc.start, loc.end, 31);
8511
8546
  parser.report(31);
8547
+ }
8512
8548
  if (context & (1 | 1024) && destructible & 256) {
8513
8549
  parser.report(32);
8514
8550
  }
@@ -8516,7 +8552,7 @@
8516
8552
  parser.flags |= 128;
8517
8553
  if (hasStrictReserved)
8518
8554
  parser.flags |= 256;
8519
- return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start);
8555
+ return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start, origin);
8520
8556
  }
8521
8557
  if (destructible & 64) {
8522
8558
  parser.report(63);
@@ -8524,7 +8560,11 @@
8524
8560
  if (destructible & 8) {
8525
8561
  parser.report(146);
8526
8562
  }
8527
- parser.destructible = ((parser.destructible | 256) ^ 256) | destructible;
8563
+ parser.destructible =
8564
+ ((parser.destructible | 256) ^ 256) | destructible | previousAwaitYield;
8565
+ if (previousFirstAwaitLocation) {
8566
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8567
+ }
8528
8568
  return parser.options.preserveParens
8529
8569
  ? parser.finishNode({
8530
8570
  type: 'ParenthesizedExpression',
@@ -8533,8 +8573,7 @@
8533
8573
  : expr;
8534
8574
  }
8535
8575
  function parseIdentifierOrArrow(parser, context, privateScope) {
8536
- const { tokenStart: start } = parser;
8537
- const { tokenValue } = parser;
8576
+ const { tokenValue, tokenStart, currentLocation } = parser;
8538
8577
  let isNonSimpleParameterList = 0;
8539
8578
  let hasStrictReserved = 0;
8540
8579
  if ((parser.getToken() & 537079808) === 537079808) {
@@ -8546,32 +8585,36 @@
8546
8585
  const expr = parseIdentifier(parser, context);
8547
8586
  parser.assignable = 1;
8548
8587
  if (parser.getToken() === 10) {
8549
- const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, tokenValue) : undefined;
8588
+ const scope = parser.options.lexical
8589
+ ? createArrowHeadParsingScope(parser, context, tokenValue, tokenStart, currentLocation)
8590
+ : undefined;
8550
8591
  if (isNonSimpleParameterList)
8551
8592
  parser.flags |= 128;
8552
8593
  if (hasStrictReserved)
8553
8594
  parser.flags |= 256;
8554
- return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, start);
8595
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], 0, tokenStart);
8555
8596
  }
8556
8597
  return expr;
8557
8598
  }
8558
- function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start) {
8599
+ function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start, origin = 0) {
8559
8600
  if (!canAssign)
8560
8601
  parser.report(57);
8561
8602
  if (inNew)
8562
8603
  parser.report(51);
8563
8604
  parser.flags &= -129;
8564
- const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, value) : void 0;
8565
- return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start);
8605
+ const scope = parser.options.lexical
8606
+ ? createArrowHeadParsingScope(parser, context, value, start, parser.currentLocation)
8607
+ : void 0;
8608
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start, origin);
8566
8609
  }
8567
- function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start) {
8610
+ function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start, origin = 0) {
8568
8611
  if (!canAssign)
8569
8612
  parser.report(57);
8570
8613
  for (let i = 0; i < params.length; ++i)
8571
8614
  reinterpretToPattern(parser, params[i]);
8572
- return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start);
8615
+ return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin);
8573
8616
  }
8574
- function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start) {
8617
+ function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin = 0) {
8575
8618
  if (parser.flags & 1)
8576
8619
  parser.report(48);
8577
8620
  consume(parser, context | 32, 10);
@@ -8589,7 +8632,7 @@
8589
8632
  else {
8590
8633
  scope = scope?.createChildScope(64);
8591
8634
  const modifierFlags = 4 | 131072 | 8;
8592
- body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, 16, void 0, void 0);
8635
+ body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, void 0, void 0, 16);
8593
8636
  switch (parser.getToken()) {
8594
8637
  case 69271571:
8595
8638
  if ((parser.flags & 1) === 0) {
@@ -8608,8 +8651,11 @@
8608
8651
  parser.flags |= 1024;
8609
8652
  break;
8610
8653
  }
8611
- if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0)
8612
- parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8654
+ if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0) {
8655
+ if (parser.getToken() !== 8673330 || origin !== 32) {
8656
+ parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8657
+ }
8658
+ }
8613
8659
  if ((parser.getToken() & 33619968) === 33619968)
8614
8660
  parser.report(127);
8615
8661
  }
@@ -8627,6 +8673,7 @@
8627
8673
  consume(parser, context, 67174411);
8628
8674
  parser.flags = (parser.flags | 128) ^ 128;
8629
8675
  parser.strictReservedRange = null;
8676
+ parser.firstAwaitLocation = null;
8630
8677
  const params = [];
8631
8678
  if (consumeOpt(parser, context, 16))
8632
8679
  return params;
@@ -8646,17 +8693,17 @@
8646
8693
  parser.flags |= 512;
8647
8694
  }
8648
8695
  }
8649
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1, 0);
8696
+ left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
8650
8697
  }
8651
8698
  else {
8652
8699
  if (token === 2162700) {
8653
- left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8700
+ left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8654
8701
  }
8655
8702
  else if (token === 69271571) {
8656
- left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind, 0);
8703
+ left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
8657
8704
  }
8658
8705
  else if (token === 14) {
8659
- left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 0, inGroup, 1);
8706
+ left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, inGroup, 1);
8660
8707
  }
8661
8708
  else {
8662
8709
  parser.report(30, KeywordDescTable[token & 255]);
@@ -8780,9 +8827,11 @@
8780
8827
  }
8781
8828
  return parseArrowFromIdentifier(parser, (context & -524289) | 2048, privateScope, parser.tokenValue, parseIdentifier(parser, context), 0, canAssign, 1, start);
8782
8829
  }
8783
- function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, origin, flags, start) {
8830
+ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, flags, start) {
8784
8831
  nextToken(parser, context | 32);
8785
8832
  const scope = parser.createScopeIfLexical()?.createChildScope(512);
8833
+ const previousFirstAwaitLocation = parser.firstAwaitLocation;
8834
+ parser.firstAwaitLocation = null;
8786
8835
  context = (context | 131072) ^ 131072;
8787
8836
  if (consumeOpt(parser, context, 16)) {
8788
8837
  if (parser.getToken() === 10) {
@@ -8796,6 +8845,8 @@
8796
8845
  else {
8797
8846
  parser.assignable = 2;
8798
8847
  }
8848
+ if (previousFirstAwaitLocation)
8849
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8799
8850
  return parser.finishNode({
8800
8851
  type: 'CallExpression',
8801
8852
  callee,
@@ -8811,10 +8862,10 @@
8811
8862
  (256 | 128);
8812
8863
  const params = [];
8813
8864
  while (parser.getToken() !== 16) {
8814
- const { tokenStart } = parser;
8865
+ const { tokenStart, currentLocation } = parser;
8815
8866
  const token = parser.getToken();
8816
8867
  if (token & 143360) {
8817
- scope?.addBlockName(context, parser.tokenValue, kind, 0);
8868
+ scope?.addBlockName(context, parser.tokenValue, kind, tokenStart, currentLocation);
8818
8869
  if ((token & 537079808) === 537079808) {
8819
8870
  parser.flags |= 512;
8820
8871
  }
@@ -8844,8 +8895,8 @@
8844
8895
  else if (token & 2097152) {
8845
8896
  expr =
8846
8897
  token === 2162700
8847
- ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin)
8848
- : parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind, origin);
8898
+ ? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind)
8899
+ : parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind);
8849
8900
  destructible |= parser.destructible;
8850
8901
  isNonSimpleParameterList = 1;
8851
8902
  if (parser.getToken() !== 16 && parser.getToken() !== 18) {
@@ -8862,7 +8913,7 @@
8862
8913
  }
8863
8914
  }
8864
8915
  else if (token === 14) {
8865
- expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, origin, 1, 1, 0);
8916
+ expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 1, 1, 0);
8866
8917
  destructible |=
8867
8918
  (parser.getToken() === 16 ? 0 : 16) | parser.destructible;
8868
8919
  isNonSimpleParameterList = 1;
@@ -8883,6 +8934,8 @@
8883
8934
  else {
8884
8935
  parser.assignable = 2;
8885
8936
  }
8937
+ if (previousFirstAwaitLocation)
8938
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8886
8939
  return parser.finishNode({
8887
8940
  type: 'CallExpression',
8888
8941
  callee,
@@ -8906,8 +8959,12 @@
8906
8959
  parser.report(27);
8907
8960
  if (parser.flags & 1 || flags & 1)
8908
8961
  parser.report(48);
8909
- if (destructible & 128)
8962
+ if (destructible & 128) {
8963
+ const loc = parser.firstAwaitLocation;
8964
+ if (loc)
8965
+ throw new ParseError(loc.start, loc.end, 31);
8910
8966
  parser.report(31);
8967
+ }
8911
8968
  if (context & (1 | 1024) && destructible & 256)
8912
8969
  parser.report(32);
8913
8970
  if (isNonSimpleParameterList)
@@ -8926,6 +8983,8 @@
8926
8983
  else {
8927
8984
  parser.assignable = 2;
8928
8985
  }
8986
+ if (previousFirstAwaitLocation)
8987
+ parser.firstAwaitLocation = previousFirstAwaitLocation;
8929
8988
  return parser.finishNode({
8930
8989
  type: 'CallExpression',
8931
8990
  callee,
@@ -8963,7 +9022,7 @@
8963
9022
  consume(parser, context, 86094);
8964
9023
  let id = null;
8965
9024
  let superClass = null;
8966
- const { tokenValue } = parser;
9025
+ const { tokenValue, tokenStart, currentLocation } = parser;
8967
9026
  if (parser.getToken() & 4096 && parser.getToken() !== 20565) {
8968
9027
  if (isStrictReservedWord(parser, context, parser.getToken())) {
8969
9028
  parser.report(120);
@@ -8972,7 +9031,7 @@
8972
9031
  parser.report(121);
8973
9032
  }
8974
9033
  if (scope) {
8975
- scope.addBlockName(context, tokenValue, 32, 0);
9034
+ scope.addBlockName(context, tokenValue, 32, tokenStart, currentLocation);
8976
9035
  if (flags) {
8977
9036
  if (flags & 2) {
8978
9037
  parser.declareUnboundVariable(tokenValue);
@@ -8993,7 +9052,7 @@
8993
9052
  else {
8994
9053
  inheritedContext = (inheritedContext | 512) ^ 512;
8995
9054
  }
8996
- const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 8, 0);
9055
+ const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 0, 8);
8997
9056
  return parser.finishNode({
8998
9057
  type: 'ClassDeclaration',
8999
9058
  id,
@@ -9024,7 +9083,7 @@
9024
9083
  else {
9025
9084
  inheritedContext = (inheritedContext | 512) ^ 512;
9026
9085
  }
9027
- const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, 0, inGroup);
9086
+ const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, inGroup);
9028
9087
  parser.assignable = 2;
9029
9088
  return parser.finishNode({
9030
9089
  type: 'ClassExpression',
@@ -9091,7 +9150,7 @@
9091
9150
  expression,
9092
9151
  }, start);
9093
9152
  }
9094
- function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, origin, inGroup) {
9153
+ function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, inGroup, origin = 0) {
9095
9154
  const { tokenStart } = parser;
9096
9155
  const privateScope = parser.createPrivateScopeIfLexical(parentScope);
9097
9156
  consume(parser, context | 32, 2162700);
@@ -9331,22 +9390,22 @@
9331
9390
  ...(parser.features & 1 ? { decorators } : null),
9332
9391
  }, start);
9333
9392
  }
9334
- function parseBindingPattern(parser, context, scope, privateScope, type, origin) {
9393
+ function parseBindingPattern(parser, context, scope, privateScope, kind, origin = 0) {
9335
9394
  if (parser.getToken() & 143360 ||
9336
9395
  ((context & 1) === 0 && parser.getToken() === -2147483526))
9337
- return parseAndClassifyIdentifier(parser, context, scope, type, origin);
9396
+ return parseAndClassifyIdentifier(parser, context, scope, kind, origin);
9338
9397
  if ((parser.getToken() & 2097152) !== 2097152)
9339
9398
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
9340
9399
  const left = parser.getToken() === 69271571
9341
- ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, type, origin)
9342
- : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, type, origin);
9400
+ ? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin)
9401
+ : parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin);
9343
9402
  if (parser.destructible & 16)
9344
9403
  parser.report(50);
9345
9404
  if (parser.destructible & 32)
9346
9405
  parser.report(50);
9347
9406
  return left;
9348
9407
  }
9349
- function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
9408
+ function parseAndClassifyIdentifier(parser, context, scope, kind, origin = 0) {
9350
9409
  const token = parser.getToken();
9351
9410
  if (context & 1) {
9352
9411
  if ((token & 537079808) === 537079808) {
@@ -9375,13 +9434,13 @@
9375
9434
  if (context & 2)
9376
9435
  parser.report(112);
9377
9436
  }
9378
- const { tokenValue, tokenStart: start } = parser;
9437
+ const { tokenValue, tokenStart, currentLocation } = parser;
9379
9438
  nextToken(parser, context);
9380
- scope?.addVarOrBlock(context, tokenValue, kind, origin);
9439
+ scope?.addVarOrBlock(context, tokenValue, kind, tokenStart, currentLocation, origin);
9381
9440
  return parser.finishNode({
9382
9441
  type: 'Identifier',
9383
9442
  name: tokenValue,
9384
- }, start);
9443
+ }, tokenStart);
9385
9444
  }
9386
9445
  function parseJSXRootElementOrFragment(parser, context, privateScope, inJSXChild, start) {
9387
9446
  if (!inJSXChild)
@@ -9474,7 +9533,7 @@
9474
9533
  }
9475
9534
  function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild) {
9476
9535
  if (parser.getToken() === 138)
9477
- return parseJSXText(parser, context);
9536
+ return parseJSXText(parser);
9478
9537
  if (parser.getToken() === 2162700)
9479
9538
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9480
9539
  if (parser.getToken() === 8456256) {
@@ -9488,7 +9547,7 @@
9488
9547
  }
9489
9548
  function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChild) {
9490
9549
  if (parser.getToken() === 138)
9491
- return parseJSXText(parser, context);
9550
+ return parseJSXText(parser);
9492
9551
  if (parser.getToken() === 2162700)
9493
9552
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
9494
9553
  if (parser.getToken() === 8456256) {
@@ -9500,9 +9559,9 @@
9500
9559
  }
9501
9560
  parser.report(0);
9502
9561
  }
9503
- function parseJSXText(parser, context) {
9562
+ function parseJSXText(parser) {
9504
9563
  const start = parser.tokenStart;
9505
- nextToken(parser, context);
9564
+ nextJSXToken(parser);
9506
9565
  const node = {
9507
9566
  type: 'JSXText',
9508
9567
  value: parser.tokenValue,
@@ -9520,7 +9579,7 @@
9520
9579
  const attributes = parseJSXAttributes(parser, context, privateScope);
9521
9580
  const selfClosing = parser.getToken() === 8457014;
9522
9581
  if (selfClosing)
9523
- consume(parser, context, 8457014);
9582
+ consume(parser, context | 1048576, 8457014);
9524
9583
  if (parser.getToken() !== 8390721) {
9525
9584
  parser.report(25, KeywordDescTable[8390721 & 255]);
9526
9585
  }
@@ -9671,7 +9730,7 @@
9671
9730
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
9672
9731
  }
9673
9732
  const { tokenValue } = parser;
9674
- nextToken(parser, context);
9733
+ nextToken(parser, context | 1048576);
9675
9734
  return parser.finishNode({
9676
9735
  type: 'JSXIdentifier',
9677
9736
  name: tokenValue,