meriyah 7.0.0 → 7.1.0
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 +19 -0
- package/README.md +18 -1
- package/dist/meriyah.cjs +76 -38
- package/dist/meriyah.min.mjs +1 -1
- package/dist/meriyah.mjs +76 -39
- package/dist/meriyah.umd.js +76 -38
- package/dist/meriyah.umd.min.js +1 -1
- package/dist/types/common.d.ts +4 -3
- package/dist/types/errors.d.ts +1 -0
- package/dist/types/meriyah.d.ts +1 -0
- package/dist/types/parser/parser.d.ts +3 -3
- package/dist/types/token.d.ts +3 -3
- package/package.json +1 -66
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# [7.1.0](https://github.com/meriyah/meriyah/compare/v7.0.0...v7.1.0) (2026-02-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add `isParseError()` for brand check ([#541](https://github.com/meriyah/meriyah/issues/541)) ([c5443c4](https://github.com/meriyah/meriyah/commit/c5443c4ac0abb9f25e6f176a7947f9b61e299c5d))
|
|
7
|
+
* assign to CallExpression is now runtime error in annexB ([#546](https://github.com/meriyah/meriyah/issues/546)) ([5835016](https://github.com/meriyah/meriyah/commit/5835016ddcf3f16807ef87c41661a18c3038f131))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
1
11
|
# [7.0.0](https://github.com/meriyah/meriyah/compare/v6.1.4...v7.0.0) (2025-11-27)
|
|
2
12
|
|
|
3
13
|
|
|
@@ -15,6 +25,15 @@
|
|
|
15
25
|
* support unicode 17 ([#532](https://github.com/meriyah/meriyah/issues/532)) ([de36a18](https://github.com/meriyah/meriyah/commit/de36a1894c8098695f2a80bd1092dc627ded6dec))
|
|
16
26
|
|
|
17
27
|
|
|
28
|
+
### BREAKING CHANGES
|
|
29
|
+
|
|
30
|
+
- drop support of Node.js below v20 (#518)
|
|
31
|
+
- remove `uniqueKeyInpattern` option, nodes are always unique in shorthand pattern (#519)
|
|
32
|
+
- add `sourceType`, deprecate `module` option (#521)
|
|
33
|
+
- add `sourceType: 'commonjs'`, deprecate `globalReturn` option (#523)
|
|
34
|
+
- forbid passing option `sourceType` in `parseScript` and `parseModule` APIs (#465)
|
|
35
|
+
|
|
36
|
+
|
|
18
37
|
|
|
19
38
|
## [6.1.4](https://github.com/meriyah/meriyah/compare/v6.1.3...v6.1.4) (2025-07-02)
|
|
20
39
|
|
package/README.md
CHANGED
|
@@ -66,7 +66,6 @@ Meriyah generates `AST` according to [ESTree AST format](https://github.com/estr
|
|
|
66
66
|
The `parse` method exposed by meriyah takes an optional `options` object which allows you to specify whether to parse in [`script`](https://tc39.github.io/ecma262/#sec-parse-script) mode (the default) or in [`module`](https://tc39.github.io/ecma262/#sec-parsemodule) mode.
|
|
67
67
|
|
|
68
68
|
```js
|
|
69
|
-
// There are also "parseScript" and "parseModule" exported.
|
|
70
69
|
import { parse } from 'meriyah';
|
|
71
70
|
const result = parse('let some = "code";', { ranges: true });
|
|
72
71
|
```
|
|
@@ -144,6 +143,24 @@ If a function callback is supplied, the signature must be
|
|
|
144
143
|
declare function onInsertedSemicolon(position: number): void;
|
|
145
144
|
```
|
|
146
145
|
|
|
146
|
+
### `isParseError`
|
|
147
|
+
|
|
148
|
+
Exposed for error instance checking.
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
import { parse, isParseError } from './meriyah';
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
parse('invalid code');
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (isParseError(error)) {
|
|
157
|
+
console.error(error.description);
|
|
158
|
+
} else {
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
147
164
|
## Example usage
|
|
148
165
|
|
|
149
166
|
```js
|
package/dist/meriyah.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version$1 = "7.
|
|
3
|
+
var version$1 = "7.1.0";
|
|
4
4
|
|
|
5
5
|
const unicodeLookup = ((compressed, lookup) => {
|
|
6
6
|
const result = new Uint32Array(69632);
|
|
@@ -807,6 +807,7 @@ class ParseError extends SyntaxError {
|
|
|
807
807
|
this.description = description;
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
|
+
const isParseError = (error) => error instanceof ParseError;
|
|
810
811
|
|
|
811
812
|
function getOwnProperty(object, key) {
|
|
812
813
|
return Object.hasOwn(object, key) ? object[key] : undefined;
|
|
@@ -2005,7 +2006,7 @@ function scanSingleToken(parser, context, state) {
|
|
|
2005
2006
|
advanceChar(parser);
|
|
2006
2007
|
if (parser.currentChar === 61) {
|
|
2007
2008
|
advanceChar(parser);
|
|
2008
|
-
return
|
|
2009
|
+
return 4718632;
|
|
2009
2010
|
}
|
|
2010
2011
|
return 8913465;
|
|
2011
2012
|
}
|
|
@@ -2048,7 +2049,7 @@ function scanSingleToken(parser, context, state) {
|
|
|
2048
2049
|
advanceChar(parser);
|
|
2049
2050
|
if (parser.currentChar === 61) {
|
|
2050
2051
|
advanceChar(parser);
|
|
2051
|
-
return
|
|
2052
|
+
return 4718633;
|
|
2052
2053
|
}
|
|
2053
2054
|
return 8913720;
|
|
2054
2055
|
}
|
|
@@ -2064,7 +2065,7 @@ function scanSingleToken(parser, context, state) {
|
|
|
2064
2065
|
advanceChar(parser);
|
|
2065
2066
|
if (parser.currentChar === 61) {
|
|
2066
2067
|
advanceChar(parser);
|
|
2067
|
-
return
|
|
2068
|
+
return 4718634;
|
|
2068
2069
|
}
|
|
2069
2070
|
return 276824445;
|
|
2070
2071
|
}
|
|
@@ -4730,7 +4731,7 @@ class Parser {
|
|
|
4730
4731
|
currentChar = 0;
|
|
4731
4732
|
exportedNames = new Set();
|
|
4732
4733
|
exportedBindings = new Set();
|
|
4733
|
-
assignable =
|
|
4734
|
+
assignable = 0;
|
|
4734
4735
|
destructible = 0;
|
|
4735
4736
|
leadingDecorators = { decorators: [] };
|
|
4736
4737
|
constructor(source, rawOptions = {}) {
|
|
@@ -6019,6 +6020,8 @@ function parseAssignmentExpression(parser, context, privateScope, inGroup, isPat
|
|
|
6019
6020
|
if ((token & 4194304) === 4194304) {
|
|
6020
6021
|
if (parser.assignable & 2)
|
|
6021
6022
|
parser.report(26);
|
|
6023
|
+
if ((token & 524288) === 524288 && parser.assignable & 4)
|
|
6024
|
+
parser.report(26);
|
|
6022
6025
|
if ((!isPattern && token === 1077936155 && left.type === 'ArrayExpression') ||
|
|
6023
6026
|
left.type === 'ObjectExpression') {
|
|
6024
6027
|
reinterpretToPattern(parser, left);
|
|
@@ -6384,7 +6387,12 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
|
|
|
6384
6387
|
parser.flags = (parser.flags | 2048) ^ 2048;
|
|
6385
6388
|
}
|
|
6386
6389
|
const args = parseArguments(parser, context, privateScope, inGroup);
|
|
6387
|
-
parser.
|
|
6390
|
+
if (!(context & 1) && parser.options.webcompat) {
|
|
6391
|
+
parser.assignable = 4;
|
|
6392
|
+
}
|
|
6393
|
+
else {
|
|
6394
|
+
parser.assignable = 2;
|
|
6395
|
+
}
|
|
6388
6396
|
expr = parser.finishNode({
|
|
6389
6397
|
type: 'CallExpression',
|
|
6390
6398
|
callee: expr,
|
|
@@ -6452,7 +6460,12 @@ function parseOptionalChain(parser, context, privateScope, expr, start) {
|
|
|
6452
6460
|
}
|
|
6453
6461
|
else if (parser.getToken() === 67174411) {
|
|
6454
6462
|
const args = parseArguments(parser, context, privateScope, 0);
|
|
6455
|
-
parser.
|
|
6463
|
+
if (!(context & 1) && parser.options.webcompat) {
|
|
6464
|
+
parser.assignable = 4;
|
|
6465
|
+
}
|
|
6466
|
+
else {
|
|
6467
|
+
parser.assignable = 2;
|
|
6468
|
+
}
|
|
6456
6469
|
node = parser.finishNode({
|
|
6457
6470
|
type: 'CallExpression',
|
|
6458
6471
|
callee: expr,
|
|
@@ -7057,9 +7070,9 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
|
|
|
7057
7070
|
}
|
|
7058
7071
|
else if (parser.getToken() !== 1077936155) {
|
|
7059
7072
|
destructible |=
|
|
7060
|
-
parser.assignable &
|
|
7061
|
-
?
|
|
7062
|
-
:
|
|
7073
|
+
parser.assignable & 1
|
|
7074
|
+
? 32
|
|
7075
|
+
: 16;
|
|
7063
7076
|
}
|
|
7064
7077
|
}
|
|
7065
7078
|
}
|
|
@@ -7089,9 +7102,9 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
|
|
|
7089
7102
|
}
|
|
7090
7103
|
else if (parser.getToken() !== 1077936155) {
|
|
7091
7104
|
destructible |=
|
|
7092
|
-
parser.assignable &
|
|
7093
|
-
?
|
|
7094
|
-
:
|
|
7105
|
+
parser.assignable & 1
|
|
7106
|
+
? 32
|
|
7107
|
+
: 16;
|
|
7095
7108
|
}
|
|
7096
7109
|
}
|
|
7097
7110
|
}
|
|
@@ -7208,7 +7221,7 @@ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingT
|
|
|
7208
7221
|
if (parser.destructible & 8)
|
|
7209
7222
|
parser.report(71);
|
|
7210
7223
|
argument = parseMemberOrUpdateExpression(parser, context, privateScope, argument, inGroup, 0, tokenStart);
|
|
7211
|
-
destructible |= parser.assignable &
|
|
7224
|
+
destructible |= parser.assignable & 1 ? 0 : 16;
|
|
7212
7225
|
if ((parser.getToken() & 4194304) === 4194304) {
|
|
7213
7226
|
if (parser.getToken() !== 1077936155)
|
|
7214
7227
|
destructible |= 16;
|
|
@@ -7222,9 +7235,9 @@ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingT
|
|
|
7222
7235
|
argument = parseConditionalExpression(parser, context, privateScope, argument, tokenStart);
|
|
7223
7236
|
}
|
|
7224
7237
|
destructible |=
|
|
7225
|
-
parser.assignable &
|
|
7226
|
-
?
|
|
7227
|
-
:
|
|
7238
|
+
parser.assignable & 1
|
|
7239
|
+
? 32
|
|
7240
|
+
: 16;
|
|
7228
7241
|
}
|
|
7229
7242
|
}
|
|
7230
7243
|
else {
|
|
@@ -7253,7 +7266,9 @@ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingT
|
|
|
7253
7266
|
argument = parseAssignmentExpression(parser, context, privateScope, inGroup, isPattern, tokenStart, argument);
|
|
7254
7267
|
}
|
|
7255
7268
|
destructible |=
|
|
7256
|
-
parser.assignable & 1
|
|
7269
|
+
parser.assignable & 1
|
|
7270
|
+
? 32
|
|
7271
|
+
: 16;
|
|
7257
7272
|
}
|
|
7258
7273
|
parser.destructible = destructible;
|
|
7259
7274
|
if (parser.getToken() !== closingToken && parser.getToken() !== 18)
|
|
@@ -7445,7 +7460,9 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7445
7460
|
: parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, inGroup, isPattern, kind, origin);
|
|
7446
7461
|
destructible = parser.destructible;
|
|
7447
7462
|
parser.assignable =
|
|
7448
|
-
destructible & 16
|
|
7463
|
+
destructible & 16
|
|
7464
|
+
? 2
|
|
7465
|
+
: 1;
|
|
7449
7466
|
if (parser.getToken() === 18 || parser.getToken() === 1074790415) {
|
|
7450
7467
|
if (parser.assignable & 2)
|
|
7451
7468
|
destructible |= 16;
|
|
@@ -7467,9 +7484,9 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7467
7484
|
value = parseConditionalExpression(parser, context, privateScope, value, tokenStart);
|
|
7468
7485
|
}
|
|
7469
7486
|
destructible |=
|
|
7470
|
-
parser.assignable &
|
|
7471
|
-
?
|
|
7472
|
-
:
|
|
7487
|
+
parser.assignable & 1
|
|
7488
|
+
? 32
|
|
7489
|
+
: 16;
|
|
7473
7490
|
}
|
|
7474
7491
|
}
|
|
7475
7492
|
}
|
|
@@ -7626,7 +7643,9 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7626
7643
|
: parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, inGroup, isPattern, kind, origin);
|
|
7627
7644
|
destructible = parser.destructible;
|
|
7628
7645
|
parser.assignable =
|
|
7629
|
-
destructible & 16
|
|
7646
|
+
destructible & 16
|
|
7647
|
+
? 2
|
|
7648
|
+
: 1;
|
|
7630
7649
|
if (parser.getToken() === 18 || parser.getToken() === 1074790415) {
|
|
7631
7650
|
if (parser.assignable & 2) {
|
|
7632
7651
|
destructible |= 16;
|
|
@@ -7646,9 +7665,9 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7646
7665
|
value = parseConditionalExpression(parser, context, privateScope, value, tokenStart);
|
|
7647
7666
|
}
|
|
7648
7667
|
destructible |=
|
|
7649
|
-
parser.assignable &
|
|
7650
|
-
?
|
|
7651
|
-
:
|
|
7668
|
+
parser.assignable & 1
|
|
7669
|
+
? 32
|
|
7670
|
+
: 16;
|
|
7652
7671
|
}
|
|
7653
7672
|
}
|
|
7654
7673
|
}
|
|
@@ -7677,7 +7696,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7677
7696
|
else if (parser.getToken() === 67174411) {
|
|
7678
7697
|
state |= 1;
|
|
7679
7698
|
value = parseMethodDefinition(parser, context, privateScope, state, inGroup, parser.tokenStart);
|
|
7680
|
-
destructible =
|
|
7699
|
+
destructible = 16;
|
|
7681
7700
|
}
|
|
7682
7701
|
else {
|
|
7683
7702
|
parser.report(134);
|
|
@@ -7697,11 +7716,11 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7697
7716
|
value = parseMemberOrUpdateExpression(parser, context, privateScope, value, inGroup, 0, tokenStart);
|
|
7698
7717
|
if ((parser.getToken() & 4194304) === 4194304) {
|
|
7699
7718
|
destructible |=
|
|
7700
|
-
parser.assignable &
|
|
7701
|
-
?
|
|
7702
|
-
: token === 1077936155
|
|
7719
|
+
parser.assignable & 1
|
|
7720
|
+
? token === 1077936155
|
|
7703
7721
|
? 0
|
|
7704
|
-
: 32
|
|
7722
|
+
: 32
|
|
7723
|
+
: 16;
|
|
7705
7724
|
value = parseAssignmentExpressionOrPattern(parser, context, privateScope, inGroup, isPattern, tokenStart, value);
|
|
7706
7725
|
}
|
|
7707
7726
|
else if (parser.getToken() === 18 || parser.getToken() === 1074790415) {
|
|
@@ -7732,7 +7751,9 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7732
7751
|
: parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, inGroup, isPattern, kind, origin);
|
|
7733
7752
|
destructible = parser.destructible;
|
|
7734
7753
|
parser.assignable =
|
|
7735
|
-
destructible & 16
|
|
7754
|
+
destructible & 16
|
|
7755
|
+
? 2
|
|
7756
|
+
: 1;
|
|
7736
7757
|
if (parser.getToken() === 18 || parser.getToken() === 1074790415) {
|
|
7737
7758
|
if (parser.assignable & 2)
|
|
7738
7759
|
destructible |= 16;
|
|
@@ -7757,9 +7778,9 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7757
7778
|
value = parseConditionalExpression(parser, context, privateScope, value, tokenStart);
|
|
7758
7779
|
}
|
|
7759
7780
|
destructible |=
|
|
7760
|
-
parser.assignable &
|
|
7761
|
-
?
|
|
7762
|
-
:
|
|
7781
|
+
parser.assignable & 1
|
|
7782
|
+
? 32
|
|
7783
|
+
: 16;
|
|
7763
7784
|
}
|
|
7764
7785
|
}
|
|
7765
7786
|
}
|
|
@@ -8364,6 +8385,12 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8364
8385
|
parser.report(48);
|
|
8365
8386
|
return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 1, start);
|
|
8366
8387
|
}
|
|
8388
|
+
if (!(context & 1) && parser.options.webcompat) {
|
|
8389
|
+
parser.assignable = 4;
|
|
8390
|
+
}
|
|
8391
|
+
else {
|
|
8392
|
+
parser.assignable = 2;
|
|
8393
|
+
}
|
|
8367
8394
|
return parser.finishNode({
|
|
8368
8395
|
type: 'CallExpression',
|
|
8369
8396
|
callee,
|
|
@@ -8437,7 +8464,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8437
8464
|
}
|
|
8438
8465
|
else {
|
|
8439
8466
|
expr = parseExpression(parser, context, privateScope, 1, 0, tokenStart);
|
|
8440
|
-
destructible =
|
|
8467
|
+
destructible = 0;
|
|
8441
8468
|
params.push(expr);
|
|
8442
8469
|
while (consumeOpt(parser, context | 32, 18)) {
|
|
8443
8470
|
params.push(parseExpression(parser, context, privateScope, 1, 0, tokenStart));
|
|
@@ -8445,7 +8472,12 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8445
8472
|
destructible |= parser.assignable;
|
|
8446
8473
|
consume(parser, context, 16);
|
|
8447
8474
|
parser.destructible = destructible | 16;
|
|
8448
|
-
parser.
|
|
8475
|
+
if (!(context & 1) && parser.options.webcompat) {
|
|
8476
|
+
parser.assignable = 4;
|
|
8477
|
+
}
|
|
8478
|
+
else {
|
|
8479
|
+
parser.assignable = 2;
|
|
8480
|
+
}
|
|
8449
8481
|
return parser.finishNode({
|
|
8450
8482
|
type: 'CallExpression',
|
|
8451
8483
|
callee,
|
|
@@ -8483,7 +8515,12 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8483
8515
|
if (destructible & 8) {
|
|
8484
8516
|
parser.report(62);
|
|
8485
8517
|
}
|
|
8486
|
-
parser.
|
|
8518
|
+
if (!(context & 1) && parser.options.webcompat) {
|
|
8519
|
+
parser.assignable = 4;
|
|
8520
|
+
}
|
|
8521
|
+
else {
|
|
8522
|
+
parser.assignable = 2;
|
|
8523
|
+
}
|
|
8487
8524
|
return parser.finishNode({
|
|
8488
8525
|
type: 'CallExpression',
|
|
8489
8526
|
callee,
|
|
@@ -9207,6 +9244,7 @@ function parse(source, options) {
|
|
|
9207
9244
|
return parseSource(source, options);
|
|
9208
9245
|
}
|
|
9209
9246
|
|
|
9247
|
+
exports.isParseError = isParseError;
|
|
9210
9248
|
exports.parse = parse;
|
|
9211
9249
|
exports.parseModule = parseModule;
|
|
9212
9250
|
exports.parseScript = parseScript;
|