meriyah 4.2.1 → 4.3.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 +17 -0
- package/dist/meriyah.amd.js +77 -51
- package/dist/meriyah.amd.min.js +1 -1
- package/dist/meriyah.cjs +77 -51
- package/dist/meriyah.cjs.js +77 -51
- package/dist/meriyah.cjs.min.js +1 -1
- package/dist/meriyah.esm.js +77 -51
- package/dist/meriyah.esm.min.js +1 -1
- package/dist/meriyah.esm.min.mjs +1 -0
- package/dist/meriyah.esm.mjs +8806 -0
- package/dist/meriyah.iife.js +77 -51
- package/dist/meriyah.iife.min.js +1 -1
- package/dist/meriyah.min.cjs +1 -1
- package/dist/meriyah.system.js +77 -51
- package/dist/meriyah.system.min.js +1 -1
- package/dist/meriyah.umd.cjs +77 -51
- package/dist/meriyah.umd.es5.js +88 -58
- package/dist/meriyah.umd.es5.min.js +1 -15
- package/dist/meriyah.umd.js +77 -51
- package/dist/meriyah.umd.min.cjs +1 -1
- package/dist/meriyah.umd.min.js +1 -1
- package/dist/src/estree.d.ts +9 -4
- package/dist/src/estree.d.ts.map +1 -1
- package/dist/src/lexer/regexp.d.ts.map +1 -1
- package/dist/src/parser.d.ts +1 -0
- package/dist/src/parser.d.ts.map +1 -1
- package/package.json +25 -30
- package/src/estree.ts +11 -3
- package/src/lexer/numeric.ts +7 -7
- package/src/lexer/regexp.ts +22 -9
- package/src/lexer/scan.ts +1 -1
- package/src/parser.ts +81 -42
package/src/parser.ts
CHANGED
|
@@ -613,7 +613,7 @@ export function parseStatement(
|
|
|
613
613
|
parser,
|
|
614
614
|
context & Context.Strict
|
|
615
615
|
? Errors.StrictFunction
|
|
616
|
-
: (context & Context.OptionsWebCompat)
|
|
616
|
+
: (context & Context.OptionsWebCompat) === 0
|
|
617
617
|
? Errors.WebCompatFunction
|
|
618
618
|
: Errors.SloppyFunction
|
|
619
619
|
);
|
|
@@ -827,7 +827,7 @@ export function parseReturnStatement(
|
|
|
827
827
|
): ESTree.ReturnStatement {
|
|
828
828
|
// ReturnStatement ::
|
|
829
829
|
// 'return' [no line terminator] Expression? ';'
|
|
830
|
-
if ((context & Context.OptionsGlobalReturn)
|
|
830
|
+
if ((context & Context.OptionsGlobalReturn) === 0 && context & Context.InGlobal) report(parser, Errors.IllegalReturn);
|
|
831
831
|
|
|
832
832
|
nextToken(parser, context | Context.AllowRegExp);
|
|
833
833
|
|
|
@@ -909,7 +909,7 @@ export function parseLabelledStatement(
|
|
|
909
909
|
|
|
910
910
|
const body =
|
|
911
911
|
allowFuncDecl &&
|
|
912
|
-
(context & Context.Strict)
|
|
912
|
+
(context & Context.Strict) === 0 &&
|
|
913
913
|
context & Context.OptionsWebCompat &&
|
|
914
914
|
// In sloppy mode, Annex B.3.2 allows labelled function declarations.
|
|
915
915
|
// Otherwise it's a parse error.
|
|
@@ -1310,7 +1310,7 @@ export function parseConsequentOrAlternative(
|
|
|
1310
1310
|
): ESTree.Statement | ESTree.FunctionDeclaration {
|
|
1311
1311
|
return context & Context.Strict ||
|
|
1312
1312
|
// Disallow if web compatibility is off
|
|
1313
|
-
(context & Context.OptionsWebCompat)
|
|
1313
|
+
(context & Context.OptionsWebCompat) === 0 ||
|
|
1314
1314
|
parser.token !== Token.FunctionKeyword
|
|
1315
1315
|
? parseStatement(
|
|
1316
1316
|
parser,
|
|
@@ -1494,10 +1494,10 @@ export function parseContinueStatement(
|
|
|
1494
1494
|
): ESTree.ContinueStatement {
|
|
1495
1495
|
// ContinueStatement ::
|
|
1496
1496
|
// 'continue' Identifier? ';'
|
|
1497
|
-
if ((context & Context.InIteration)
|
|
1497
|
+
if ((context & Context.InIteration) === 0) report(parser, Errors.IllegalContinue);
|
|
1498
1498
|
nextToken(parser, context);
|
|
1499
1499
|
let label: ESTree.Identifier | undefined | null = null;
|
|
1500
|
-
if ((parser.flags & Flags.NewLine)
|
|
1500
|
+
if ((parser.flags & Flags.NewLine) === 0 && parser.token & Token.IsIdentifier) {
|
|
1501
1501
|
const { tokenValue } = parser;
|
|
1502
1502
|
label = parseIdentifier(parser, context | Context.AllowRegExp, 0);
|
|
1503
1503
|
if (!isValidLabel(parser, labels, tokenValue, /* requireIterationStatement */ 1))
|
|
@@ -1533,12 +1533,12 @@ export function parseBreakStatement(
|
|
|
1533
1533
|
// 'break' Identifier? ';'
|
|
1534
1534
|
nextToken(parser, context | Context.AllowRegExp);
|
|
1535
1535
|
let label: ESTree.Identifier | undefined | null = null;
|
|
1536
|
-
if ((parser.flags & Flags.NewLine)
|
|
1536
|
+
if ((parser.flags & Flags.NewLine) === 0 && parser.token & Token.IsIdentifier) {
|
|
1537
1537
|
const { tokenValue } = parser;
|
|
1538
1538
|
label = parseIdentifier(parser, context | Context.AllowRegExp, 0);
|
|
1539
1539
|
if (!isValidLabel(parser, labels, tokenValue, /* requireIterationStatement */ 0))
|
|
1540
1540
|
report(parser, Errors.UnknownLabel, tokenValue);
|
|
1541
|
-
} else if ((context & (Context.InSwitch | Context.InIteration))
|
|
1541
|
+
} else if ((context & (Context.InSwitch | Context.InIteration)) === 0) {
|
|
1542
1542
|
report(parser, Errors.IllegalBreak);
|
|
1543
1543
|
}
|
|
1544
1544
|
|
|
@@ -1770,6 +1770,41 @@ export function parseCatchBlock(
|
|
|
1770
1770
|
});
|
|
1771
1771
|
}
|
|
1772
1772
|
|
|
1773
|
+
/**
|
|
1774
|
+
* Parses class static initialization block
|
|
1775
|
+
*
|
|
1776
|
+
* @see [Link](https://github.com/tc39/proposal-class-static-block)
|
|
1777
|
+
*
|
|
1778
|
+
* @param parser Parser object
|
|
1779
|
+
* @param context Context masks
|
|
1780
|
+
* @param scope Scope instance
|
|
1781
|
+
* @param start Start pos of node
|
|
1782
|
+
* @param line
|
|
1783
|
+
* @param column
|
|
1784
|
+
*/
|
|
1785
|
+
export function parseStaticBlock(
|
|
1786
|
+
parser: ParserState,
|
|
1787
|
+
context: Context,
|
|
1788
|
+
scope: ScopeState | undefined,
|
|
1789
|
+
start: number,
|
|
1790
|
+
line: number,
|
|
1791
|
+
column: number
|
|
1792
|
+
): ESTree.StaticBlock {
|
|
1793
|
+
// StaticBlock ::
|
|
1794
|
+
// '{' StatementList '}'
|
|
1795
|
+
|
|
1796
|
+
if (scope) scope = addChildScope(scope, ScopeKind.Block);
|
|
1797
|
+
|
|
1798
|
+
const ctorContext = Context.InClass | Context.SuperCall;
|
|
1799
|
+
context = ((context | ctorContext) ^ ctorContext) | Context.SuperProperty;
|
|
1800
|
+
const { body } = parseBlock(parser, context, scope, {}, start, line, column);
|
|
1801
|
+
|
|
1802
|
+
return finishNode(parser, context, start, line, column, {
|
|
1803
|
+
type: 'StaticBlock',
|
|
1804
|
+
body
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1773
1808
|
/**
|
|
1774
1809
|
* Parses do while statement
|
|
1775
1810
|
*
|
|
@@ -2072,13 +2107,13 @@ function parseVariableDeclaration(
|
|
|
2072
2107
|
if (parser.token === Token.Assign) {
|
|
2073
2108
|
nextToken(parser, context | Context.AllowRegExp);
|
|
2074
2109
|
init = parseExpression(parser, context, 1, 0, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
2075
|
-
if (origin & Origin.ForStatement || (token & Token.IsPatternStart)
|
|
2110
|
+
if (origin & Origin.ForStatement || (token & Token.IsPatternStart) === 0) {
|
|
2076
2111
|
// Lexical declarations in for-in / for-of loops can't be initialized
|
|
2077
2112
|
|
|
2078
2113
|
if (
|
|
2079
2114
|
parser.token === Token.OfKeyword ||
|
|
2080
2115
|
(parser.token === Token.InKeyword &&
|
|
2081
|
-
(token & Token.IsPatternStart || (kind & BindingKind.Variable)
|
|
2116
|
+
(token & Token.IsPatternStart || (kind & BindingKind.Variable) === 0 || context & Context.Strict))
|
|
2082
2117
|
) {
|
|
2083
2118
|
reportMessageAt(
|
|
2084
2119
|
tokenPos,
|
|
@@ -2128,7 +2163,9 @@ export function parseForStatement(
|
|
|
2128
2163
|
): ESTree.ForStatement | ESTree.ForInStatement | ESTree.ForOfStatement {
|
|
2129
2164
|
nextToken(parser, context);
|
|
2130
2165
|
|
|
2131
|
-
const forAwait =
|
|
2166
|
+
const forAwait =
|
|
2167
|
+
((context & Context.InAwaitContext) > 0 || ((context & Context.Module) > 0 && (context & Context.InGlobal) > 0)) &&
|
|
2168
|
+
consumeOpt(parser, context, Token.AwaitKeyword);
|
|
2132
2169
|
|
|
2133
2170
|
consume(parser, context | Context.AllowRegExp, Token.LeftParen);
|
|
2134
2171
|
|
|
@@ -2771,7 +2808,7 @@ function parseExportDeclaration(
|
|
|
2771
2808
|
|
|
2772
2809
|
const { flags } = parser;
|
|
2773
2810
|
|
|
2774
|
-
if ((flags & Flags.NewLine)
|
|
2811
|
+
if ((flags & Flags.NewLine) === 0) {
|
|
2775
2812
|
if (parser.token === Token.FunctionKeyword) {
|
|
2776
2813
|
declaration = parseFunctionDeclaration(
|
|
2777
2814
|
parser,
|
|
@@ -3030,7 +3067,7 @@ function parseExportDeclaration(
|
|
|
3030
3067
|
|
|
3031
3068
|
nextToken(parser, context);
|
|
3032
3069
|
|
|
3033
|
-
if ((parser.flags & Flags.NewLine)
|
|
3070
|
+
if ((parser.flags & Flags.NewLine) === 0 && parser.token === Token.FunctionKeyword) {
|
|
3034
3071
|
declaration = parseFunctionDeclaration(
|
|
3035
3072
|
parser,
|
|
3036
3073
|
context,
|
|
@@ -3488,7 +3525,7 @@ export function parseAsyncExpression(
|
|
|
3488
3525
|
const expr = parseIdentifier(parser, context, isPattern);
|
|
3489
3526
|
const { flags } = parser;
|
|
3490
3527
|
|
|
3491
|
-
if ((flags & Flags.NewLine)
|
|
3528
|
+
if ((flags & Flags.NewLine) === 0) {
|
|
3492
3529
|
// async function ...
|
|
3493
3530
|
if (parser.token === Token.FunctionKeyword) {
|
|
3494
3531
|
return parseFunctionExpression(parser, context, /* isAsync */ 1, inGroup, start, line, column);
|
|
@@ -3555,7 +3592,7 @@ export function parseYieldExpression(
|
|
|
3555
3592
|
let argument: ESTree.Expression | null = null;
|
|
3556
3593
|
let delegate = false; // yield*
|
|
3557
3594
|
|
|
3558
|
-
if ((parser.flags & Flags.NewLine)
|
|
3595
|
+
if ((parser.flags & Flags.NewLine) === 0) {
|
|
3559
3596
|
delegate = consumeOpt(parser, context | Context.AllowRegExp, Token.Multiply);
|
|
3560
3597
|
if (parser.token & (Token.Contextual | Token.IsExpressionStart) || delegate) {
|
|
3561
3598
|
argument = parseExpression(parser, context, 1, 0, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
@@ -3688,8 +3725,8 @@ export function parseFunctionBody(
|
|
|
3688
3725
|
context & Context.OptionsLexical &&
|
|
3689
3726
|
scope &&
|
|
3690
3727
|
scopeError !== void 0 &&
|
|
3691
|
-
(prevContext & Context.Strict)
|
|
3692
|
-
(context & Context.InGlobal)
|
|
3728
|
+
(prevContext & Context.Strict) === 0 &&
|
|
3729
|
+
(context & Context.InGlobal) === 0
|
|
3693
3730
|
) {
|
|
3694
3731
|
reportScopeError(scopeError);
|
|
3695
3732
|
}
|
|
@@ -3741,7 +3778,7 @@ export function parseSuperExpression(
|
|
|
3741
3778
|
report(parser, Errors.OptionalChainingNoSuper);
|
|
3742
3779
|
case Token.LeftParen: {
|
|
3743
3780
|
// The super property has to be within a class constructor
|
|
3744
|
-
if ((context & Context.SuperCall)
|
|
3781
|
+
if ((context & Context.SuperCall) === 0) report(parser, Errors.SuperNoConstructor);
|
|
3745
3782
|
if (context & Context.InClass) report(parser, Errors.InvalidSuperProperty);
|
|
3746
3783
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
3747
3784
|
break;
|
|
@@ -3750,7 +3787,7 @@ export function parseSuperExpression(
|
|
|
3750
3787
|
case Token.Period: {
|
|
3751
3788
|
// new super() is never allowed.
|
|
3752
3789
|
// super() is only allowed in derived constructor
|
|
3753
|
-
if ((context & Context.SuperProperty)
|
|
3790
|
+
if ((context & Context.SuperProperty) === 0) report(parser, Errors.InvalidSuperProperty);
|
|
3754
3791
|
if (context & Context.InClass) report(parser, Errors.InvalidSuperProperty);
|
|
3755
3792
|
parser.assignable = AssignmentKind.Assignable;
|
|
3756
3793
|
break;
|
|
@@ -3856,7 +3893,7 @@ export function parseMemberOrUpdateExpression(
|
|
|
3856
3893
|
line: number,
|
|
3857
3894
|
column: number
|
|
3858
3895
|
): any {
|
|
3859
|
-
if ((parser.token & Token.IsUpdateOp) === Token.IsUpdateOp && (parser.flags & Flags.NewLine)
|
|
3896
|
+
if ((parser.token & Token.IsUpdateOp) === Token.IsUpdateOp && (parser.flags & Flags.NewLine) === 0) {
|
|
3860
3897
|
expr = parseUpdateExpression(parser, context, expr, start, line, column);
|
|
3861
3898
|
} else if ((parser.token & Token.IsMemberOrCallExpression) === Token.IsMemberOrCallExpression) {
|
|
3862
3899
|
context = (context | Context.DisallowIn) ^ Context.DisallowIn;
|
|
@@ -4029,7 +4066,7 @@ export function parseOptionalChain(
|
|
|
4029
4066
|
optional: true
|
|
4030
4067
|
});
|
|
4031
4068
|
} else {
|
|
4032
|
-
if ((parser.token & (Token.IsIdentifier | Token.Keyword))
|
|
4069
|
+
if ((parser.token & (Token.IsIdentifier | Token.Keyword)) === 0) report(parser, Errors.InvalidDotProperty);
|
|
4033
4070
|
const property = parseIdentifier(parser, context, 0);
|
|
4034
4071
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
4035
4072
|
node = finishNode(parser, context, start, line, column, {
|
|
@@ -4054,7 +4091,7 @@ export function parseOptionalChain(
|
|
|
4054
4091
|
* @param context Context masks
|
|
4055
4092
|
*/
|
|
4056
4093
|
export function parsePropertyOrPrivatePropertyName(parser: ParserState, context: Context): any {
|
|
4057
|
-
if ((parser.token & (Token.IsIdentifier | Token.Keyword))
|
|
4094
|
+
if ((parser.token & (Token.IsIdentifier | Token.Keyword)) === 0 && parser.token !== Token.PrivateField) {
|
|
4058
4095
|
report(parser, Errors.InvalidDotProperty);
|
|
4059
4096
|
}
|
|
4060
4097
|
|
|
@@ -4789,12 +4826,12 @@ export function parseFunctionDeclaration(
|
|
|
4789
4826
|
let functionScope = scope ? createScope() : void 0;
|
|
4790
4827
|
|
|
4791
4828
|
if (parser.token === Token.LeftParen) {
|
|
4792
|
-
if ((flags & HoistedClassFlags.Hoisted)
|
|
4829
|
+
if ((flags & HoistedClassFlags.Hoisted) === 0) report(parser, Errors.DeclNoName, 'Function');
|
|
4793
4830
|
} else {
|
|
4794
4831
|
// In ES6, a function behaves as a lexical binding, except in
|
|
4795
4832
|
// a script scope, or the initial scope of eval or another function.
|
|
4796
4833
|
const kind =
|
|
4797
|
-
origin & Origin.TopLevel && ((context & Context.InGlobal)
|
|
4834
|
+
origin & Origin.TopLevel && ((context & Context.InGlobal) === 0 || (context & Context.Module) === 0)
|
|
4798
4835
|
? BindingKind.Variable
|
|
4799
4836
|
: BindingKind.FunctionLexical;
|
|
4800
4837
|
|
|
@@ -5131,7 +5168,7 @@ export function parseArrayExpressionOrPattern(
|
|
|
5131
5168
|
destructible |=
|
|
5132
5169
|
kind & BindingKind.ArgumentList
|
|
5133
5170
|
? DestructuringKind.Assignable
|
|
5134
|
-
: (kind & BindingKind.Empty)
|
|
5171
|
+
: (kind & BindingKind.Empty) === 0
|
|
5135
5172
|
? DestructuringKind.CannotDestruct
|
|
5136
5173
|
: 0;
|
|
5137
5174
|
|
|
@@ -5226,7 +5263,7 @@ export function parseArrayExpressionOrPattern(
|
|
|
5226
5263
|
|
|
5227
5264
|
if (parser.token !== Token.Comma && parser.token !== Token.RightBracket) {
|
|
5228
5265
|
left = parseAssignmentExpression(parser, context, inGroup, isPattern, tokenPos, linePos, colPos, left);
|
|
5229
|
-
if ((kind & (BindingKind.Empty | BindingKind.ArgumentList))
|
|
5266
|
+
if ((kind & (BindingKind.Empty | BindingKind.ArgumentList)) === 0 && token === Token.LeftParen)
|
|
5230
5267
|
destructible |= DestructuringKind.CannotDestruct;
|
|
5231
5268
|
} else if (parser.assignable & AssignmentKind.CannotAssign) {
|
|
5232
5269
|
destructible |= DestructuringKind.CannotDestruct;
|
|
@@ -5585,7 +5622,7 @@ export function parseMethodDefinition(
|
|
|
5585
5622
|
column: number
|
|
5586
5623
|
): ESTree.FunctionExpression {
|
|
5587
5624
|
const modifierFlags =
|
|
5588
|
-
(kind & PropertyKind.Constructor)
|
|
5625
|
+
(kind & PropertyKind.Constructor) === 0 ? 0b0000001111010000000_0000_00000000 : 0b0000000111000000000_0000_00000000;
|
|
5589
5626
|
|
|
5590
5627
|
context =
|
|
5591
5628
|
((context | modifierFlags) ^ modifierFlags) |
|
|
@@ -6588,7 +6625,7 @@ export function parseMethodFormals(
|
|
|
6588
6625
|
const { tokenPos, linePos, colPos } = parser;
|
|
6589
6626
|
|
|
6590
6627
|
if (parser.token & Token.IsIdentifier) {
|
|
6591
|
-
if ((context & Context.Strict)
|
|
6628
|
+
if ((context & Context.Strict) === 0) {
|
|
6592
6629
|
if ((parser.token & Token.FutureReserved) === Token.FutureReserved) {
|
|
6593
6630
|
parser.flags |= Flags.HasStrictReserved;
|
|
6594
6631
|
}
|
|
@@ -7148,7 +7185,7 @@ export function parseArrowFunctionExpression(
|
|
|
7148
7185
|
|
|
7149
7186
|
switch (parser.token) {
|
|
7150
7187
|
case Token.LeftBracket:
|
|
7151
|
-
if ((parser.flags & Flags.NewLine)
|
|
7188
|
+
if ((parser.flags & Flags.NewLine) === 0) {
|
|
7152
7189
|
report(parser, Errors.InvalidInvokedBlockBodyArrow);
|
|
7153
7190
|
}
|
|
7154
7191
|
break;
|
|
@@ -7157,14 +7194,14 @@ export function parseArrowFunctionExpression(
|
|
|
7157
7194
|
case Token.QuestionMark:
|
|
7158
7195
|
report(parser, Errors.InvalidAccessedBlockBodyArrow);
|
|
7159
7196
|
case Token.LeftParen:
|
|
7160
|
-
if ((parser.flags & Flags.NewLine)
|
|
7197
|
+
if ((parser.flags & Flags.NewLine) === 0) {
|
|
7161
7198
|
report(parser, Errors.InvalidInvokedBlockBodyArrow);
|
|
7162
7199
|
}
|
|
7163
7200
|
parser.flags |= Flags.DisallowCall;
|
|
7164
7201
|
break;
|
|
7165
7202
|
default: // ignore
|
|
7166
7203
|
}
|
|
7167
|
-
if ((parser.token & Token.IsBinaryOp) === Token.IsBinaryOp && (parser.flags & Flags.NewLine)
|
|
7204
|
+
if ((parser.token & Token.IsBinaryOp) === Token.IsBinaryOp && (parser.flags & Flags.NewLine) === 0)
|
|
7168
7205
|
report(parser, Errors.UnexpectedToken, KeywordDescTable[parser.token & Token.Type]);
|
|
7169
7206
|
if ((parser.token & Token.IsUpdateOp) === Token.IsUpdateOp) report(parser, Errors.InvalidArrowPostfix);
|
|
7170
7207
|
}
|
|
@@ -7236,7 +7273,7 @@ export function parseFormalParametersOrFormalList(
|
|
|
7236
7273
|
const { tokenPos, linePos, colPos } = parser;
|
|
7237
7274
|
|
|
7238
7275
|
if (parser.token & Token.IsIdentifier) {
|
|
7239
|
-
if ((context & Context.Strict)
|
|
7276
|
+
if ((context & Context.Strict) === 0) {
|
|
7240
7277
|
if ((parser.token & Token.FutureReserved) === Token.FutureReserved) {
|
|
7241
7278
|
parser.flags |= Flags.HasStrictReserved;
|
|
7242
7279
|
}
|
|
@@ -7915,7 +7952,7 @@ export function parseClassDeclaration(
|
|
|
7915
7952
|
// ...
|
|
7916
7953
|
// [+Default] class ClassTail[?Yield]
|
|
7917
7954
|
//
|
|
7918
|
-
if ((flags & HoistedClassFlags.Hoisted)
|
|
7955
|
+
if ((flags & HoistedClassFlags.Hoisted) === 0) report(parser, Errors.DeclNoName, 'Class');
|
|
7919
7956
|
}
|
|
7920
7957
|
let inheritedContext = context;
|
|
7921
7958
|
|
|
@@ -8163,7 +8200,7 @@ export function parseClassBody(
|
|
|
8163
8200
|
context = (context | Context.DisallowIn) ^ Context.DisallowIn;
|
|
8164
8201
|
parser.flags = (parser.flags | Flags.HasConstructor) ^ Flags.HasConstructor;
|
|
8165
8202
|
|
|
8166
|
-
const body: (ESTree.MethodDefinition | ESTree.PropertyDefinition)[] = [];
|
|
8203
|
+
const body: (ESTree.MethodDefinition | ESTree.PropertyDefinition | ESTree.StaticBlock)[] = [];
|
|
8167
8204
|
let decorators: ESTree.Decorator[];
|
|
8168
8205
|
|
|
8169
8206
|
while (parser.token !== Token.RightBrace) {
|
|
@@ -8231,7 +8268,7 @@ function parseClassElementList(
|
|
|
8231
8268
|
start: number,
|
|
8232
8269
|
line: number,
|
|
8233
8270
|
column: number
|
|
8234
|
-
): ESTree.MethodDefinition | ESTree.PropertyDefinition {
|
|
8271
|
+
): ESTree.MethodDefinition | ESTree.PropertyDefinition | ESTree.StaticBlock {
|
|
8235
8272
|
let kind: PropertyKind = isStatic ? PropertyKind.Static : PropertyKind.None;
|
|
8236
8273
|
let key: ESTree.Expression | ESTree.PrivateIdentifier | null = null;
|
|
8237
8274
|
|
|
@@ -8260,7 +8297,7 @@ function parseClassElementList(
|
|
|
8260
8297
|
break;
|
|
8261
8298
|
|
|
8262
8299
|
case Token.AsyncKeyword:
|
|
8263
|
-
if (parser.token !== Token.LeftParen && (parser.flags & Flags.NewLine)
|
|
8300
|
+
if (parser.token !== Token.LeftParen && (parser.flags & Flags.NewLine) === 0) {
|
|
8264
8301
|
if (context & Context.OptionsNext && (parser.token & Token.IsClassField) === Token.IsClassField) {
|
|
8265
8302
|
return parsePropertyDefinition(parser, context, key, kind, decorators, tokenPos, linePos, colPos);
|
|
8266
8303
|
}
|
|
@@ -8302,6 +8339,8 @@ function parseClassElementList(
|
|
|
8302
8339
|
key = parsePrivateIdentifier(parser, context | Context.InClass, tokenPos, linePos, colPos);
|
|
8303
8340
|
} else if (context & Context.OptionsNext && (parser.token & Token.IsClassField) === Token.IsClassField) {
|
|
8304
8341
|
kind |= PropertyKind.ClassField;
|
|
8342
|
+
} else if (isStatic && token === Token.LeftBrace) {
|
|
8343
|
+
return parseStaticBlock(parser, context, scope, tokenPos, linePos, colPos);
|
|
8305
8344
|
} else if (token === Token.EscapedFutureReserved) {
|
|
8306
8345
|
key = parseIdentifier(parser, context, 0);
|
|
8307
8346
|
if (parser.token !== Token.LeftParen)
|
|
@@ -8326,14 +8365,14 @@ function parseClassElementList(
|
|
|
8326
8365
|
} else report(parser, Errors.InvalidKeyToken);
|
|
8327
8366
|
}
|
|
8328
8367
|
|
|
8329
|
-
if ((kind & PropertyKind.Computed)
|
|
8368
|
+
if ((kind & PropertyKind.Computed) === 0) {
|
|
8330
8369
|
if (parser.tokenValue === 'constructor') {
|
|
8331
8370
|
if ((parser.token & Token.IsClassField) === Token.IsClassField) {
|
|
8332
8371
|
report(parser, Errors.InvalidClassFieldConstructor);
|
|
8333
|
-
} else if ((kind & PropertyKind.Static)
|
|
8372
|
+
} else if ((kind & PropertyKind.Static) === 0 && parser.token === Token.LeftParen) {
|
|
8334
8373
|
if (kind & (PropertyKind.GetSet | PropertyKind.Async | PropertyKind.ClassField | PropertyKind.Generator)) {
|
|
8335
8374
|
report(parser, Errors.InvalidConstructor, 'accessor');
|
|
8336
|
-
} else if ((context & Context.SuperCall)
|
|
8375
|
+
} else if ((context & Context.SuperCall) === 0) {
|
|
8337
8376
|
if (parser.flags & Flags.HasConstructor) report(parser, Errors.DuplicateConstructor);
|
|
8338
8377
|
else parser.flags |= Flags.HasConstructor;
|
|
8339
8378
|
}
|
|
@@ -8341,7 +8380,7 @@ function parseClassElementList(
|
|
|
8341
8380
|
kind |= PropertyKind.Constructor;
|
|
8342
8381
|
} else if (
|
|
8343
8382
|
// Static Async Generator Private Methods can be named "#prototype" (class declaration)
|
|
8344
|
-
(kind & PropertyKind.PrivateField)
|
|
8383
|
+
(kind & PropertyKind.PrivateField) === 0 &&
|
|
8345
8384
|
kind & (PropertyKind.Static | PropertyKind.GetSet | PropertyKind.Generator | PropertyKind.Async) &&
|
|
8346
8385
|
parser.tokenValue === 'prototype'
|
|
8347
8386
|
) {
|
|
@@ -8365,7 +8404,7 @@ function parseClassElementList(
|
|
|
8365
8404
|
? {
|
|
8366
8405
|
type: 'MethodDefinition',
|
|
8367
8406
|
kind:
|
|
8368
|
-
(kind & PropertyKind.Static)
|
|
8407
|
+
(kind & PropertyKind.Static) === 0 && kind & PropertyKind.Constructor
|
|
8369
8408
|
? 'constructor'
|
|
8370
8409
|
: kind & PropertyKind.Getter
|
|
8371
8410
|
? 'get'
|
|
@@ -8381,7 +8420,7 @@ function parseClassElementList(
|
|
|
8381
8420
|
: {
|
|
8382
8421
|
type: 'MethodDefinition',
|
|
8383
8422
|
kind:
|
|
8384
|
-
(kind & PropertyKind.Static)
|
|
8423
|
+
(kind & PropertyKind.Static) === 0 && kind & PropertyKind.Constructor
|
|
8385
8424
|
? 'constructor'
|
|
8386
8425
|
: kind & PropertyKind.Getter
|
|
8387
8426
|
? 'get'
|