meriyah 7.1.0 → 7.1.1

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,15 @@
1
+ ## [7.1.1](https://github.com/meriyah/meriyah/compare/v7.1.0...v7.1.1) (2026-07-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **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))
7
+ * **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)
8
+ * **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))
9
+ * **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)
10
+
11
+
12
+
1
13
  # [7.1.0](https://github.com/meriyah/meriyah/compare/v7.0.0...v7.1.0) (2026-02-04)
2
14
 
3
15
 
package/README.md CHANGED
@@ -80,8 +80,10 @@ The available options:
80
80
  // The flag to enable stage 3 support (ESNext), default `false`
81
81
  next: boolean;
82
82
 
83
- // The flag to enable start, end offsets and range: [start, end] to each node, default `false`
84
- ranges: boolean;
83
+ // Enable start/end offsets to each node, default `false`
84
+ // true: emit start, end, and range: [start, end] (backwards compatible)
85
+ // object: selectively enable { start, end, range } — e.g. { start: true, end: true }
86
+ ranges: boolean | { start?: boolean; end?: boolean; range?: boolean };
85
87
 
86
88
  // Enable web compatibility, default `false`
87
89
  webcompat: boolean;
package/dist/meriyah.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version$1 = "7.1.0";
3
+ var version$1 = "7.1.1";
4
4
 
5
5
  const unicodeLookup = ((compressed, lookup) => {
6
6
  const result = new Uint32Array(69632);
@@ -1550,7 +1550,7 @@ function parseEscape(parser, context, first, isTemplate = 0) {
1550
1550
  }
1551
1551
  case 56:
1552
1552
  case 57:
1553
- if (isTemplate || !parser.options.webcompat || context & 1)
1553
+ if (isTemplate || context & 1)
1554
1554
  return -3;
1555
1555
  parser.flags |= 4096;
1556
1556
  default:
@@ -4544,10 +4544,22 @@ function rescanJSXIdentifier(parser) {
4544
4544
  return parser.getToken();
4545
4545
  }
4546
4546
 
4547
+ function normalizeRanges(ranges) {
4548
+ if (!ranges)
4549
+ return undefined;
4550
+ if (ranges === true)
4551
+ return { start: true, end: true, range: true };
4552
+ return {
4553
+ start: ranges.start ?? false,
4554
+ end: ranges.end ?? false,
4555
+ range: ranges.range ?? false,
4556
+ };
4557
+ }
4547
4558
  function normalizeOptions(rawOptions) {
4548
4559
  const options = {
4549
4560
  validateRegex: true,
4550
4561
  ...rawOptions,
4562
+ ranges: normalizeRanges(rawOptions.ranges),
4551
4563
  };
4552
4564
  if (options.module && !options.sourceType) {
4553
4565
  options.sourceType = 'module';
@@ -4733,6 +4745,7 @@ class Parser {
4733
4745
  exportedBindings = new Set();
4734
4746
  assignable = 0;
4735
4747
  destructible = 0;
4748
+ strictReservedRange = null;
4736
4749
  leadingDecorators = { decorators: [] };
4737
4750
  constructor(source, rawOptions = {}) {
4738
4751
  this.source = source;
@@ -4789,11 +4802,15 @@ class Parser {
4789
4802
  return { index: this.index, line: this.line, column: this.column };
4790
4803
  }
4791
4804
  finishNode(node, start, end) {
4792
- if (this.options.ranges) {
4793
- node.start = start.index;
4805
+ const { ranges } = this.options;
4806
+ if (ranges) {
4794
4807
  const endIndex = end ? end.index : this.startIndex;
4795
- node.end = endIndex;
4796
- node.range = [start.index, endIndex];
4808
+ if (ranges.start)
4809
+ node.start = start.index;
4810
+ if (ranges.end)
4811
+ node.end = endIndex;
4812
+ if (ranges.range)
4813
+ node.range = [start.index, endIndex];
4797
4814
  }
4798
4815
  if (this.options.loc) {
4799
4816
  node.loc = {
@@ -4844,8 +4861,14 @@ class Parser {
4844
4861
  return this.cloneLocationInformation({ ...original }, original);
4845
4862
  }
4846
4863
  cloneLocationInformation(node, original) {
4847
- if (this.options.ranges) {
4848
- node.range = [...original.range];
4864
+ const { ranges } = this.options;
4865
+ if (ranges) {
4866
+ if (ranges.start)
4867
+ node.start = original.start;
4868
+ if (ranges.end)
4869
+ node.end = original.end;
4870
+ if (ranges.range)
4871
+ node.range = [...original.range];
4849
4872
  }
4850
4873
  if (this.options.loc) {
4851
4874
  node.loc = {
@@ -4863,10 +4886,14 @@ function pushComment(comments, options) {
4863
4886
  type,
4864
4887
  value,
4865
4888
  };
4866
- if (options.ranges) {
4867
- comment.start = start;
4868
- comment.end = end;
4869
- comment.range = [start, end];
4889
+ const { ranges } = options;
4890
+ if (ranges) {
4891
+ if (ranges.start)
4892
+ comment.start = start;
4893
+ if (ranges.end)
4894
+ comment.end = end;
4895
+ if (ranges.range)
4896
+ comment.range = [start, end];
4870
4897
  }
4871
4898
  if (options.loc) {
4872
4899
  comment.loc = loc;
@@ -4879,10 +4906,14 @@ function pushToken(tokens, options) {
4879
4906
  const token = {
4880
4907
  token: type,
4881
4908
  };
4882
- if (options.ranges) {
4883
- token.start = start;
4884
- token.end = end;
4885
- token.range = [start, end];
4909
+ const { ranges } = options;
4910
+ if (ranges) {
4911
+ if (ranges.start)
4912
+ token.start = start;
4913
+ if (ranges.end)
4914
+ token.end = end;
4915
+ if (ranges.range)
4916
+ token.range = [start, end];
4886
4917
  }
4887
4918
  if (options.loc) {
4888
4919
  token.loc = loc;
@@ -5521,7 +5552,7 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
5521
5552
  if (parser.getToken() === 1077936155) {
5522
5553
  nextToken(parser, context | 32);
5523
5554
  init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5524
- if (origin & 32 || (token & 2097152) === 0) {
5555
+ if (origin & 32) {
5525
5556
  if (parser.getToken() === 471156 ||
5526
5557
  (parser.getToken() === 8673330 &&
5527
5558
  (token & 2097152 || (kind & 4) === 0 || context & 1))) {
@@ -6268,8 +6299,12 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
6268
6299
  }
6269
6300
  if (parser.flags & 512)
6270
6301
  parser.report(119);
6271
- if (parser.flags & 256)
6302
+ if (parser.flags & 256) {
6303
+ if (parser.strictReservedRange) {
6304
+ throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 118);
6305
+ }
6272
6306
  parser.report(118);
6307
+ }
6273
6308
  }
6274
6309
  }
6275
6310
  parser.flags =
@@ -6354,6 +6389,10 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
6354
6389
  break;
6355
6390
  }
6356
6391
  case 69271571: {
6392
+ if ((parser.flags & 8192) === 8192) {
6393
+ parser.flags = (parser.flags | 8192) ^ 8192;
6394
+ return expr;
6395
+ }
6357
6396
  let restoreHasOptionalChaining = false;
6358
6397
  if ((parser.flags & 2048) === 2048) {
6359
6398
  restoreHasOptionalChaining = true;
@@ -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;