meriyah 7.1.0 → 7.1.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,24 @@
1
+ ## [7.1.2](https://github.com/meriyah/meriyah/compare/v7.1.1...v7.1.2) (2026-07-11)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **lexer:** reject empty unicode code point escape \u{} ([#562](https://github.com/meriyah/meriyah/issues/562)) ([6dd2bba](https://github.com/meriyah/meriyah/commit/6dd2bba7bf9375f751ee9214526e4592702dab9d))
6
+ * **parser:** mark template literal with substitutions as invalid assignment target ([#563](https://github.com/meriyah/meriyah/issues/563)) ([addcad6](https://github.com/meriyah/meriyah/commit/addcad684d5f1e13bcaebe8e97db7ca39370f603))
7
+ * **parser:** parse get and set fields before generators ([#576](https://github.com/meriyah/meriyah/issues/576)) ([cad0605](https://github.com/meriyah/meriyah/commit/cad06053fc9ee16a2217f84ca46d45d9b25c17e7))
8
+ * **parser:** treat let as identifier before in and instanceof ([#577](https://github.com/meriyah/meriyah/issues/577)) ([4a08591](https://github.com/meriyah/meriyah/commit/4a085918dce320f39b535a15eafb774a0b4b90b0))
9
+
10
+ ## [7.1.1](https://github.com/meriyah/meriyah/compare/v7.1.0...v7.1.1) (2026-07-05)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **lexer:** accept \8 and \9 escapes in sloppy mode ([#559](https://github.com/meriyah/meriyah/issues/559)) ([8938494](https://github.com/meriyah/meriyah/commit/893849491bb493cd7e72280e82c4fb344915a4cb))
16
+ * **parser:** fix for-of initializer check ([#549](https://github.com/meriyah/meriyah/issues/549)) ([72952d1](https://github.com/meriyah/meriyah/commit/72952d144b5f8a2715c72ba54c50e42e987dc4a8)), closes [#548](https://github.com/meriyah/meriyah/issues/548)
17
+ * **parser:** fix the invoke check after arrow function when newline is involved ([#551](https://github.com/meriyah/meriyah/issues/551)) ([c6904bc](https://github.com/meriyah/meriyah/commit/c6904bce68ec824ca7dc9a42a7e5eb6352eddd47))
18
+ * **parser:** report strict reserved parameters at their original range ([#558](https://github.com/meriyah/meriyah/issues/558)) ([842e276](https://github.com/meriyah/meriyah/commit/842e2768bf76f920a303df375e07eb6dcd085fb1)), closes [#470](https://github.com/meriyah/meriyah/issues/470)
19
+
20
+
21
+
1
22
  # [7.1.0](https://github.com/meriyah/meriyah/compare/v7.0.0...v7.1.0) (2026-02-04)
2
23
 
3
24
 
package/README.md CHANGED
@@ -26,6 +26,10 @@
26
26
  - No backtracking
27
27
  - Low memory usage
28
28
 
29
+ ### Not yet supported features:
30
+
31
+ - [Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management)
32
+
29
33
  ## ESNext Stage 3 features
30
34
 
31
35
  ### Supported stage 3 features:
@@ -33,12 +37,11 @@
33
37
  These features need to be enabled with the `next` option.
34
38
 
35
39
  - [Decorators](https://github.com/tc39/proposal-decorators)
36
- - [JSON Modules](https://github.com/tc39/proposal-json-modules)
37
40
 
38
41
  ### Not yet supported stage 3 features:
39
42
 
40
- - [Explicit resource management](https://github.com/tc39/proposal-explicit-resource-management)
41
- - [Source phase import](https://github.com/tc39/proposal-source-phase-imports)
43
+ - [Source Phase Imports](https://github.com/tc39/proposal-source-phase-imports)
44
+ - [Deferring Module Evaluation](https://github.com/tc39/proposal-defer-import-eval)
42
45
 
43
46
  ## RegExp support
44
47
 
@@ -80,8 +83,10 @@ The available options:
80
83
  // The flag to enable stage 3 support (ESNext), default `false`
81
84
  next: boolean;
82
85
 
83
- // The flag to enable start, end offsets and range: [start, end] to each node, default `false`
84
- ranges: boolean;
86
+ // Enable start/end offsets to each node, default `false`
87
+ // true: emit start, end, and range: [start, end] (backwards compatible)
88
+ // object: selectively enable { start, end, range } — e.g. { start: true, end: true }
89
+ ranges: boolean | { start?: boolean; end?: boolean; range?: boolean };
85
90
 
86
91
  // Enable web compatibility, default `false`
87
92
  webcompat: boolean;
package/dist/meriyah.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var version$1 = "7.1.0";
3
+ var version$1 = "7.1.2";
4
+ var packageJson = {
5
+ version: version$1};
4
6
 
5
7
  const unicodeLookup = ((compressed, lookup) => {
6
8
  const result = new Uint32Array(69632);
@@ -1520,12 +1522,14 @@ function parseEscape(parser, context, first, isTemplate = 0) {
1520
1522
  const ch = advanceChar(parser);
1521
1523
  if (parser.currentChar === 123) {
1522
1524
  let code = 0;
1525
+ let digits = 0;
1523
1526
  while ((CharTypes[advanceChar(parser)] & 64) !== 0) {
1524
1527
  code = (code << 4) | toHex(parser.currentChar);
1525
1528
  if (code > 1114111)
1526
1529
  return -5;
1530
+ digits++;
1527
1531
  }
1528
- if (parser.currentChar < 1 || parser.currentChar !== 125) {
1532
+ if (digits === 0 || parser.currentChar < 1 || parser.currentChar !== 125) {
1529
1533
  return -4;
1530
1534
  }
1531
1535
  return code;
@@ -1550,7 +1554,7 @@ function parseEscape(parser, context, first, isTemplate = 0) {
1550
1554
  }
1551
1555
  case 56:
1552
1556
  case 57:
1553
- if (isTemplate || !parser.options.webcompat || context & 1)
1557
+ if (isTemplate || context & 1)
1554
1558
  return -3;
1555
1559
  parser.flags |= 4096;
1556
1560
  default:
@@ -4544,10 +4548,22 @@ function rescanJSXIdentifier(parser) {
4544
4548
  return parser.getToken();
4545
4549
  }
4546
4550
 
4551
+ function normalizeRanges(ranges) {
4552
+ if (!ranges)
4553
+ return undefined;
4554
+ if (ranges === true)
4555
+ return { start: true, end: true, range: true };
4556
+ return {
4557
+ start: ranges.start ?? false,
4558
+ end: ranges.end ?? false,
4559
+ range: ranges.range ?? false,
4560
+ };
4561
+ }
4547
4562
  function normalizeOptions(rawOptions) {
4548
4563
  const options = {
4549
4564
  validateRegex: true,
4550
4565
  ...rawOptions,
4566
+ ranges: normalizeRanges(rawOptions.ranges),
4551
4567
  };
4552
4568
  if (options.module && !options.sourceType) {
4553
4569
  options.sourceType = 'module';
@@ -4733,6 +4749,7 @@ class Parser {
4733
4749
  exportedBindings = new Set();
4734
4750
  assignable = 0;
4735
4751
  destructible = 0;
4752
+ strictReservedRange = null;
4736
4753
  leadingDecorators = { decorators: [] };
4737
4754
  constructor(source, rawOptions = {}) {
4738
4755
  this.source = source;
@@ -4789,11 +4806,15 @@ class Parser {
4789
4806
  return { index: this.index, line: this.line, column: this.column };
4790
4807
  }
4791
4808
  finishNode(node, start, end) {
4792
- if (this.options.ranges) {
4793
- node.start = start.index;
4809
+ const { ranges } = this.options;
4810
+ if (ranges) {
4794
4811
  const endIndex = end ? end.index : this.startIndex;
4795
- node.end = endIndex;
4796
- node.range = [start.index, endIndex];
4812
+ if (ranges.start)
4813
+ node.start = start.index;
4814
+ if (ranges.end)
4815
+ node.end = endIndex;
4816
+ if (ranges.range)
4817
+ node.range = [start.index, endIndex];
4797
4818
  }
4798
4819
  if (this.options.loc) {
4799
4820
  node.loc = {
@@ -4844,8 +4865,14 @@ class Parser {
4844
4865
  return this.cloneLocationInformation({ ...original }, original);
4845
4866
  }
4846
4867
  cloneLocationInformation(node, original) {
4847
- if (this.options.ranges) {
4848
- node.range = [...original.range];
4868
+ const { ranges } = this.options;
4869
+ if (ranges) {
4870
+ if (ranges.start)
4871
+ node.start = original.start;
4872
+ if (ranges.end)
4873
+ node.end = original.end;
4874
+ if (ranges.range)
4875
+ node.range = [...original.range];
4849
4876
  }
4850
4877
  if (this.options.loc) {
4851
4878
  node.loc = {
@@ -4863,10 +4890,14 @@ function pushComment(comments, options) {
4863
4890
  type,
4864
4891
  value,
4865
4892
  };
4866
- if (options.ranges) {
4867
- comment.start = start;
4868
- comment.end = end;
4869
- comment.range = [start, end];
4893
+ const { ranges } = options;
4894
+ if (ranges) {
4895
+ if (ranges.start)
4896
+ comment.start = start;
4897
+ if (ranges.end)
4898
+ comment.end = end;
4899
+ if (ranges.range)
4900
+ comment.range = [start, end];
4870
4901
  }
4871
4902
  if (options.loc) {
4872
4903
  comment.loc = loc;
@@ -4879,10 +4910,14 @@ function pushToken(tokens, options) {
4879
4910
  const token = {
4880
4911
  token: type,
4881
4912
  };
4882
- if (options.ranges) {
4883
- token.start = start;
4884
- token.end = end;
4885
- token.range = [start, end];
4913
+ const { ranges } = options;
4914
+ if (ranges) {
4915
+ if (ranges.start)
4916
+ token.start = start;
4917
+ if (ranges.end)
4918
+ token.end = end;
4919
+ if (ranges.range)
4920
+ token.range = [start, end];
4886
4921
  }
4887
4922
  if (options.loc) {
4888
4923
  token.loc = loc;
@@ -4901,7 +4936,7 @@ function parseSource(source, rawOptions = {}, context = 0) {
4901
4936
  context |= 1;
4902
4937
  skipHashBang(parser);
4903
4938
  const scope = parser.createScopeIfLexical();
4904
- let body = [];
4939
+ let body;
4905
4940
  let sourceType = 'script';
4906
4941
  if (context & 2) {
4907
4942
  sourceType = 'module';
@@ -5394,7 +5429,6 @@ function parseTryStatement(parser, context, scope, privateScope, labels) {
5394
5429
  }
5395
5430
  function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
5396
5431
  let param = null;
5397
- let additionalScope = scope;
5398
5432
  if (consumeOpt(parser, context, 67174411)) {
5399
5433
  scope = scope?.createChildScope(4);
5400
5434
  param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
@@ -5408,7 +5442,7 @@ function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
5408
5442
  }
5409
5443
  consume(parser, context | 32, 16);
5410
5444
  }
5411
- additionalScope = scope?.createChildScope(32);
5445
+ const additionalScope = scope?.createChildScope(32);
5412
5446
  const body = parseBlock(parser, context, additionalScope, privateScope, { $: labels });
5413
5447
  return parser.finishNode({
5414
5448
  type: 'CatchClause',
@@ -5446,7 +5480,8 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
5446
5480
  const { tokenValue, tokenStart } = parser;
5447
5481
  const token = parser.getToken();
5448
5482
  let expr = parseIdentifier(parser, context);
5449
- if (parser.getToken() & (143360 | 2097152)) {
5483
+ if (parser.getToken() & (143360 | 2097152) &&
5484
+ (parser.getToken() & 20480) !== 20480) {
5450
5485
  const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8, 0);
5451
5486
  matchOrInsertSemicolon(parser, context | 32);
5452
5487
  return parser.finishNode({
@@ -5521,7 +5556,7 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
5521
5556
  if (parser.getToken() === 1077936155) {
5522
5557
  nextToken(parser, context | 32);
5523
5558
  init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5524
- if (origin & 32 || (token & 2097152) === 0) {
5559
+ if (origin & 32) {
5525
5560
  if (parser.getToken() === 471156 ||
5526
5561
  (parser.getToken() === 8673330 &&
5527
5562
  (token & 2097152 || (kind & 4) === 0 || context & 1))) {
@@ -5559,18 +5594,13 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5559
5594
  if (isVarDecl) {
5560
5595
  if (token === 241737) {
5561
5596
  init = parseIdentifier(parser, context);
5562
- if (parser.getToken() & (143360 | 2097152)) {
5563
- if (parser.getToken() === 8673330) {
5564
- if (context & 1)
5565
- parser.report(67);
5566
- }
5567
- else {
5568
- init = parser.finishNode({
5569
- type: 'VariableDeclaration',
5570
- kind: 'let',
5571
- declarations: parseVariableDeclarationList(parser, context | 131072, scope, privateScope, 8, 32),
5572
- }, tokenStart);
5573
- }
5597
+ if (parser.getToken() & (143360 | 2097152) &&
5598
+ (parser.getToken() & 20480) !== 20480) {
5599
+ init = parser.finishNode({
5600
+ type: 'VariableDeclaration',
5601
+ kind: 'let',
5602
+ declarations: parseVariableDeclarationList(parser, context | 131072, scope, privateScope, 8, 32),
5603
+ }, tokenStart);
5574
5604
  parser.assignable = 1;
5575
5605
  }
5576
5606
  else if (context & 1) {
@@ -5691,7 +5721,7 @@ function parseRestrictedIdentifier(parser, context, scope) {
5691
5721
  function parseImportDeclaration(parser, context, scope) {
5692
5722
  const start = parser.tokenStart;
5693
5723
  nextToken(parser, context);
5694
- let source = null;
5724
+ let source;
5695
5725
  const { tokenStart } = parser;
5696
5726
  let specifiers = [];
5697
5727
  if (parser.getToken() === 134283267) {
@@ -6268,8 +6298,12 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
6268
6298
  }
6269
6299
  if (parser.flags & 512)
6270
6300
  parser.report(119);
6271
- if (parser.flags & 256)
6301
+ if (parser.flags & 256) {
6302
+ if (parser.strictReservedRange) {
6303
+ throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 118);
6304
+ }
6272
6305
  parser.report(118);
6306
+ }
6273
6307
  }
6274
6308
  }
6275
6309
  parser.flags =
@@ -6354,6 +6388,10 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
6354
6388
  break;
6355
6389
  }
6356
6390
  case 69271571: {
6391
+ if ((parser.flags & 8192) === 8192) {
6392
+ parser.flags = (parser.flags | 8192) ^ 8192;
6393
+ return expr;
6394
+ }
6357
6395
  let restoreHasOptionalChaining = false;
6358
6396
  if ((parser.flags & 2048) === 2048) {
6359
6397
  restoreHasOptionalChaining = true;
@@ -6776,6 +6814,7 @@ function parseTemplate(parser, context, privateScope) {
6776
6814
  consume(parser, context, 67174409);
6777
6815
  quasis.push(parseTemplateElement(parser, tokenValue, tokenRaw, tokenStart, true));
6778
6816
  }
6817
+ parser.assignable = 2;
6779
6818
  return parser.finishNode({
6780
6819
  type: 'TemplateLiteral',
6781
6820
  expressions,
@@ -6792,11 +6831,16 @@ function parseTemplateElement(parser, cooked, raw, start, tail) {
6792
6831
  tail,
6793
6832
  }, start);
6794
6833
  const tailSize = tail ? 1 : 2;
6795
- if (parser.options.ranges) {
6796
- node.start += 1;
6797
- node.range[0] += 1;
6798
- node.end -= tailSize;
6799
- node.range[1] -= tailSize;
6834
+ const { ranges } = parser.options;
6835
+ if (ranges) {
6836
+ if (ranges.start)
6837
+ node.start += 1;
6838
+ if (ranges.end)
6839
+ node.end -= tailSize;
6840
+ if (ranges.range) {
6841
+ node.range[0] += 1;
6842
+ node.range[1] -= tailSize;
6843
+ }
6800
6844
  }
6801
6845
  if (parser.options.loc) {
6802
6846
  node.loc.start.column += 1;
@@ -7886,6 +7930,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
7886
7930
  consume(parser, context, 67174411);
7887
7931
  const params = [];
7888
7932
  parser.flags = (parser.flags | 128) ^ 128;
7933
+ parser.strictReservedRange = null;
7889
7934
  if (parser.getToken() === 16) {
7890
7935
  if (kind & 512) {
7891
7936
  parser.report(37, 'Setter', 'one', '');
@@ -7909,6 +7954,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
7909
7954
  if ((context & 1) === 0) {
7910
7955
  if ((parser.getToken() & 36864) === 36864) {
7911
7956
  parser.flags |= 256;
7957
+ parser.strictReservedRange ??= [tokenStart, parser.currentLocation];
7912
7958
  }
7913
7959
  if ((parser.getToken() & 537079808) === 537079808) {
7914
7960
  parser.flags |= 512;
@@ -8193,6 +8239,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8193
8239
  if ((parser.flags & 1) === 0) {
8194
8240
  parser.report(116);
8195
8241
  }
8242
+ parser.flags |= 8192;
8196
8243
  break;
8197
8244
  case 67108877:
8198
8245
  case 67174409:
@@ -8223,6 +8270,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8223
8270
  function parseFormalParametersOrFormalList(parser, context, scope, privateScope, inGroup, kind) {
8224
8271
  consume(parser, context, 67174411);
8225
8272
  parser.flags = (parser.flags | 128) ^ 128;
8273
+ parser.strictReservedRange = null;
8226
8274
  const params = [];
8227
8275
  if (consumeOpt(parser, context, 16))
8228
8276
  return params;
@@ -8236,6 +8284,7 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
8236
8284
  if ((context & 1) === 0) {
8237
8285
  if ((token & 36864) === 36864) {
8238
8286
  parser.flags |= 256;
8287
+ parser.strictReservedRange ??= [tokenStart, parser.currentLocation];
8239
8288
  }
8240
8289
  if ((token & 537079808) === 537079808) {
8241
8290
  parser.flags |= 512;
@@ -8399,7 +8448,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8399
8448
  }, start);
8400
8449
  }
8401
8450
  let destructible = 0;
8402
- let expr = null;
8451
+ let expr;
8403
8452
  let isNonSimpleParameterList = 0;
8404
8453
  parser.destructible =
8405
8454
  (parser.destructible | 256 | 128) ^
@@ -8709,6 +8758,9 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8709
8758
  break;
8710
8759
  case 209008:
8711
8760
  if (parser.getToken() !== 67174411) {
8761
+ if (parser.getToken() === 8391476 && parser.flags & 1) {
8762
+ return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8763
+ }
8712
8764
  if ((parser.getToken() & 1073741824) === 1073741824) {
8713
8765
  return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8714
8766
  }
@@ -8717,6 +8769,9 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8717
8769
  break;
8718
8770
  case 209009:
8719
8771
  if (parser.getToken() !== 67174411) {
8772
+ if (parser.getToken() === 8391476 && parser.flags & 1) {
8773
+ return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8774
+ }
8720
8775
  if ((parser.getToken() & 1073741824) === 1073741824) {
8721
8776
  return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8722
8777
  }
@@ -9179,7 +9234,7 @@ function parseJSXExpressionContainer(parser, context, privateScope, inJSXChild,
9179
9234
  const { tokenStart } = parser;
9180
9235
  if (parser.getToken() === 14)
9181
9236
  return parseJSXSpreadChild(parser, context, privateScope, start);
9182
- let expression = null;
9237
+ let expression;
9183
9238
  if (parser.getToken() === 1074790415) {
9184
9239
  if (isAttr)
9185
9240
  parser.report(157);
@@ -9233,7 +9288,7 @@ function parseJSXIdentifier(parser, context) {
9233
9288
  }, start);
9234
9289
  }
9235
9290
 
9236
- const version = version$1;
9291
+ const { version } = packageJson;
9237
9292
  function parseScript(source, options) {
9238
9293
  return parseSource(source, { ...options, sourceType: 'script' });
9239
9294
  }