meriyah 7.4.0 → 7.4.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/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ ## [7.4.2](https://github.com/meriyah/meriyah/compare/v7.4.1...v7.4.2) (2026-11-08)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **lexer:** only treat `<!--` as a comment in web compatible script code ([#683](https://github.com/meriyah/meriyah/issues/683)) ([78eebfe](https://github.com/meriyah/meriyah/commit/78eebfe5a2eb4a51e11212598f6e586faa655606))
6
+ * **lexer:** recognize an HTML close comment after a hashbang line ([#682](https://github.com/meriyah/meriyah/issues/682)) ([133b2b9](https://github.com/meriyah/meriyah/commit/133b2b906ddcc77941797f593389450baa5ad5c7))
7
+ * **parser:** allow `#x in obj` as an array element, object property value and spread argument ([#678](https://github.com/meriyah/meriyah/issues/678)) ([1f7c40e](https://github.com/meriyah/meriyah/commit/1f7c40e8b031ea476934ab27610fdc04d35d2389)), closes [#x](https://github.com/meriyah/meriyah/issues/x)
8
+ * **parser:** allow `arguments` as a label in class field initializers and static blocks ([#703](https://github.com/meriyah/meriyah/issues/703)) ([b3eae1f](https://github.com/meriyah/meriyah/commit/b3eae1f9958e12ffe5d36552b82f11b0cd8ff282))
9
+ * **parser:** allow a nested class to use a private name declared later in an enclosing class ([#699](https://github.com/meriyah/meriyah/issues/699)) ([e476062](https://github.com/meriyah/meriyah/commit/e476062ed155cade8e8aa8fd70cd027068a3732f))
10
+ * **parser:** allow an escaped strict mode reserved word as a class field name ([#698](https://github.com/meriyah/meriyah/issues/698)) ([5a764b5](https://github.com/meriyah/meriyah/commit/5a764b575b8e332a92c261e5e4fffef34e7c4eda))
11
+ * **parser:** allow strict mode reserved words as identifiers in sloppy generators ([#674](https://github.com/meriyah/meriyah/issues/674)) ([0dc7926](https://github.com/meriyah/meriyah/commit/0dc792608674ac7796b8485f5b3cbaabbb604503))
12
+ * **parser:** declare method parameters as parameters in lexical mode ([#688](https://github.com/meriyah/meriyah/issues/688)) ([c1dae06](https://github.com/meriyah/meriyah/commit/c1dae06f4cd76c75c780bd34c3c93ce08dc7980c))
13
+ * **parser:** keep enclosing labels and allow web compat function declarations for a `let` label ([#692](https://github.com/meriyah/meriyah/issues/692)) ([0ab5c32](https://github.com/meriyah/meriyah/commit/0ab5c3289a0f581e42ec9a970851ffd929056627))
14
+ * **parser:** parse `await` followed by a strict mode reserved word in sloppy async functions ([#679](https://github.com/meriyah/meriyah/issues/679)) ([dd8e9aa](https://github.com/meriyah/meriyah/commit/dd8e9aa6e16fe909e656bec4da02538e690597c0))
15
+ * **parser:** parse operators after an import call at the start of a statement ([#677](https://github.com/meriyah/meriyah/issues/677)) ([c4b297a](https://github.com/meriyah/meriyah/commit/c4b297a26fbba6d01620f029d8ef9aef01a8b4a8))
16
+ * **parser:** parse the computed key of a generator, async or accessor method in the enclosing context ([#695](https://github.com/meriyah/meriyah/issues/695)) ([a158249](https://github.com/meriyah/meriyah/commit/a1582490dc29ef1527e04af9cde38790da3bce32))
17
+ * **parser:** reject `?.` and templates with substitutions after a block body arrow ([#686](https://github.com/meriyah/meriyah/issues/686)) ([1845d76](https://github.com/meriyah/meriyah/commit/1845d768841ccb0756372cf2f531b4184a59ce18))
18
+ * **parser:** reject `++` and `--` after an array or object literal nested in another literal ([#694](https://github.com/meriyah/meriyah/issues/694)) ([7e1ec5e](https://github.com/meriyah/meriyah/commit/7e1ec5e78c1f00f911df78ad7b6fcb35e777dd9e))
19
+ * **parser:** reject `++` and `--` on array and object literals ([#689](https://github.com/meriyah/meriyah/issues/689)) ([e13e7c9](https://github.com/meriyah/meriyah/commit/e13e7c922e91dfa692e35d49ba85f003087dbb5b))
20
+ * **parser:** reject `arguments` in class field initializers and static blocks nested in functions ([#676](https://github.com/meriyah/meriyah/issues/676)) ([9a4f073](https://github.com/meriyah/meriyah/commit/9a4f07372b3766fa126d868fb40e45fd2554e50b))
21
+ * **parser:** reject `await` in the concise body of a non-async arrow in module code ([#673](https://github.com/meriyah/meriyah/issues/673)) ([43449ea](https://github.com/meriyah/meriyah/commit/43449ea396c78524e1188ce816d4cc21d27a85a8))
22
+ * **parser:** reject `break` and `continue` in an arrow or method body inside a loop ([#693](https://github.com/meriyah/meriyah/issues/693)) ([dfa8ad0](https://github.com/meriyah/meriyah/commit/dfa8ad0bb89f0bdd65db991e0f5e436f16ea67f9))
23
+ * **parser:** reject `for await` in class static blocks ([#680](https://github.com/meriyah/meriyah/issues/680)) ([65d5350](https://github.com/meriyah/meriyah/commit/65d5350ad326d3f764500be51f4e93aa006b455a))
24
+ * **parser:** reject a function declaration after an `async:` label in a single-statement context ([#697](https://github.com/meriyah/meriyah/issues/697)) ([4c4ea12](https://github.com/meriyah/meriyah/commit/4c4ea129bbb8eb6d68976b41d316752100694122))
25
+ * **parser:** reject an escaped `yield` or `await` as the name of a generator or async function expression ([#702](https://github.com/meriyah/meriyah/issues/702)) ([1480dad](https://github.com/meriyah/meriyah/commit/1480dad32cc6546ea7d2a623e851f18fccf32a7f))
26
+ * **parser:** reject an optional call as an assignment target in web compat mode ([#696](https://github.com/meriyah/meriyah/issues/696)) ([a3d5926](https://github.com/meriyah/meriyah/commit/a3d59264e1261c04030898a0001c7cbcd8a735ea))
27
+ * **parser:** reject arrow functions after unary operators when the parameter is a reserved word ([#687](https://github.com/meriyah/meriyah/issues/687)) ([e79d7db](https://github.com/meriyah/meriyah/commit/e79d7dbd1a56f44144f6e9a5dcb281c2bc7f21d1))
28
+ * **parser:** reject assignment to a statement-level arrow with an `async` parameter ([#690](https://github.com/meriyah/meriyah/issues/690)) ([1f16445](https://github.com/meriyah/meriyah/commit/1f164456e95a4338d45a80d3bb6489e1802c2ae8))
29
+ * **parser:** reject optional chains after a member expression in `new` without arguments ([#691](https://github.com/meriyah/meriyah/issues/691)) ([b299db5](https://github.com/meriyah/meriyah/commit/b299db5590d7789d048eb2cdc89669ac58219921))
30
+ * **parser:** template literal inside parentheses should not be processed as tagged template ([#701](https://github.com/meriyah/meriyah/issues/701)) ([431f0f4](https://github.com/meriyah/meriyah/commit/431f0f42faa4b51b1b1480371a55033fc126f30a)), closes [#700](https://github.com/meriyah/meriyah/issues/700)
31
+
32
+ ## [7.4.1](https://github.com/meriyah/meriyah/compare/v7.4.0...v7.4.1) (2026-10-25)
33
+
34
+ ### Bug Fixes
35
+
36
+ * parse default-exported arrows with async as a parameter ([#672](https://github.com/meriyah/meriyah/issues/672)) ([30e5789](https://github.com/meriyah/meriyah/commit/30e57899a281ef8fa6c1706fbc2478ceaa6ac4c1))
37
+ * **parser:** don't extend `yield` with member access, calls or binary operators ([#669](https://github.com/meriyah/meriyah/issues/669)) ([7bcc6ae](https://github.com/meriyah/meriyah/commit/7bcc6aea2b6f21a9bed70c45804dc9888e7956b3))
38
+ * **parser:** finish `export default async` expressions ([#670](https://github.com/meriyah/meriyah/issues/670)) ([41b306b](https://github.com/meriyah/meriyah/commit/41b306bfdf3dfb2d92272688369c99a0be816dd1))
39
+ * **parser:** reject `let` as an arrow parameter in strict mode code ([#671](https://github.com/meriyah/meriyah/issues/671)) ([bb5eac9](https://github.com/meriyah/meriyah/commit/bb5eac99027a73304ee61e24ac332c465474e4f8))
40
+ * **parser:** start binary and conditional spread arguments at their left operand ([#668](https://github.com/meriyah/meriyah/issues/668)) ([56afd77](https://github.com/meriyah/meriyah/commit/56afd77e926e990136418df06300a49d0f35b1b7))
41
+
1
42
  # [7.4.0](https://github.com/meriyah/meriyah/compare/v7.3.3...v7.4.0) (2026-10-05)
2
43
 
3
44
  ### Bug Fixes
package/dist/meriyah.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version$1 = "7.4.0";
3
+ var version$1 = "7.4.2";
4
4
  var packageJson = {
5
5
  version: version$1};
6
6
 
@@ -1888,7 +1888,9 @@ function scanSingleToken(parser, context, state) {
1888
1888
  }
1889
1889
  if (ch === 33) {
1890
1890
  const index = parser.index + 1;
1891
- if (index + 1 < parser.end &&
1891
+ if (parser.options.webcompat &&
1892
+ !(context & 2) &&
1893
+ index + 1 < parser.end &&
1892
1894
  source.charCodeAt(index) === 45 &&
1893
1895
  source.charCodeAt(index + 1) == 45) {
1894
1896
  parser.column += 3;
@@ -1970,7 +1972,10 @@ function scanSingleToken(parser, context, state) {
1970
1972
  const ch = parser.currentChar;
1971
1973
  if (ch === 45) {
1972
1974
  advanceChar(parser);
1973
- if ((state & 1 || isStartOfLine) && parser.currentChar === 62) {
1975
+ if (parser.currentChar === 62 &&
1976
+ (state & 1 ||
1977
+ isStartOfLine ||
1978
+ (parser.getToken() === 1048576 && parser.line > 1))) {
1974
1979
  if (!parser.options.webcompat)
1975
1980
  parser.report(114);
1976
1981
  advanceChar(parser);
@@ -2242,10 +2247,10 @@ function validateFunctionName(parser, context, t) {
2242
2247
  if ((t & 20480) === 20480) {
2243
2248
  parser.report(102);
2244
2249
  }
2245
- if (context & (2048 | 2) && t === 209006) {
2250
+ if (context & (2048 | 2) && (t & 2147483647) === 209006) {
2246
2251
  parser.report(112);
2247
2252
  }
2248
- if (context & (1024 | 1) && t === 241771) {
2253
+ if (context & (1024 | 1) && (t & 2147483647) === 241771) {
2249
2254
  parser.report(97, 'yield');
2250
2255
  }
2251
2256
  }
@@ -2305,7 +2310,8 @@ function isValidIdentifier(context, t) {
2305
2310
  return false;
2306
2311
  if (context & 1024 && t === 241771)
2307
2312
  return false;
2308
- return (t & 12288) === 12288;
2313
+ if (context & 1)
2314
+ return (t & 12288) === 12288;
2309
2315
  }
2310
2316
  return (t & 12288) === 12288 || (t & 36864) === 36864;
2311
2317
  }
@@ -2315,6 +2321,9 @@ function classifyIdentifier(parser, context, t) {
2315
2321
  parser.report(121);
2316
2322
  parser.flags |= 512;
2317
2323
  }
2324
+ if (context & 1 && (t & 255) === (241737 & 255)) {
2325
+ parser.report(99);
2326
+ }
2318
2327
  if (!isValidIdentifier(context, t))
2319
2328
  parser.report(0);
2320
2329
  }
@@ -2756,12 +2765,14 @@ class PrivateScope {
2756
2765
  this.refs[name] ??= [];
2757
2766
  this.refs[name].push(this.parser.tokenStart);
2758
2767
  }
2759
- isPrivateIdentifierDefined(name) {
2760
- return this.hasPrivateIdentifier(name) || Boolean(this.parent?.isPrivateIdentifierDefined(name));
2761
- }
2762
2768
  validatePrivateIdentifierRefs() {
2763
2769
  for (const name in this.refs) {
2764
- if (!this.isPrivateIdentifierDefined(name)) {
2770
+ if (this.hasPrivateIdentifier(name))
2771
+ continue;
2772
+ if (this.parent) {
2773
+ (this.parent.refs[name] ??= []).push(...this.refs[name]);
2774
+ }
2775
+ else {
2765
2776
  const { index, line, column } = this.refs[name][0];
2766
2777
  throw new ParseError({ index, line, column }, { index: index + name.length, line, column: column + name.length }, 4, name);
2767
2778
  }
@@ -3182,7 +3193,7 @@ function parseStatementListItem(parser, context, scope, privateScope, labels, or
3182
3193
  case 86090:
3183
3194
  return parseLexicalDeclaration(parser, context, scope, privateScope, 16);
3184
3195
  case 241737:
3185
- return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin);
3196
+ return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, labels, origin);
3186
3197
  case 209013:
3187
3198
  return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
3188
3199
  case 209006:
@@ -3204,7 +3215,7 @@ function parseStatementListItem(parser, context, scope, privateScope, labels, or
3204
3215
  parser.report(103, 'import');
3205
3216
  }
3206
3217
  case 209005:
3207
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 1, origin);
3218
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 1, 1, origin);
3208
3219
  default:
3209
3220
  return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
3210
3221
  }
@@ -3242,7 +3253,7 @@ function parseStatement(parser, context, scope, privateScope, labels, allowFuncD
3242
3253
  case 20560:
3243
3254
  return parseDebuggerStatement(parser, context);
3244
3255
  case 209005:
3245
- return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 0, origin);
3256
+ return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 0, allowFuncDecl, origin);
3246
3257
  case 20557:
3247
3258
  parser.report(164);
3248
3259
  case 20566:
@@ -3272,7 +3283,7 @@ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope
3272
3283
  parser.report(84);
3273
3284
  break;
3274
3285
  default:
3275
- expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart, 0, 1);
3286
+ expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart, 1, 1);
3276
3287
  }
3277
3288
  return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, expr, token, tokenValue, tokenStart, origin);
3278
3289
  }
@@ -3336,17 +3347,17 @@ function parseLabelledStatement(parser, context, scope, privateScope, labels, va
3336
3347
  body,
3337
3348
  }, start);
3338
3349
  }
3339
- function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
3350
+ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, allowAsyncFuncDecl, allowFuncDecl, origin) {
3340
3351
  const { tokenValue, tokenStart: start } = parser;
3341
3352
  const token = parser.getToken();
3342
3353
  let expr = parseIdentifier(parser, context);
3343
3354
  if (parser.getToken() === 21) {
3344
- return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, 1, start, origin);
3355
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, allowFuncDecl, start, origin);
3345
3356
  }
3346
3357
  const asyncNewLine = parser.flags & 1;
3347
3358
  if (!asyncNewLine) {
3348
3359
  if (parser.getToken() === 86104) {
3349
- if (!allowFuncDecl)
3360
+ if (!allowAsyncFuncDecl)
3350
3361
  parser.report(125);
3351
3362
  return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 1, start, origin);
3352
3363
  }
@@ -3368,7 +3379,9 @@ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, priva
3368
3379
  }
3369
3380
  expr = parseArrowFromIdentifier(parser, context | 2048, privateScope, parser.tokenValue, expr, 0, 1, 0, start);
3370
3381
  }
3371
- parser.assignable = 1;
3382
+ else {
3383
+ parser.assignable = 1;
3384
+ }
3372
3385
  }
3373
3386
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, 0, 0, start);
3374
3387
  expr = parseAssignmentExpression(parser, context, privateScope, 0, 0, start, expr);
@@ -3623,7 +3636,12 @@ function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
3623
3636
  }
3624
3637
  function parseStaticBlock(parser, context, scope, privateScope, start) {
3625
3638
  scope = scope?.createChildScope();
3626
- const ctorContext = 512 | 4096 | 1024 | 4 | 128;
3639
+ const ctorContext = 512 |
3640
+ 4096 |
3641
+ 1024 |
3642
+ 4 |
3643
+ 128 |
3644
+ 32768;
3627
3645
  context =
3628
3646
  ((context | ctorContext) ^ ctorContext) |
3629
3647
  256 |
@@ -3647,7 +3665,7 @@ function parseDoWhileStatement(parser, context, scope, privateScope, labels) {
3647
3665
  test,
3648
3666
  }, start);
3649
3667
  }
3650
- function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin) {
3668
+ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, labels, origin) {
3651
3669
  const { tokenValue, tokenStart, currentLocation } = parser;
3652
3670
  const token = parser.getToken();
3653
3671
  let expr = parseIdentifier(parser, context);
@@ -3665,7 +3683,7 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
3665
3683
  if (context & 1)
3666
3684
  parser.report(85);
3667
3685
  if (parser.getToken() === 21) {
3668
- return parseLabelledStatement(parser, context, scope, privateScope, {}, tokenValue, expr, token, 0, tokenStart, origin);
3686
+ return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, 1, tokenStart, origin);
3669
3687
  }
3670
3688
  if (parser.getToken() === 10) {
3671
3689
  let scope = void 0;
@@ -3848,6 +3866,9 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
3848
3866
  function parseForStatement(parser, context, scope, privateScope, labels) {
3849
3867
  const start = parser.tokenStart;
3850
3868
  nextToken(parser, context);
3869
+ if (context & 524288 && parser.getToken() === 209006) {
3870
+ parser.report(179);
3871
+ }
3851
3872
  const forAwait = ((context & 2048) > 0 || ((context & 2) > 0 && (context & 8) > 0)) &&
3852
3873
  consumeOpt(parser, context, 209006);
3853
3874
  consume(parser, context | 32, 67174411);
@@ -4327,7 +4348,9 @@ function parseImportMetaDeclaration(parser, context, start) {
4327
4348
  }
4328
4349
  function parseImportCallDeclaration(parser, context, privateScope, start) {
4329
4350
  let expr = parseImportExpression(parser, context, privateScope, 0, start);
4351
+ parser.assignable = 2;
4330
4352
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, 0, 0, start);
4353
+ expr = parseAssignmentExpression(parser, context, privateScope, 0, 0, start, expr);
4331
4354
  if (parser.getToken() === 18) {
4332
4355
  expr = parseSequenceExpression(parser, context, privateScope, 0, start, expr);
4333
4356
  }
@@ -4361,24 +4384,29 @@ function parseExportDeclaration(parser, context, scope) {
4361
4384
  const { tokenStart } = parser;
4362
4385
  declaration = parseIdentifier(parser, context);
4363
4386
  const { flags } = parser;
4364
- if ((flags & 1) === 0) {
4365
- if (parser.getToken() === 86104) {
4366
- declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 1, tokenStart, 4);
4367
- }
4368
- else {
4369
- if (parser.getToken() === 67174411) {
4370
- declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, flags, tokenStart);
4371
- declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
4372
- declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
4373
- }
4374
- else if (parser.getToken() & 143360) {
4375
- if (scope)
4376
- scope = createArrowHeadParsingScope(parser, context, parser.tokenValue, parser.tokenStart, parser.currentLocation);
4377
- declaration = parseIdentifier(parser, context);
4378
- declaration = parseArrowFunctionExpression(parser, context, scope, undefined, [declaration], 1, tokenStart);
4379
- }
4380
- }
4387
+ if ((flags & 1) === 0 && parser.getToken() === 86104) {
4388
+ declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 1, tokenStart, 4);
4389
+ break;
4390
+ }
4391
+ if (parser.getToken() === 10) {
4392
+ declaration = parseArrowFromIdentifier(parser, context & -9, undefined, 'async', declaration, 0, 1, 0, tokenStart);
4393
+ }
4394
+ else if ((flags & 1) === 0 && parser.getToken() === 67174411) {
4395
+ declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, flags, tokenStart);
4396
+ declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
4397
+ declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
4398
+ }
4399
+ else if ((flags & 1) === 0 && parser.getToken() & 143360) {
4400
+ if (scope)
4401
+ scope = createArrowHeadParsingScope(parser, context, parser.tokenValue, parser.tokenStart, parser.currentLocation);
4402
+ declaration = parseIdentifier(parser, context);
4403
+ declaration = parseArrowFunctionExpression(parser, context, scope, undefined, [declaration], 1, tokenStart);
4404
+ }
4405
+ else {
4406
+ declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
4407
+ declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
4381
4408
  }
4409
+ matchOrInsertSemicolon(parser, context | 32);
4382
4410
  break;
4383
4411
  }
4384
4412
  default:
@@ -4604,6 +4632,10 @@ function parseConditionalExpression(parser, context, privateScope, test, start)
4604
4632
  }, start);
4605
4633
  }
4606
4634
  function parseBinaryExpression(parser, context, privateScope, inGroup, start, minPrecedence, operator, left) {
4635
+ if ((parser.flags & 16384) === 16384) {
4636
+ parser.flags = (parser.flags | 16384) ^ 16384;
4637
+ return left;
4638
+ }
4607
4639
  const bit = -((context & 131072) > 0) & 8673330;
4608
4640
  let t;
4609
4641
  let precedence;
@@ -4711,6 +4743,12 @@ function parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup
4711
4743
  else if (parser.getToken() === 8391476) {
4712
4744
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
4713
4745
  }
4746
+ if (parser.getToken() & (67108864 | 8388608)) {
4747
+ if (argument === null && (parser.flags & 1) === 0) {
4748
+ parser.report(30, KeywordDescTable[parser.getToken() & 255]);
4749
+ }
4750
+ parser.flags |= 16384;
4751
+ }
4714
4752
  parser.assignable = 2;
4715
4753
  return parser.finishNode({
4716
4754
  type: 'YieldExpression',
@@ -4720,9 +4758,9 @@ function parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup
4720
4758
  }
4721
4759
  if (context & 1)
4722
4760
  parser.report(97, 'yield');
4723
- return parseIdentifierOrArrow(parser, context, privateScope);
4761
+ return parseIdentifierOrArrow(parser, context, privateScope, 0, canAssign);
4724
4762
  }
4725
- function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, start) {
4763
+ function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, canAssign, start) {
4726
4764
  if (inGroup) {
4727
4765
  if ((parser.destructible & 128) === 0) {
4728
4766
  parser.firstAwaitLocation ??= { start, end: parser.currentLocation };
@@ -4733,10 +4771,11 @@ function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew,
4733
4771
  parser.report(179);
4734
4772
  const isEscaped = (parser.getToken() & -2147483648) !== 0;
4735
4773
  const allowRegExp = !isEscaped && context & (2048 | 2) ? 1 : 0;
4736
- const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope, allowRegExp);
4774
+ const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope, allowRegExp, canAssign);
4737
4775
  const isIdentifier = isEscaped ||
4738
4776
  possibleIdentifierOrArrowFunc.type === 'ArrowFunctionExpression' ||
4739
- (parser.getToken() & 65536) === 0;
4777
+ ((parser.getToken() & 65536) === 0 &&
4778
+ (parser.getToken() & 36864) !== 36864);
4740
4779
  if (isIdentifier) {
4741
4780
  if (context & 2048)
4742
4781
  throw new ParseError(start, parser.startPosition, 178);
@@ -4856,8 +4895,11 @@ function parseLeftHandSideExpression(parser, context, privateScope, canAssign, i
4856
4895
  return parseMemberOrUpdateExpression(parser, context, privateScope, expression, inGroup, 0, start);
4857
4896
  }
4858
4897
  function parseUpdateExpression(parser, context, expr, start) {
4859
- if (parser.assignable & 2)
4898
+ if (parser.assignable & 2 ||
4899
+ expr.type === 'ArrayExpression' ||
4900
+ expr.type === 'ObjectExpression') {
4860
4901
  parser.report(55);
4902
+ }
4861
4903
  const token = parser.getToken();
4862
4904
  nextToken(parser, context);
4863
4905
  parser.assignable = 2;
@@ -4873,6 +4915,10 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
4873
4915
  expr = parseUpdateExpression(parser, context, expr, start);
4874
4916
  }
4875
4917
  else if ((parser.getToken() & 67108864) === 67108864) {
4918
+ if ((parser.flags & 16384) === 16384) {
4919
+ parser.flags = (parser.flags | 16384) ^ 16384;
4920
+ return expr;
4921
+ }
4876
4922
  context = (context | 131072) ^ 131072;
4877
4923
  switch (parser.getToken()) {
4878
4924
  case 67108877: {
@@ -4932,7 +4978,7 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
4932
4978
  parser.flags = (parser.flags | 2048) ^ 2048;
4933
4979
  }
4934
4980
  const args = parseArguments(parser, context, privateScope, inGroup);
4935
- if (!(context & 1) && parser.options.webcompat) {
4981
+ if (!restoreHasOptionalChaining && !(context & 1) && parser.options.webcompat) {
4936
4982
  parser.assignable = 4;
4937
4983
  }
4938
4984
  else {
@@ -5005,12 +5051,7 @@ function parseOptionalChain(parser, context, privateScope, expr, start) {
5005
5051
  }
5006
5052
  else if (parser.getToken() === 67174411) {
5007
5053
  const args = parseArguments(parser, context, privateScope, 0);
5008
- if (!(context & 1) && parser.options.webcompat) {
5009
- parser.assignable = 4;
5010
- }
5011
- else {
5012
- parser.assignable = 2;
5013
- }
5054
+ parser.assignable = 2;
5014
5055
  node = parser.finishNode({
5015
5056
  type: 'CallExpression',
5016
5057
  callee: expr,
@@ -5069,7 +5110,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
5069
5110
  switch (parser.getToken()) {
5070
5111
  case 209006:
5071
5112
  case 209006 | -2147483648:
5072
- return parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, start);
5113
+ return parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, canAssign, start);
5073
5114
  case 241771:
5074
5115
  return parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup, canAssign, start);
5075
5116
  case 209005:
@@ -5090,8 +5131,9 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
5090
5131
  if (context & 16 &&
5091
5132
  !(context & 32768) &&
5092
5133
  !(context & 8192) &&
5093
- parser.tokenValue === 'arguments')
5094
- parser.report(132);
5134
+ parser.tokenValue === 'arguments' &&
5135
+ !(origin & 1 && parser.getToken() === 21))
5136
+ throw new ParseError(start, parser.startPosition, 132);
5095
5137
  if ((token & 255) === (241737 & 255)) {
5096
5138
  if (context & 1)
5097
5139
  parser.report(115);
@@ -5126,7 +5168,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
5126
5168
  case 69271571:
5127
5169
  return parseArrayLiteral(parser, context, privateScope, canAssign ? 0 : 1, inGroup);
5128
5170
  case 67174411:
5129
- return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, start, origin);
5171
+ return parseParenthesizedExpression(parser, context, privateScope, canAssign, 1, start, origin);
5130
5172
  case 86021:
5131
5173
  case 86022:
5132
5174
  case 86023:
@@ -5167,8 +5209,9 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
5167
5209
  if (parser.options.jsx)
5168
5210
  return parseJSXRootElementOrFragment(parser, context, privateScope, 0, parser.tokenStart);
5169
5211
  default:
5170
- if (isValidIdentifier(context, parser.getToken()))
5171
- return parseIdentifierOrArrow(parser, context, privateScope);
5212
+ if (isValidIdentifier(context, parser.getToken())) {
5213
+ return parseIdentifierOrArrow(parser, context, privateScope, 0, canAssign);
5214
+ }
5172
5215
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5173
5216
  }
5174
5217
  }
@@ -5569,6 +5612,8 @@ function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGro
5569
5612
  if (parser.destructible & 8) {
5570
5613
  parser.report(62);
5571
5614
  }
5615
+ if (expr.type === 'ArrayExpression')
5616
+ parser.assignable = 2;
5572
5617
  return expr;
5573
5618
  }
5574
5619
  function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
@@ -5680,8 +5725,10 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
5680
5725
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5681
5726
  }
5682
5727
  else {
5683
- left = parseLeftHandSideExpression(parser, context, privateScope, 1, 0, 1);
5728
+ left = parseLeftHandSideExpression(parser, context, privateScope, 1, 0, 1, context & 131072 ? 0 : 1);
5684
5729
  if (parser.getToken() !== 18 && parser.getToken() !== 20) {
5730
+ if (parser.getToken() !== 1077936155)
5731
+ destructible |= 16;
5685
5732
  left = parseAssignmentExpression(parser, context, privateScope, inGroup, isPattern, tokenStart, left);
5686
5733
  if ((kind & (2 | 1)) === 0 && token === 67174411)
5687
5734
  destructible |= 16;
@@ -5813,8 +5860,7 @@ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingT
5813
5860
  }
5814
5861
  else {
5815
5862
  destructible |= 32;
5816
- argument = parseLeftHandSideExpression(parser, context, privateScope, 1, inGroup, 1);
5817
- const { tokenStart } = parser;
5863
+ argument = parseLeftHandSideExpression(parser, context, privateScope, 1, inGroup, 1, context & 131072 ? 0 : 1);
5818
5864
  const token = parser.getToken();
5819
5865
  if (token === 1077936155) {
5820
5866
  if (parser.assignable & 2)
@@ -5890,7 +5936,8 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
5890
5936
  let scope = parser.createScopeIfLexical(256);
5891
5937
  const params = parseMethodFormals(parser, (context | 8192) & -524289, scope, privateScope, kind, 1, inGroup);
5892
5938
  scope = scope?.createChildScope(64);
5893
- const body = parseFunctionBody(parser, (context & -655373) |
5939
+ const body = parseFunctionBody(parser, (context &
5940
+ -655501) |
5894
5941
  32768 |
5895
5942
  4096, scope, privateScope, void 0, scope?.parent);
5896
5943
  return parser.finishNode({
@@ -5910,6 +5957,8 @@ function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGr
5910
5957
  if (parser.destructible & 8) {
5911
5958
  parser.report(62);
5912
5959
  }
5960
+ if (expr.type === 'ObjectExpression')
5961
+ parser.assignable = 2;
5913
5962
  return expr;
5914
5963
  }
5915
5964
  function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
@@ -5939,6 +5988,11 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
5939
5988
  parser.getToken() === 1074790415 ||
5940
5989
  parser.getToken() === 1077936155) {
5941
5990
  state |= 4;
5991
+ if (context & 16 &&
5992
+ !(context & 32768) &&
5993
+ !(context & 8192) &&
5994
+ tokenValue === 'arguments')
5995
+ throw new ParseError(tokenStart, currentLocation, 132);
5942
5996
  if (context & 1 && (token & 537079808) === 537079808) {
5943
5997
  destructible |= 16;
5944
5998
  }
@@ -6052,7 +6106,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
6052
6106
  }
6053
6107
  }
6054
6108
  else {
6055
- value = parseLeftHandSideExpression(parser, context, privateScope, 1, inGroup, 1);
6109
+ value = parseLeftHandSideExpression(parser, context, privateScope, 1, inGroup, 1, context & 131072 ? 0 : 1);
6056
6110
  destructible |=
6057
6111
  parser.assignable & 1
6058
6112
  ? 32
@@ -6233,7 +6287,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
6233
6287
  }
6234
6288
  }
6235
6289
  else {
6236
- value = parseLeftHandSideExpression(parser, context, privateScope, 1, 0, 1);
6290
+ value = parseLeftHandSideExpression(parser, context, privateScope, 1, 0, 1, context & 131072 ? 0 : 1);
6237
6291
  destructible |=
6238
6292
  parser.assignable & 1
6239
6293
  ? 32
@@ -6346,7 +6400,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
6346
6400
  }
6347
6401
  }
6348
6402
  else {
6349
- value = parseLeftHandSideExpression(parser, context, privateScope, 1, 0, 1);
6403
+ value = parseLeftHandSideExpression(parser, context, privateScope, 1, 0, 1, context & 131072 ? 0 : 1);
6350
6404
  destructible |=
6351
6405
  parser.assignable & 1
6352
6406
  ? 32
@@ -6479,7 +6533,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
6479
6533
  parser.flags |= 512;
6480
6534
  }
6481
6535
  }
6482
- left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
6536
+ left = parseAndClassifyIdentifier(parser, context, scope, type);
6483
6537
  }
6484
6538
  else {
6485
6539
  if (parser.getToken() === 2162700) {
@@ -6633,7 +6687,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
6633
6687
  expressions: expressions,
6634
6688
  }, tokenAfterParenthesesStart);
6635
6689
  }
6636
- consume(parser, context, 16);
6690
+ consume(parser, context | 64, 16);
6637
6691
  parser.destructible = destructible | previousAwaitYield;
6638
6692
  if (previousFirstAwaitLocation) {
6639
6693
  parser.firstAwaitLocation = previousFirstAwaitLocation;
@@ -6669,7 +6723,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
6669
6723
  expressions: expressions,
6670
6724
  }, tokenAfterParenthesesStart);
6671
6725
  }
6672
- consume(parser, context, 16);
6726
+ consume(parser, context | 64, 16);
6673
6727
  if (destructible & 16 && destructible & 8)
6674
6728
  parser.report(153);
6675
6729
  destructible |=
@@ -6724,7 +6778,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
6724
6778
  }, parenthesesStart)
6725
6779
  : expr;
6726
6780
  }
6727
- function parseIdentifierOrArrow(parser, context, privateScope, allowRegExp = 0) {
6781
+ function parseIdentifierOrArrow(parser, context, privateScope, allowRegExp = 0, canAssign = 1) {
6728
6782
  const { tokenValue, tokenStart, currentLocation } = parser;
6729
6783
  let isNonSimpleParameterList = 0;
6730
6784
  let hasStrictReserved = 0;
@@ -6737,6 +6791,8 @@ function parseIdentifierOrArrow(parser, context, privateScope, allowRegExp = 0)
6737
6791
  const expr = parseIdentifier(parser, context, allowRegExp);
6738
6792
  parser.assignable = 1;
6739
6793
  if (parser.getToken() === 10) {
6794
+ if (!canAssign)
6795
+ parser.report(57);
6740
6796
  const scope = parser.options.lexical
6741
6797
  ? createArrowHeadParsingScope(parser, context, tokenValue, tokenStart, currentLocation)
6742
6798
  : undefined;
@@ -6770,7 +6826,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
6770
6826
  if (parser.flags & 1)
6771
6827
  parser.report(48);
6772
6828
  consume(parser, context | 32, 10);
6773
- const modifierFlags = 1024 | 2048 | 8192 | 524288;
6829
+ const modifierFlags = 1024 | 2048 | 8192 | 524288 | 8;
6774
6830
  context = ((context | modifierFlags) ^ modifierFlags) | (isAsync ? 2048 : 0);
6775
6831
  const expression = parser.getToken() !== 2162700;
6776
6832
  let body;
@@ -6783,7 +6839,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
6783
6839
  }
6784
6840
  else {
6785
6841
  scope = scope?.createChildScope(64);
6786
- const modifierFlags = 4 | 131072 | 8;
6842
+ const modifierFlags = 4 | 128 | 131072 | 8;
6787
6843
  body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, void 0, void 0, 16);
6788
6844
  switch (parser.getToken()) {
6789
6845
  case 69271571:
@@ -6793,7 +6849,9 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
6793
6849
  parser.flags |= 8192;
6794
6850
  break;
6795
6851
  case 67108877:
6852
+ case 67108991:
6796
6853
  case 67174409:
6854
+ case 67174408:
6797
6855
  case 22:
6798
6856
  parser.report(119);
6799
6857
  case 67174411:
@@ -6950,9 +7008,9 @@ function parseNewExpression(parser, context, privateScope, inGroup) {
6950
7008
  }
6951
7009
  const expr = parsePrimaryExpression(parser, context, privateScope, 2, 1, 0, inGroup, 1, tokenStart);
6952
7010
  context = (context | 131072) ^ 131072;
7011
+ const callee = parseMemberExpressionNoCall(parser, context, privateScope, expr, inGroup, tokenStart);
6953
7012
  if (parser.getToken() === 67108991)
6954
7013
  parser.report(170);
6955
- const callee = parseMemberExpressionNoCall(parser, context, privateScope, expr, inGroup, tokenStart);
6956
7014
  parser.assignable = 2;
6957
7015
  return parser.finishNode({
6958
7016
  type: 'NewExpression',
@@ -7422,8 +7480,6 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
7422
7480
  }
7423
7481
  else if (token === -2147483526) {
7424
7482
  key = parseIdentifier(parser, context);
7425
- if (parser.getToken() !== 67174411)
7426
- parser.report(30, KeywordDescTable[parser.getToken() & 255]);
7427
7483
  }
7428
7484
  else {
7429
7485
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
@@ -7439,7 +7495,7 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
7439
7495
  }
7440
7496
  else if (parser.getToken() === 69271571) {
7441
7497
  kind |= 2;
7442
- key = parseComputedPropertyName(parser, context, privateScope, 0);
7498
+ key = parseComputedPropertyName(parser, inheritedContext, privateScope, 0);
7443
7499
  }
7444
7500
  else if (parser.getToken() === 131) {
7445
7501
  kind |= 8192;
@@ -7527,6 +7583,7 @@ function parsePropertyDefinition(parser, context, privateScope, key, state, deco
7527
7583
  2048 |
7528
7584
  8 |
7529
7585
  8192 |
7586
+ 32768 |
7530
7587
  ((state & 64) === 0 ? 512 | 16384 : 0);
7531
7588
  context =
7532
7589
  ((context | modifierFlags) ^ modifierFlags) |