meriyah 4.4.2 → 4.4.4
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 +13 -0
- package/README.md +1 -7
- package/dist/meriyah.amd.js +121 -118
- package/dist/meriyah.amd.min.js +1 -1
- package/dist/meriyah.cjs +121 -118
- package/dist/meriyah.cjs.js +121 -118
- package/dist/meriyah.cjs.min.js +1 -1
- package/dist/meriyah.esm.js +121 -118
- package/dist/meriyah.esm.min.js +1 -1
- package/dist/meriyah.esm.min.mjs +1 -1
- package/dist/meriyah.esm.mjs +121 -118
- package/dist/meriyah.iife.js +121 -118
- package/dist/meriyah.iife.min.js +1 -1
- package/dist/meriyah.min.cjs +1 -1
- package/dist/meriyah.system.js +121 -118
- package/dist/meriyah.system.min.js +1 -1
- package/dist/meriyah.umd.cjs +121 -118
- package/dist/meriyah.umd.es5.js +121 -118
- package/dist/meriyah.umd.es5.min.js +1 -1
- package/dist/meriyah.umd.js +121 -118
- package/dist/meriyah.umd.min.cjs +1 -1
- package/dist/meriyah.umd.min.js +1 -1
- package/dist/src/common.d.ts +3 -5
- package/dist/src/common.d.ts.map +1 -1
- package/dist/src/parser.d.ts +4 -6
- package/dist/src/parser.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +4 -7
- package/src/parser.ts +115 -144
package/src/parser.ts
CHANGED
|
@@ -222,12 +222,8 @@ export interface Options {
|
|
|
222
222
|
lexical?: boolean;
|
|
223
223
|
// Adds a source attribute in every node’s loc object when the locations option is `true`
|
|
224
224
|
source?: string;
|
|
225
|
-
// Distinguish Identifier from IdentifierPattern
|
|
226
|
-
identifierPattern?: boolean;
|
|
227
225
|
// Enable React JSX parsing
|
|
228
226
|
jsx?: boolean;
|
|
229
|
-
// Allow edge cases that deviate from the spec
|
|
230
|
-
specDeviation?: boolean;
|
|
231
227
|
// Allows comment extraction. Accepts either a callback function or an array
|
|
232
228
|
onComment?: OnComment;
|
|
233
229
|
// Allows detection of automatic semicolon insertion. Accepts a callback function that will be passed the charater offset where the semicolon was inserted
|
|
@@ -260,8 +256,6 @@ export function parseSource(source: string, options: Options | void, context: Co
|
|
|
260
256
|
if (options.preserveParens) context |= Context.OptionsPreserveParens;
|
|
261
257
|
if (options.impliedStrict) context |= Context.Strict;
|
|
262
258
|
if (options.jsx) context |= Context.OptionsJSX;
|
|
263
|
-
if (options.identifierPattern) context |= Context.OptionsIdentifierPattern;
|
|
264
|
-
if (options.specDeviation) context |= Context.OptionsSpecDeviation;
|
|
265
259
|
if (options.source) sourceFile = options.source;
|
|
266
260
|
// Accepts either a callback function to be invoked or an array to collect comments (as the node is constructed)
|
|
267
261
|
if (options.onComment != null) {
|
|
@@ -678,7 +672,7 @@ export function parseExpressionOrLabelledStatement(
|
|
|
678
672
|
|
|
679
673
|
switch (token) {
|
|
680
674
|
case Token.LetKeyword:
|
|
681
|
-
expr = parseIdentifier(parser, context
|
|
675
|
+
expr = parseIdentifier(parser, context);
|
|
682
676
|
if (context & Context.Strict) report(parser, Errors.UnexpectedLetStrictReserved);
|
|
683
677
|
|
|
684
678
|
// "let" followed by either "[", "{" or an identifier means a lexical
|
|
@@ -696,7 +690,6 @@ export function parseExpressionOrLabelledStatement(
|
|
|
696
690
|
0,
|
|
697
691
|
1,
|
|
698
692
|
0,
|
|
699
|
-
0,
|
|
700
693
|
1,
|
|
701
694
|
parser.tokenPos,
|
|
702
695
|
parser.linePos,
|
|
@@ -1000,7 +993,7 @@ export function parseAsyncArrowOrAsyncFunctionDeclaration(
|
|
|
1000
993
|
|
|
1001
994
|
const { token, tokenValue } = parser;
|
|
1002
995
|
|
|
1003
|
-
let expr: ESTree.Expression = parseIdentifier(parser, context
|
|
996
|
+
let expr: ESTree.Expression = parseIdentifier(parser, context);
|
|
1004
997
|
|
|
1005
998
|
if (parser.token === Token.Colon) {
|
|
1006
999
|
return parseLabelledStatement(
|
|
@@ -1513,7 +1506,7 @@ export function parseContinueStatement(
|
|
|
1513
1506
|
let label: ESTree.Identifier | undefined | null = null;
|
|
1514
1507
|
if ((parser.flags & Flags.NewLine) === 0 && parser.token & Token.IsIdentifier) {
|
|
1515
1508
|
const { tokenValue } = parser;
|
|
1516
|
-
label = parseIdentifier(parser, context | Context.AllowRegExp
|
|
1509
|
+
label = parseIdentifier(parser, context | Context.AllowRegExp);
|
|
1517
1510
|
if (!isValidLabel(parser, labels, tokenValue, /* requireIterationStatement */ 1))
|
|
1518
1511
|
report(parser, Errors.UnknownLabel, tokenValue);
|
|
1519
1512
|
}
|
|
@@ -1549,7 +1542,7 @@ export function parseBreakStatement(
|
|
|
1549
1542
|
let label: ESTree.Identifier | undefined | null = null;
|
|
1550
1543
|
if ((parser.flags & Flags.NewLine) === 0 && parser.token & Token.IsIdentifier) {
|
|
1551
1544
|
const { tokenValue } = parser;
|
|
1552
|
-
label = parseIdentifier(parser, context | Context.AllowRegExp
|
|
1545
|
+
label = parseIdentifier(parser, context | Context.AllowRegExp);
|
|
1553
1546
|
if (!isValidLabel(parser, labels, tokenValue, /* requireIterationStatement */ 0))
|
|
1554
1547
|
report(parser, Errors.UnknownLabel, tokenValue);
|
|
1555
1548
|
} else if ((context & (Context.InSwitch | Context.InIteration)) === 0) {
|
|
@@ -1850,7 +1843,7 @@ export function parseDoWhileStatement(
|
|
|
1850
1843
|
// ECMA-262, section 11.9
|
|
1851
1844
|
// The previous token is ) and the inserted semicolon would then be parsed as the terminating semicolon of a do-while statement (13.7.2).
|
|
1852
1845
|
// This cannot be implemented in matchOrInsertSemicolon() because it doesn't know
|
|
1853
|
-
// this
|
|
1846
|
+
// this RightParen is the end of a do-while statement.
|
|
1854
1847
|
consumeOpt(parser, context | Context.AllowRegExp, Token.Semicolon);
|
|
1855
1848
|
return finishNode(parser, context, start, line, column, {
|
|
1856
1849
|
type: 'DoWhileStatement',
|
|
@@ -1884,7 +1877,7 @@ export function parseLetIdentOrVarDeclarationStatement(
|
|
|
1884
1877
|
column: number
|
|
1885
1878
|
): ESTree.VariableDeclaration | ESTree.LabeledStatement | ESTree.ExpressionStatement {
|
|
1886
1879
|
const { token, tokenValue } = parser;
|
|
1887
|
-
let expr: ESTree.Identifier | ESTree.Expression = parseIdentifier(parser, context
|
|
1880
|
+
let expr: ESTree.Identifier | ESTree.Expression = parseIdentifier(parser, context);
|
|
1888
1881
|
|
|
1889
1882
|
if (parser.token & (Token.IsIdentifier | Token.IsPatternStart)) {
|
|
1890
1883
|
/* VariableDeclarations ::
|
|
@@ -2120,7 +2113,7 @@ function parseVariableDeclaration(
|
|
|
2120
2113
|
|
|
2121
2114
|
if (parser.token === Token.Assign) {
|
|
2122
2115
|
nextToken(parser, context | Context.AllowRegExp);
|
|
2123
|
-
init = parseExpression(parser, context, 1, 0,
|
|
2116
|
+
init = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
2124
2117
|
if (origin & Origin.ForStatement || (token & Token.IsPatternStart) === 0) {
|
|
2125
2118
|
// Lexical declarations in for-in / for-of loops can't be initialized
|
|
2126
2119
|
|
|
@@ -2197,7 +2190,7 @@ export function parseForStatement(
|
|
|
2197
2190
|
|
|
2198
2191
|
if (isVarDecl) {
|
|
2199
2192
|
if (token === Token.LetKeyword) {
|
|
2200
|
-
init = parseIdentifier(parser, context
|
|
2193
|
+
init = parseIdentifier(parser, context);
|
|
2201
2194
|
if (parser.token & (Token.IsIdentifier | Token.IsPatternStart)) {
|
|
2202
2195
|
if (parser.token === Token.InKeyword) {
|
|
2203
2196
|
if (context & Context.Strict) report(parser, Errors.DisallowedLetInStrict);
|
|
@@ -2328,7 +2321,7 @@ export function parseForStatement(
|
|
|
2328
2321
|
// IterationStatement:
|
|
2329
2322
|
// for(LeftHandSideExpression of AssignmentExpression) Statement
|
|
2330
2323
|
// forawait(LeftHandSideExpression of AssignmentExpression) Statement
|
|
2331
|
-
right = parseExpression(parser, context, 1, 0,
|
|
2324
|
+
right = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
2332
2325
|
|
|
2333
2326
|
consume(parser, context | Context.AllowRegExp, Token.RightParen);
|
|
2334
2327
|
|
|
@@ -2418,7 +2411,7 @@ export function parseRestrictedIdentifier(
|
|
|
2418
2411
|
if (!isValidIdentifier(context, parser.token)) report(parser, Errors.UnexpectedStrictReserved);
|
|
2419
2412
|
if ((parser.token & Token.IsEvalOrArguments) === Token.IsEvalOrArguments) report(parser, Errors.StrictEvalArguments);
|
|
2420
2413
|
if (scope) addBlockName(parser, context, scope, parser.tokenValue, BindingKind.Let, Origin.None);
|
|
2421
|
-
return parseIdentifier(parser, context
|
|
2414
|
+
return parseIdentifier(parser, context);
|
|
2422
2415
|
}
|
|
2423
2416
|
|
|
2424
2417
|
/**
|
|
@@ -2566,7 +2559,9 @@ function parseImportNamespaceSpecifier(
|
|
|
2566
2559
|
function parseModuleSpecifier(parser: ParserState, context: Context): ESTree.Literal {
|
|
2567
2560
|
// ModuleSpecifier :
|
|
2568
2561
|
// StringLiteral
|
|
2569
|
-
consumeOpt(parser, context, Token.FromKeyword)
|
|
2562
|
+
if (!consumeOpt(parser, context, Token.FromKeyword)) {
|
|
2563
|
+
report(parser, Errors.UnexpectedToken, KeywordDescTable[parser.token & Token.Type]);
|
|
2564
|
+
}
|
|
2570
2565
|
|
|
2571
2566
|
if (parser.token !== Token.StringLiteral) report(parser, Errors.InvalidExportImportSource, 'Import');
|
|
2572
2567
|
|
|
@@ -2596,7 +2591,7 @@ function parseImportSpecifierOrNamedImports(
|
|
|
2596
2591
|
|
|
2597
2592
|
while (parser.token & Token.IsIdentifier) {
|
|
2598
2593
|
let { token, tokenValue, tokenPos, linePos, colPos } = parser;
|
|
2599
|
-
const imported = parseIdentifier(parser, context
|
|
2594
|
+
const imported = parseIdentifier(parser, context);
|
|
2600
2595
|
let local: ESTree.Identifier;
|
|
2601
2596
|
|
|
2602
2597
|
if (consumeOpt(parser, context, Token.AsKeyword)) {
|
|
@@ -2606,7 +2601,7 @@ function parseImportSpecifierOrNamedImports(
|
|
|
2606
2601
|
validateBindingIdentifier(parser, context, BindingKind.Const, parser.token, 0);
|
|
2607
2602
|
}
|
|
2608
2603
|
tokenValue = parser.tokenValue;
|
|
2609
|
-
local = parseIdentifier(parser, context
|
|
2604
|
+
local = parseIdentifier(parser, context);
|
|
2610
2605
|
} else {
|
|
2611
2606
|
// Keywords cannot be bound to themselves, so an import name
|
|
2612
2607
|
// that is a keyword is a syntax error if it is not followed
|
|
@@ -2826,7 +2821,7 @@ function parseExportDeclaration(
|
|
|
2826
2821
|
case Token.AsyncKeyword:
|
|
2827
2822
|
const { tokenPos, linePos, colPos } = parser;
|
|
2828
2823
|
|
|
2829
|
-
declaration = parseIdentifier(parser, context
|
|
2824
|
+
declaration = parseIdentifier(parser, context);
|
|
2830
2825
|
|
|
2831
2826
|
const { flags } = parser;
|
|
2832
2827
|
|
|
@@ -2881,7 +2876,7 @@ function parseExportDeclaration(
|
|
|
2881
2876
|
} else if (parser.token & Token.IsIdentifier) {
|
|
2882
2877
|
if (scope) scope = createArrowHeadParsingScope(parser, context, parser.tokenValue);
|
|
2883
2878
|
|
|
2884
|
-
declaration = parseIdentifier(parser, context
|
|
2879
|
+
declaration = parseIdentifier(parser, context);
|
|
2885
2880
|
declaration = parseArrowFunctionExpression(
|
|
2886
2881
|
parser,
|
|
2887
2882
|
context,
|
|
@@ -2899,7 +2894,7 @@ function parseExportDeclaration(
|
|
|
2899
2894
|
|
|
2900
2895
|
default:
|
|
2901
2896
|
// export default [lookahead ∉ {function, class}] AssignmentExpression[In] ;
|
|
2902
|
-
declaration = parseExpression(parser, context, 1, 0,
|
|
2897
|
+
declaration = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
2903
2898
|
matchOrInsertSemicolon(parser, context | Context.AllowRegExp);
|
|
2904
2899
|
}
|
|
2905
2900
|
|
|
@@ -2925,7 +2920,7 @@ function parseExportDeclaration(
|
|
|
2925
2920
|
|
|
2926
2921
|
if (isNamedDeclaration) {
|
|
2927
2922
|
if (scope) declareUnboundVariable(parser, parser.tokenValue);
|
|
2928
|
-
exported = parseIdentifier(parser, context
|
|
2923
|
+
exported = parseIdentifier(parser, context);
|
|
2929
2924
|
}
|
|
2930
2925
|
|
|
2931
2926
|
consume(parser, context, Token.FromKeyword);
|
|
@@ -2963,7 +2958,7 @@ function parseExportDeclaration(
|
|
|
2963
2958
|
|
|
2964
2959
|
while (parser.token & Token.IsIdentifier) {
|
|
2965
2960
|
const { tokenPos, tokenValue, linePos, colPos } = parser;
|
|
2966
|
-
const local = parseIdentifier(parser, context
|
|
2961
|
+
const local = parseIdentifier(parser, context);
|
|
2967
2962
|
|
|
2968
2963
|
let exported: ESTree.Identifier | null;
|
|
2969
2964
|
|
|
@@ -2976,7 +2971,7 @@ function parseExportDeclaration(
|
|
|
2976
2971
|
tmpExportedNames.push(parser.tokenValue);
|
|
2977
2972
|
tmpExportedBindings.push(tokenValue);
|
|
2978
2973
|
}
|
|
2979
|
-
exported = parseIdentifier(parser, context
|
|
2974
|
+
exported = parseIdentifier(parser, context);
|
|
2980
2975
|
} else {
|
|
2981
2976
|
if (scope) {
|
|
2982
2977
|
tmpExportedNames.push(parser.tokenValue);
|
|
@@ -3126,13 +3121,16 @@ function parseExportDeclaration(
|
|
|
3126
3121
|
*
|
|
3127
3122
|
* @param parser Parser object
|
|
3128
3123
|
* @param context Context masks
|
|
3129
|
-
* @param
|
|
3124
|
+
* @param canAssign
|
|
3125
|
+
* @param inGroup,
|
|
3126
|
+
* @param start,
|
|
3127
|
+
* @param line,
|
|
3128
|
+
* @param column,
|
|
3130
3129
|
*/
|
|
3131
3130
|
export function parseExpression(
|
|
3132
3131
|
parser: ParserState,
|
|
3133
3132
|
context: Context,
|
|
3134
3133
|
canAssign: 0 | 1,
|
|
3135
|
-
isPattern: 0 | 1,
|
|
3136
3134
|
inGroup: 0 | 1,
|
|
3137
3135
|
start: number,
|
|
3138
3136
|
line: number,
|
|
@@ -3142,19 +3140,7 @@ export function parseExpression(
|
|
|
3142
3140
|
// AssignmentExpression
|
|
3143
3141
|
// Expression ',' AssignmentExpression
|
|
3144
3142
|
|
|
3145
|
-
let expr = parsePrimaryExpression(
|
|
3146
|
-
parser,
|
|
3147
|
-
context,
|
|
3148
|
-
BindingKind.Empty,
|
|
3149
|
-
0,
|
|
3150
|
-
canAssign,
|
|
3151
|
-
isPattern,
|
|
3152
|
-
inGroup,
|
|
3153
|
-
1,
|
|
3154
|
-
start,
|
|
3155
|
-
line,
|
|
3156
|
-
column
|
|
3157
|
-
);
|
|
3143
|
+
let expr = parsePrimaryExpression(parser, context, BindingKind.Empty, 0, canAssign, inGroup, 1, start, line, column);
|
|
3158
3144
|
|
|
3159
3145
|
expr = parseMemberOrUpdateExpression(parser, context, expr, inGroup, 0, start, line, column);
|
|
3160
3146
|
|
|
@@ -3182,7 +3168,7 @@ export function parseSequenceExpression(
|
|
|
3182
3168
|
// Expression ',' AssignmentExpression
|
|
3183
3169
|
const expressions: ESTree.Expression[] = [expr];
|
|
3184
3170
|
while (consumeOpt(parser, context | Context.AllowRegExp, Token.Comma)) {
|
|
3185
|
-
expressions.push(parseExpression(parser, context, 1,
|
|
3171
|
+
expressions.push(parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos));
|
|
3186
3172
|
}
|
|
3187
3173
|
|
|
3188
3174
|
return finishNode(parser, context, start, line, column, {
|
|
@@ -3207,7 +3193,7 @@ export function parseExpressions(
|
|
|
3207
3193
|
line: number,
|
|
3208
3194
|
column: number
|
|
3209
3195
|
): ESTree.SequenceExpression | ESTree.Expression {
|
|
3210
|
-
const expr = parseExpression(parser, context, canAssign,
|
|
3196
|
+
const expr = parseExpression(parser, context, canAssign, inGroup, start, line, column);
|
|
3211
3197
|
return parser.token === Token.Comma
|
|
3212
3198
|
? parseSequenceExpression(parser, context, inGroup, start, line, column, expr)
|
|
3213
3199
|
: expr;
|
|
@@ -3259,7 +3245,7 @@ export function parseAssignmentExpression(
|
|
|
3259
3245
|
|
|
3260
3246
|
nextToken(parser, context | Context.AllowRegExp);
|
|
3261
3247
|
|
|
3262
|
-
const right = parseExpression(parser, context, 1,
|
|
3248
|
+
const right = parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos);
|
|
3263
3249
|
|
|
3264
3250
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
3265
3251
|
|
|
@@ -3333,7 +3319,7 @@ export function parseAssignmentExpressionOrPattern(
|
|
|
3333
3319
|
|
|
3334
3320
|
nextToken(parser, context | Context.AllowRegExp);
|
|
3335
3321
|
|
|
3336
|
-
const right = parseExpression(parser, context, 1,
|
|
3322
|
+
const right = parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos);
|
|
3337
3323
|
|
|
3338
3324
|
left = finishNode(
|
|
3339
3325
|
parser,
|
|
@@ -3383,7 +3369,6 @@ export function parseConditionalExpression(
|
|
|
3383
3369
|
(context | Context.DisallowIn) ^ Context.DisallowIn,
|
|
3384
3370
|
1,
|
|
3385
3371
|
0,
|
|
3386
|
-
0,
|
|
3387
3372
|
parser.tokenPos,
|
|
3388
3373
|
parser.linePos,
|
|
3389
3374
|
parser.colPos
|
|
@@ -3393,7 +3378,7 @@ export function parseConditionalExpression(
|
|
|
3393
3378
|
// In parsing the first assignment expression in conditional
|
|
3394
3379
|
// expressions we always accept the 'in' keyword; see ECMA-262,
|
|
3395
3380
|
// section 11.12, page 58.
|
|
3396
|
-
const alternate = parseExpression(parser, context, 1, 0,
|
|
3381
|
+
const alternate = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
3397
3382
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
3398
3383
|
return finishNode(parser, context, start, line, column, {
|
|
3399
3384
|
type: 'ConditionalExpression',
|
|
@@ -3537,14 +3522,13 @@ export function parseAsyncExpression(
|
|
|
3537
3522
|
inGroup: 0 | 1,
|
|
3538
3523
|
isLHS: 0 | 1,
|
|
3539
3524
|
canAssign: 0 | 1,
|
|
3540
|
-
isPattern: 0 | 1,
|
|
3541
3525
|
inNew: 0 | 1,
|
|
3542
3526
|
start: number,
|
|
3543
3527
|
line: number,
|
|
3544
3528
|
column: number
|
|
3545
3529
|
): ESTree.FunctionExpression | ESTree.ArrowFunctionExpression | ESTree.CallExpression | ESTree.Identifier {
|
|
3546
3530
|
const { token } = parser;
|
|
3547
|
-
const expr = parseIdentifier(parser, context
|
|
3531
|
+
const expr = parseIdentifier(parser, context);
|
|
3548
3532
|
const { flags } = parser;
|
|
3549
3533
|
|
|
3550
3534
|
if ((flags & Flags.NewLine) === 0) {
|
|
@@ -3619,7 +3603,7 @@ export function parseYieldExpression(
|
|
|
3619
3603
|
if ((parser.flags & Flags.NewLine) === 0) {
|
|
3620
3604
|
delegate = consumeOpt(parser, context | Context.AllowRegExp, Token.Multiply);
|
|
3621
3605
|
if (parser.token & (Token.Contextual | Token.IsExpressionStart) || delegate) {
|
|
3622
|
-
argument = parseExpression(parser, context, 1, 0,
|
|
3606
|
+
argument = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
3623
3607
|
}
|
|
3624
3608
|
}
|
|
3625
3609
|
|
|
@@ -3803,7 +3787,9 @@ export function parseSuperExpression(
|
|
|
3803
3787
|
case Token.LeftParen: {
|
|
3804
3788
|
// The super property has to be within a class constructor
|
|
3805
3789
|
if ((context & Context.SuperCall) === 0) report(parser, Errors.SuperNoConstructor);
|
|
3806
|
-
if (context & Context.InClass
|
|
3790
|
+
if (context & Context.InClass && !(context & Context.InMethod)) {
|
|
3791
|
+
report(parser, Errors.InvalidSuperProperty);
|
|
3792
|
+
}
|
|
3807
3793
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
3808
3794
|
break;
|
|
3809
3795
|
}
|
|
@@ -3812,7 +3798,9 @@ export function parseSuperExpression(
|
|
|
3812
3798
|
// new super() is never allowed.
|
|
3813
3799
|
// super() is only allowed in derived constructor
|
|
3814
3800
|
if ((context & Context.SuperProperty) === 0) report(parser, Errors.InvalidSuperProperty);
|
|
3815
|
-
if (context & Context.InClass
|
|
3801
|
+
if (context & Context.InClass && !(context & Context.InMethod)) {
|
|
3802
|
+
report(parser, Errors.InvalidSuperProperty);
|
|
3803
|
+
}
|
|
3816
3804
|
parser.assignable = AssignmentKind.Assignable;
|
|
3817
3805
|
break;
|
|
3818
3806
|
}
|
|
@@ -3852,7 +3840,6 @@ export function parseLeftHandSideExpression(
|
|
|
3852
3840
|
BindingKind.Empty,
|
|
3853
3841
|
0,
|
|
3854
3842
|
canAssign,
|
|
3855
|
-
0,
|
|
3856
3843
|
inGroup,
|
|
3857
3844
|
isLHS,
|
|
3858
3845
|
start,
|
|
@@ -3927,6 +3914,10 @@ export function parseMemberOrUpdateExpression(
|
|
|
3927
3914
|
case Token.Period: {
|
|
3928
3915
|
nextToken(parser, (context | Context.AllowEscapedKeyword | Context.InGlobal) ^ Context.InGlobal);
|
|
3929
3916
|
|
|
3917
|
+
if (context & Context.InClass && parser.token === Token.PrivateField && parser.tokenValue === 'super') {
|
|
3918
|
+
report(parser, Errors.InvalidSuperProperty);
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3930
3921
|
parser.assignable = AssignmentKind.Assignable;
|
|
3931
3922
|
|
|
3932
3923
|
const property = parsePropertyOrPrivatePropertyName(parser, context | Context.TaggedTemplate);
|
|
@@ -4091,7 +4082,7 @@ export function parseOptionalChain(
|
|
|
4091
4082
|
});
|
|
4092
4083
|
} else {
|
|
4093
4084
|
if ((parser.token & (Token.IsIdentifier | Token.Keyword)) === 0) report(parser, Errors.InvalidDotProperty);
|
|
4094
|
-
const property = parseIdentifier(parser, context
|
|
4085
|
+
const property = parseIdentifier(parser, context);
|
|
4095
4086
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
4096
4087
|
node = finishNode(parser, context, start, line, column, {
|
|
4097
4088
|
type: 'MemberExpression',
|
|
@@ -4121,7 +4112,7 @@ export function parsePropertyOrPrivatePropertyName(parser: ParserState, context:
|
|
|
4121
4112
|
|
|
4122
4113
|
return context & Context.OptionsNext && parser.token === Token.PrivateField
|
|
4123
4114
|
? parsePrivateIdentifier(parser, context, parser.tokenPos, parser.linePos, parser.colPos)
|
|
4124
|
-
: parseIdentifier(parser, context
|
|
4115
|
+
: parseIdentifier(parser, context);
|
|
4125
4116
|
}
|
|
4126
4117
|
|
|
4127
4118
|
/**
|
|
@@ -4178,7 +4169,6 @@ export function parseUpdateExpressionPrefixed(
|
|
|
4178
4169
|
* @param kind Binding kind
|
|
4179
4170
|
* @param inNew
|
|
4180
4171
|
* @param canAssign
|
|
4181
|
-
* @param isPattern
|
|
4182
4172
|
* @param inGroup
|
|
4183
4173
|
* @param start
|
|
4184
4174
|
* @param line
|
|
@@ -4191,7 +4181,6 @@ export function parsePrimaryExpression(
|
|
|
4191
4181
|
kind: BindingKind,
|
|
4192
4182
|
inNew: 0 | 1,
|
|
4193
4183
|
canAssign: 0 | 1,
|
|
4194
|
-
isPattern: 0 | 1,
|
|
4195
4184
|
inGroup: 0 | 1,
|
|
4196
4185
|
isLHS: 0 | 1,
|
|
4197
4186
|
start: number,
|
|
@@ -4230,13 +4219,13 @@ export function parsePrimaryExpression(
|
|
|
4230
4219
|
case Token.YieldKeyword:
|
|
4231
4220
|
return parseYieldExpression(parser, context, inGroup, canAssign, start, line, column);
|
|
4232
4221
|
case Token.AsyncKeyword:
|
|
4233
|
-
return parseAsyncExpression(parser, context, inGroup, isLHS, canAssign,
|
|
4222
|
+
return parseAsyncExpression(parser, context, inGroup, isLHS, canAssign, inNew, start, line, column);
|
|
4234
4223
|
default: // ignore
|
|
4235
4224
|
}
|
|
4236
4225
|
|
|
4237
4226
|
const { token, tokenValue } = parser;
|
|
4238
4227
|
|
|
4239
|
-
const expr = parseIdentifier(parser, context | Context.TaggedTemplate
|
|
4228
|
+
const expr = parseIdentifier(parser, context | Context.TaggedTemplate);
|
|
4240
4229
|
|
|
4241
4230
|
if (parser.token === Token.Arrow) {
|
|
4242
4231
|
if (!isLHS) report(parser, Errors.Unexpected);
|
|
@@ -4351,7 +4340,7 @@ function parseImportCallOrMetaExpression(
|
|
|
4351
4340
|
// ImportCall[Yield, Await]:
|
|
4352
4341
|
// import(AssignmentExpression[+In, ?Yield, ?Await])
|
|
4353
4342
|
|
|
4354
|
-
let expr: ESTree.Identifier | ESTree.ImportExpression = parseIdentifier(parser, context
|
|
4343
|
+
let expr: ESTree.Identifier | ESTree.ImportExpression = parseIdentifier(parser, context);
|
|
4355
4344
|
|
|
4356
4345
|
if (parser.token === Token.Period) {
|
|
4357
4346
|
return parseImportMetaExpression(parser, context, expr, start, line, column);
|
|
@@ -4397,7 +4386,7 @@ export function parseImportMetaExpression(
|
|
|
4397
4386
|
return finishNode(parser, context, start, line, column, {
|
|
4398
4387
|
type: 'MetaProperty',
|
|
4399
4388
|
meta,
|
|
4400
|
-
property: parseIdentifier(parser, context
|
|
4389
|
+
property: parseIdentifier(parser, context)
|
|
4401
4390
|
});
|
|
4402
4391
|
}
|
|
4403
4392
|
|
|
@@ -4424,7 +4413,7 @@ export function parseImportExpression(
|
|
|
4424
4413
|
|
|
4425
4414
|
if (parser.token === Token.Ellipsis) report(parser, Errors.InvalidSpreadInImport);
|
|
4426
4415
|
|
|
4427
|
-
const source = parseExpression(parser, context, 1,
|
|
4416
|
+
const source = parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos);
|
|
4428
4417
|
|
|
4429
4418
|
consume(parser, context, Token.RightParen);
|
|
4430
4419
|
|
|
@@ -4637,7 +4626,7 @@ function parseSpreadElement(
|
|
|
4637
4626
|
): ESTree.SpreadElement {
|
|
4638
4627
|
context = (context | Context.DisallowIn) ^ Context.DisallowIn;
|
|
4639
4628
|
consume(parser, context | Context.AllowRegExp, Token.Ellipsis);
|
|
4640
|
-
const argument = parseExpression(parser, context, 1, 0,
|
|
4629
|
+
const argument = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
4641
4630
|
parser.assignable = AssignmentKind.Assignable;
|
|
4642
4631
|
return finishNode(parser, context, start, line, column, {
|
|
4643
4632
|
type: 'SpreadElement',
|
|
@@ -4671,7 +4660,7 @@ export function parseArguments(
|
|
|
4671
4660
|
if (parser.token === Token.Ellipsis) {
|
|
4672
4661
|
args.push(parseSpreadElement(parser, context, parser.tokenPos, parser.linePos, parser.colPos));
|
|
4673
4662
|
} else {
|
|
4674
|
-
args.push(parseExpression(parser, context, 1,
|
|
4663
|
+
args.push(parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos));
|
|
4675
4664
|
}
|
|
4676
4665
|
|
|
4677
4666
|
if (parser.token !== Token.Comma) break;
|
|
@@ -4692,27 +4681,14 @@ export function parseArguments(
|
|
|
4692
4681
|
* @param parser Parser object
|
|
4693
4682
|
* @param context Context masks
|
|
4694
4683
|
*/
|
|
4695
|
-
export function parseIdentifier(parser: ParserState, context: Context
|
|
4684
|
+
export function parseIdentifier(parser: ParserState, context: Context): ESTree.Identifier {
|
|
4696
4685
|
const { tokenValue, tokenPos, linePos, colPos } = parser;
|
|
4697
4686
|
nextToken(parser, context);
|
|
4698
4687
|
|
|
4699
|
-
return finishNode(
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
linePos,
|
|
4704
|
-
colPos,
|
|
4705
|
-
context & Context.OptionsIdentifierPattern
|
|
4706
|
-
? {
|
|
4707
|
-
type: 'Identifier',
|
|
4708
|
-
name: tokenValue,
|
|
4709
|
-
pattern: isPattern === 1
|
|
4710
|
-
}
|
|
4711
|
-
: {
|
|
4712
|
-
type: 'Identifier',
|
|
4713
|
-
name: tokenValue
|
|
4714
|
-
}
|
|
4715
|
-
);
|
|
4688
|
+
return finishNode(parser, context, tokenPos, linePos, colPos, {
|
|
4689
|
+
type: 'Identifier',
|
|
4690
|
+
name: tokenValue
|
|
4691
|
+
});
|
|
4716
4692
|
}
|
|
4717
4693
|
|
|
4718
4694
|
/**
|
|
@@ -4880,7 +4856,7 @@ export function parseFunctionDeclaration(
|
|
|
4880
4856
|
firstRestricted = parser.token;
|
|
4881
4857
|
|
|
4882
4858
|
if (parser.token & Token.IsIdentifier) {
|
|
4883
|
-
id = parseIdentifier(parser, context
|
|
4859
|
+
id = parseIdentifier(parser, context);
|
|
4884
4860
|
} else {
|
|
4885
4861
|
report(parser, Errors.UnexpectedToken, KeywordDescTable[parser.token & Token.Type]);
|
|
4886
4862
|
}
|
|
@@ -4961,7 +4937,7 @@ export function parseFunctionExpression(
|
|
|
4961
4937
|
if (scope) scope = addChildScope(scope, ScopeKind.FunctionRoot);
|
|
4962
4938
|
|
|
4963
4939
|
firstRestricted = parser.token;
|
|
4964
|
-
id = parseIdentifier(parser, context
|
|
4940
|
+
id = parseIdentifier(parser, context);
|
|
4965
4941
|
}
|
|
4966
4942
|
|
|
4967
4943
|
context =
|
|
@@ -5139,7 +5115,7 @@ export function parseArrayExpressionOrPattern(
|
|
|
5139
5115
|
const { token, tokenPos, linePos, colPos, tokenValue } = parser;
|
|
5140
5116
|
|
|
5141
5117
|
if (token & Token.IsIdentifier) {
|
|
5142
|
-
left = parsePrimaryExpression(parser, context, kind, 0, 1,
|
|
5118
|
+
left = parsePrimaryExpression(parser, context, kind, 0, 1, inGroup, 1, tokenPos, linePos, colPos);
|
|
5143
5119
|
|
|
5144
5120
|
if (parser.token === Token.Assign) {
|
|
5145
5121
|
if (parser.assignable & AssignmentKind.CannotAssign) report(parser, Errors.CantAssignTo);
|
|
@@ -5148,7 +5124,7 @@ export function parseArrayExpressionOrPattern(
|
|
|
5148
5124
|
|
|
5149
5125
|
if (scope) addVarOrBlock(parser, context, scope, tokenValue, kind, origin);
|
|
5150
5126
|
|
|
5151
|
-
const right = parseExpression(parser, context, 1,
|
|
5127
|
+
const right = parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos);
|
|
5152
5128
|
|
|
5153
5129
|
left = finishNode(
|
|
5154
5130
|
parser,
|
|
@@ -5374,7 +5350,7 @@ function parseArrayOrObjectAssignmentPattern(
|
|
|
5374
5350
|
|
|
5375
5351
|
const { tokenPos, linePos, colPos } = parser;
|
|
5376
5352
|
|
|
5377
|
-
const right = parseExpression(parser, context, 1,
|
|
5353
|
+
const right = parseExpression(parser, context, 1, inGroup, tokenPos, linePos, colPos);
|
|
5378
5354
|
|
|
5379
5355
|
parser.destructible =
|
|
5380
5356
|
((destructible | DestructuringKind.SeenProto | DestructuringKind.HasToDestruct) ^
|
|
@@ -5441,7 +5417,7 @@ function parseSpreadOrRestElement(
|
|
|
5441
5417
|
if (token & (Token.Keyword | Token.IsIdentifier)) {
|
|
5442
5418
|
parser.assignable = AssignmentKind.Assignable;
|
|
5443
5419
|
|
|
5444
|
-
argument = parsePrimaryExpression(parser, context, kind, 0, 1,
|
|
5420
|
+
argument = parsePrimaryExpression(parser, context, kind, 0, 1, inGroup, 1, tokenPos, linePos, colPos);
|
|
5445
5421
|
|
|
5446
5422
|
token = parser.token;
|
|
5447
5423
|
|
|
@@ -5588,7 +5564,7 @@ function parseSpreadOrRestElement(
|
|
|
5588
5564
|
|
|
5589
5565
|
reinterpretToPattern(parser, argument);
|
|
5590
5566
|
|
|
5591
|
-
const right = parseExpression(parser, context, 1,
|
|
5567
|
+
const right = parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos);
|
|
5592
5568
|
|
|
5593
5569
|
argument = finishNode(
|
|
5594
5570
|
parser,
|
|
@@ -5862,7 +5838,7 @@ export function parseObjectLiteralOrPattern(
|
|
|
5862
5838
|
let value;
|
|
5863
5839
|
const t = parser.token;
|
|
5864
5840
|
if (parser.token & (Token.IsIdentifier | Token.Keyword) || parser.token === Token.EscapedReserved) {
|
|
5865
|
-
key = parseIdentifier(parser, context
|
|
5841
|
+
key = parseIdentifier(parser, context);
|
|
5866
5842
|
|
|
5867
5843
|
if (parser.token === Token.Comma || parser.token === Token.RightBrace || parser.token === Token.Assign) {
|
|
5868
5844
|
state |= PropertyKind.Shorthand;
|
|
@@ -5878,16 +5854,7 @@ export function parseObjectLiteralOrPattern(
|
|
|
5878
5854
|
if (consumeOpt(parser, context | Context.AllowRegExp, Token.Assign)) {
|
|
5879
5855
|
destructible |= DestructuringKind.HasToDestruct;
|
|
5880
5856
|
|
|
5881
|
-
const right = parseExpression(
|
|
5882
|
-
parser,
|
|
5883
|
-
context,
|
|
5884
|
-
1,
|
|
5885
|
-
1,
|
|
5886
|
-
inGroup,
|
|
5887
|
-
parser.tokenPos,
|
|
5888
|
-
parser.linePos,
|
|
5889
|
-
parser.colPos
|
|
5890
|
-
);
|
|
5857
|
+
const right = parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos);
|
|
5891
5858
|
|
|
5892
5859
|
destructible |=
|
|
5893
5860
|
parser.destructible & DestructuringKind.Yield
|
|
@@ -5918,7 +5885,7 @@ export function parseObjectLiteralOrPattern(
|
|
|
5918
5885
|
// A reserved word is an IdentifierName that cannot be used as an Identifier
|
|
5919
5886
|
destructible |= t === Token.EscapedReserved ? DestructuringKind.CannotDestruct : 0;
|
|
5920
5887
|
|
|
5921
|
-
value = parsePrimaryExpression(parser, context, kind, 0, 1,
|
|
5888
|
+
value = parsePrimaryExpression(parser, context, kind, 0, 1, inGroup, 1, tokenPos, linePos, colPos);
|
|
5922
5889
|
|
|
5923
5890
|
const { token } = parser;
|
|
5924
5891
|
|
|
@@ -6084,7 +6051,7 @@ export function parseObjectLiteralOrPattern(
|
|
|
6084
6051
|
if (parser.flags & Flags.NewLine) report(parser, Errors.AsyncRestrictedProd);
|
|
6085
6052
|
state |= PropertyKind.Async;
|
|
6086
6053
|
}
|
|
6087
|
-
key = parseIdentifier(parser, context
|
|
6054
|
+
key = parseIdentifier(parser, context);
|
|
6088
6055
|
|
|
6089
6056
|
state |=
|
|
6090
6057
|
token === Token.GetKeyword
|
|
@@ -6131,7 +6098,7 @@ export function parseObjectLiteralOrPattern(
|
|
|
6131
6098
|
PropertyKind.Generator | PropertyKind.Method | (token === Token.AsyncKeyword ? PropertyKind.Async : 0);
|
|
6132
6099
|
|
|
6133
6100
|
if (parser.token & Token.IsIdentifier) {
|
|
6134
|
-
key = parseIdentifier(parser, context
|
|
6101
|
+
key = parseIdentifier(parser, context);
|
|
6135
6102
|
} else if ((parser.token & Token.IsStringOrNumber) === Token.IsStringOrNumber) {
|
|
6136
6103
|
key = parseLiteral(parser, context);
|
|
6137
6104
|
} else if (parser.token === Token.LeftBracket) {
|
|
@@ -6187,7 +6154,7 @@ export function parseObjectLiteralOrPattern(
|
|
|
6187
6154
|
if (tokenValue === '__proto__') prototypeCount++;
|
|
6188
6155
|
|
|
6189
6156
|
if (parser.token & Token.IsIdentifier) {
|
|
6190
|
-
value = parsePrimaryExpression(parser, context, kind, 0, 1,
|
|
6157
|
+
value = parsePrimaryExpression(parser, context, kind, 0, 1, inGroup, 1, tokenPos, linePos, colPos);
|
|
6191
6158
|
|
|
6192
6159
|
const { token, tokenValue: valueAfterColon } = parser;
|
|
6193
6160
|
|
|
@@ -6340,7 +6307,7 @@ export function parseObjectLiteralOrPattern(
|
|
|
6340
6307
|
const { tokenPos, linePos, colPos, tokenValue, token: tokenAfterColon } = parser;
|
|
6341
6308
|
|
|
6342
6309
|
if (parser.token & Token.IsIdentifier) {
|
|
6343
|
-
value = parsePrimaryExpression(parser, context, kind, 0, 1,
|
|
6310
|
+
value = parsePrimaryExpression(parser, context, kind, 0, 1, inGroup, 1, tokenPos, linePos, colPos);
|
|
6344
6311
|
|
|
6345
6312
|
const { token } = parser;
|
|
6346
6313
|
|
|
@@ -6497,7 +6464,7 @@ export function parseObjectLiteralOrPattern(
|
|
|
6497
6464
|
if (parser.token & Token.IsIdentifier) {
|
|
6498
6465
|
const { token, line, index } = parser;
|
|
6499
6466
|
|
|
6500
|
-
key = parseIdentifier(parser, context
|
|
6467
|
+
key = parseIdentifier(parser, context);
|
|
6501
6468
|
|
|
6502
6469
|
state |= PropertyKind.Method;
|
|
6503
6470
|
|
|
@@ -6728,7 +6695,7 @@ export function parseMethodFormals(
|
|
|
6728
6695
|
|
|
6729
6696
|
isSimpleParameterList = 1;
|
|
6730
6697
|
|
|
6731
|
-
const right = parseExpression(parser, context, 1,
|
|
6698
|
+
const right = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
6732
6699
|
|
|
6733
6700
|
left = finishNode(parser, context, tokenPos, linePos, colPos, {
|
|
6734
6701
|
type: 'AssignmentPattern',
|
|
@@ -6775,7 +6742,6 @@ export function parseComputedPropertyName(parser: ParserState, context: Context,
|
|
|
6775
6742
|
parser,
|
|
6776
6743
|
(context | Context.DisallowIn) ^ Context.DisallowIn,
|
|
6777
6744
|
1,
|
|
6778
|
-
0,
|
|
6779
6745
|
inGroup,
|
|
6780
6746
|
parser.tokenPos,
|
|
6781
6747
|
parser.linePos,
|
|
@@ -6840,7 +6806,7 @@ export function parseParenthesizedExpression(
|
|
|
6840
6806
|
if (token & (Token.IsIdentifier | Token.Keyword)) {
|
|
6841
6807
|
if (scope) addBlockName(parser, context, scope, parser.tokenValue, BindingKind.ArgumentList, Origin.None);
|
|
6842
6808
|
|
|
6843
|
-
expr = parsePrimaryExpression(parser, context, kind, 0, 1,
|
|
6809
|
+
expr = parsePrimaryExpression(parser, context, kind, 0, 1, 1, 1, tokenPos, linePos, colPos);
|
|
6844
6810
|
|
|
6845
6811
|
if (parser.token === Token.RightParen || parser.token === Token.Comma) {
|
|
6846
6812
|
if (parser.assignable & AssignmentKind.CannotAssign) {
|
|
@@ -6940,7 +6906,7 @@ export function parseParenthesizedExpression(
|
|
|
6940
6906
|
} else {
|
|
6941
6907
|
destructible |= DestructuringKind.CannotDestruct;
|
|
6942
6908
|
|
|
6943
|
-
expr = parseExpression(parser, context, 1,
|
|
6909
|
+
expr = parseExpression(parser, context, 1, 1, tokenPos, linePos, colPos);
|
|
6944
6910
|
|
|
6945
6911
|
if (isSequence && (parser.token === Token.RightParen || parser.token === Token.Comma)) {
|
|
6946
6912
|
expressions.push(expr);
|
|
@@ -6955,7 +6921,7 @@ export function parseParenthesizedExpression(
|
|
|
6955
6921
|
|
|
6956
6922
|
if (isSequence) {
|
|
6957
6923
|
while (consumeOpt(parser, context | Context.AllowRegExp, Token.Comma)) {
|
|
6958
|
-
expressions.push(parseExpression(parser, context, 1,
|
|
6924
|
+
expressions.push(parseExpression(parser, context, 1, 1, parser.tokenPos, parser.linePos, parser.colPos));
|
|
6959
6925
|
}
|
|
6960
6926
|
|
|
6961
6927
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
@@ -7064,7 +7030,7 @@ export function parseIdentifierOrArrow(
|
|
|
7064
7030
|
): ESTree.Identifier | ESTree.ArrowFunctionExpression {
|
|
7065
7031
|
const { tokenValue } = parser;
|
|
7066
7032
|
|
|
7067
|
-
const expr = parseIdentifier(parser, context
|
|
7033
|
+
const expr = parseIdentifier(parser, context);
|
|
7068
7034
|
parser.assignable = AssignmentKind.Assignable;
|
|
7069
7035
|
if (parser.token === Token.Arrow) {
|
|
7070
7036
|
let scope: ScopeState | undefined = void 0;
|
|
@@ -7195,7 +7161,15 @@ export function parseArrowFunctionExpression(
|
|
|
7195
7161
|
|
|
7196
7162
|
if (expression) {
|
|
7197
7163
|
// Single-expression body
|
|
7198
|
-
body = parseExpression(
|
|
7164
|
+
body = parseExpression(
|
|
7165
|
+
parser,
|
|
7166
|
+
context & Context.InClass ? context | Context.InMethod : context,
|
|
7167
|
+
1,
|
|
7168
|
+
0,
|
|
7169
|
+
parser.tokenPos,
|
|
7170
|
+
parser.linePos,
|
|
7171
|
+
parser.colPos
|
|
7172
|
+
);
|
|
7199
7173
|
} else {
|
|
7200
7174
|
if (scope) scope = addChildScope(scope, ScopeKind.FunctionBody);
|
|
7201
7175
|
|
|
@@ -7378,7 +7352,7 @@ export function parseFormalParametersOrFormalList(
|
|
|
7378
7352
|
|
|
7379
7353
|
isSimpleParameterList = 1;
|
|
7380
7354
|
|
|
7381
|
-
const right = parseExpression(parser, context, 1,
|
|
7355
|
+
const right = parseExpression(parser, context, 1, inGroup, parser.tokenPos, parser.linePos, parser.colPos);
|
|
7382
7356
|
|
|
7383
7357
|
left = finishNode(parser, context, tokenPos, linePos, colPos, {
|
|
7384
7358
|
type: 'AssignmentPattern',
|
|
@@ -7537,7 +7511,7 @@ export function parseNewExpression(
|
|
|
7537
7511
|
// - `new foo()();`
|
|
7538
7512
|
// - `new (await foo);`
|
|
7539
7513
|
// - `new x(await foo);`
|
|
7540
|
-
const id = parseIdentifier(parser, context | Context.AllowRegExp
|
|
7514
|
+
const id = parseIdentifier(parser, context | Context.AllowRegExp);
|
|
7541
7515
|
const { tokenPos, linePos, colPos } = parser;
|
|
7542
7516
|
|
|
7543
7517
|
if (consumeOpt(parser, context, Token.Period)) {
|
|
@@ -7555,19 +7529,7 @@ export function parseNewExpression(
|
|
|
7555
7529
|
report(parser, Errors.InvalidNewUnary, KeywordDescTable[parser.token & Token.Type]);
|
|
7556
7530
|
}
|
|
7557
7531
|
|
|
7558
|
-
const expr = parsePrimaryExpression(
|
|
7559
|
-
parser,
|
|
7560
|
-
context,
|
|
7561
|
-
BindingKind.Empty,
|
|
7562
|
-
1,
|
|
7563
|
-
0,
|
|
7564
|
-
0,
|
|
7565
|
-
inGroup,
|
|
7566
|
-
1,
|
|
7567
|
-
tokenPos,
|
|
7568
|
-
linePos,
|
|
7569
|
-
colPos
|
|
7570
|
-
);
|
|
7532
|
+
const expr = parsePrimaryExpression(parser, context, BindingKind.Empty, 1, 0, inGroup, 1, tokenPos, linePos, colPos);
|
|
7571
7533
|
|
|
7572
7534
|
context = (context | Context.DisallowIn) ^ Context.DisallowIn;
|
|
7573
7535
|
|
|
@@ -7602,7 +7564,7 @@ export function parseMetaProperty(
|
|
|
7602
7564
|
line: number,
|
|
7603
7565
|
column: number
|
|
7604
7566
|
): ESTree.MetaProperty {
|
|
7605
|
-
const property = parseIdentifier(parser, context
|
|
7567
|
+
const property = parseIdentifier(parser, context);
|
|
7606
7568
|
return finishNode(parser, context, start, line, column, {
|
|
7607
7569
|
type: 'MetaProperty',
|
|
7608
7570
|
meta,
|
|
@@ -7651,7 +7613,7 @@ function parseAsyncArrowAfterIdent(
|
|
|
7651
7613
|
parser,
|
|
7652
7614
|
context,
|
|
7653
7615
|
parser.tokenValue,
|
|
7654
|
-
parseIdentifier(parser, context
|
|
7616
|
+
parseIdentifier(parser, context),
|
|
7655
7617
|
0,
|
|
7656
7618
|
canAssign,
|
|
7657
7619
|
1,
|
|
@@ -7723,7 +7685,7 @@ export function parseAsyncArrowOrCallExpression(
|
|
|
7723
7685
|
if (token & (Token.IsIdentifier | Token.Keyword)) {
|
|
7724
7686
|
if (scope) addBlockName(parser, context, scope, parser.tokenValue, kind, Origin.None);
|
|
7725
7687
|
|
|
7726
|
-
expr = parsePrimaryExpression(parser, context, kind, 0, 1,
|
|
7688
|
+
expr = parsePrimaryExpression(parser, context, kind, 0, 1, 1, 1, tokenPos, linePos, colPos);
|
|
7727
7689
|
|
|
7728
7690
|
if (parser.token === Token.RightParen || parser.token === Token.Comma) {
|
|
7729
7691
|
if (parser.assignable & AssignmentKind.CannotAssign) {
|
|
@@ -7800,14 +7762,14 @@ export function parseAsyncArrowOrCallExpression(
|
|
|
7800
7762
|
|
|
7801
7763
|
isSimpleParameterList = 1;
|
|
7802
7764
|
} else {
|
|
7803
|
-
expr = parseExpression(parser, context, 1, 0,
|
|
7765
|
+
expr = parseExpression(parser, context, 1, 0, tokenPos, linePos, colPos);
|
|
7804
7766
|
|
|
7805
7767
|
destructible = parser.assignable;
|
|
7806
7768
|
|
|
7807
7769
|
params.push(expr);
|
|
7808
7770
|
|
|
7809
7771
|
while (consumeOpt(parser, context | Context.AllowRegExp, Token.Comma)) {
|
|
7810
|
-
params.push(parseExpression(parser, context, 1, 0,
|
|
7772
|
+
params.push(parseExpression(parser, context, 1, 0, tokenPos, linePos, colPos));
|
|
7811
7773
|
}
|
|
7812
7774
|
|
|
7813
7775
|
destructible |= parser.assignable;
|
|
@@ -7965,7 +7927,7 @@ export function parseClassDeclaration(
|
|
|
7965
7927
|
}
|
|
7966
7928
|
}
|
|
7967
7929
|
|
|
7968
|
-
id = parseIdentifier(parser, context
|
|
7930
|
+
id = parseIdentifier(parser, context);
|
|
7969
7931
|
} else {
|
|
7970
7932
|
// Only under the "export default" context, class declaration does not require the class name.
|
|
7971
7933
|
//
|
|
@@ -8055,7 +8017,7 @@ export function parseClassExpression(
|
|
|
8055
8017
|
report(parser, Errors.StrictEvalArguments);
|
|
8056
8018
|
}
|
|
8057
8019
|
|
|
8058
|
-
id = parseIdentifier(parser, context
|
|
8020
|
+
id = parseIdentifier(parser, context);
|
|
8059
8021
|
}
|
|
8060
8022
|
|
|
8061
8023
|
// Second set of context masks to fix 'super' edge cases
|
|
@@ -8139,7 +8101,7 @@ export function parseDecoratorList(
|
|
|
8139
8101
|
): ESTree.Decorator {
|
|
8140
8102
|
nextToken(parser, context | Context.AllowRegExp);
|
|
8141
8103
|
|
|
8142
|
-
let expression = parsePrimaryExpression(parser, context, BindingKind.Empty, 0, 1, 0,
|
|
8104
|
+
let expression = parsePrimaryExpression(parser, context, BindingKind.Empty, 0, 1, 0, 1, start, line, column);
|
|
8143
8105
|
|
|
8144
8106
|
expression = parseMemberOrUpdateExpression(parser, context, expression, 0, 0, start, line, column);
|
|
8145
8107
|
|
|
@@ -8304,7 +8266,7 @@ function parseClassElementList(
|
|
|
8304
8266
|
const { token, tokenPos, linePos, colPos } = parser;
|
|
8305
8267
|
|
|
8306
8268
|
if (token & (Token.IsIdentifier | Token.FutureReserved)) {
|
|
8307
|
-
key = parseIdentifier(parser, context
|
|
8269
|
+
key = parseIdentifier(parser, context);
|
|
8308
8270
|
|
|
8309
8271
|
switch (token) {
|
|
8310
8272
|
case Token.StaticKeyword:
|
|
@@ -8376,7 +8338,7 @@ function parseClassElementList(
|
|
|
8376
8338
|
} else if (isStatic && token === Token.LeftBrace) {
|
|
8377
8339
|
return parseStaticBlock(parser, context, scope, tokenPos, linePos, colPos);
|
|
8378
8340
|
} else if (token === Token.EscapedFutureReserved) {
|
|
8379
|
-
key = parseIdentifier(parser, context
|
|
8341
|
+
key = parseIdentifier(parser, context);
|
|
8380
8342
|
if (parser.token !== Token.LeftParen)
|
|
8381
8343
|
report(parser, Errors.UnexpectedToken, KeywordDescTable[parser.token & Token.Type]);
|
|
8382
8344
|
} else {
|
|
@@ -8385,14 +8347,14 @@ function parseClassElementList(
|
|
|
8385
8347
|
|
|
8386
8348
|
if (kind & (PropertyKind.Generator | PropertyKind.Async | PropertyKind.GetSet)) {
|
|
8387
8349
|
if (parser.token & Token.IsIdentifier) {
|
|
8388
|
-
key = parseIdentifier(parser, context
|
|
8350
|
+
key = parseIdentifier(parser, context);
|
|
8389
8351
|
} else if ((parser.token & Token.IsStringOrNumber) === Token.IsStringOrNumber) {
|
|
8390
8352
|
key = parseLiteral(parser, context);
|
|
8391
8353
|
} else if (parser.token === Token.LeftBracket) {
|
|
8392
8354
|
kind |= PropertyKind.Computed;
|
|
8393
8355
|
key = parseComputedPropertyName(parser, context, /* inGroup */ 0);
|
|
8394
8356
|
} else if (parser.token === Token.EscapedFutureReserved) {
|
|
8395
|
-
key = parseIdentifier(parser, context
|
|
8357
|
+
key = parseIdentifier(parser, context);
|
|
8396
8358
|
} else if (context & Context.OptionsNext && parser.token === Token.PrivateField) {
|
|
8397
8359
|
kind |= PropertyKind.PrivateField;
|
|
8398
8360
|
key = parsePrivateIdentifier(parser, context, tokenPos, linePos, colPos);
|
|
@@ -8531,6 +8493,16 @@ export function parsePropertyDefinition(
|
|
|
8531
8493
|
|
|
8532
8494
|
if (parser.token === Token.Arguments) report(parser, Errors.StrictEvalArguments);
|
|
8533
8495
|
|
|
8496
|
+
const modifierFlags =
|
|
8497
|
+
(state & PropertyKind.Constructor) === 0
|
|
8498
|
+
? 0b0000001111010000000_0000_00000000
|
|
8499
|
+
: 0b0000000111000000000_0000_00000000;
|
|
8500
|
+
|
|
8501
|
+
context =
|
|
8502
|
+
((context | modifierFlags) ^ modifierFlags) |
|
|
8503
|
+
((state & 0b0000000000000000000_0000_01011000) << 18) |
|
|
8504
|
+
0b0000110000001000000_0000_00000000;
|
|
8505
|
+
|
|
8534
8506
|
value = parsePrimaryExpression(
|
|
8535
8507
|
parser,
|
|
8536
8508
|
context | Context.InClass,
|
|
@@ -8538,7 +8510,6 @@ export function parsePropertyDefinition(
|
|
|
8538
8510
|
0,
|
|
8539
8511
|
1,
|
|
8540
8512
|
0,
|
|
8541
|
-
0,
|
|
8542
8513
|
1,
|
|
8543
8514
|
tokenPos,
|
|
8544
8515
|
linePos,
|
|
@@ -9029,7 +9000,7 @@ export function parseJSXSpreadAttribute(
|
|
|
9029
9000
|
): ESTree.JSXSpreadAttribute {
|
|
9030
9001
|
nextToken(parser, context); // skips: '{'
|
|
9031
9002
|
consume(parser, context, Token.Ellipsis);
|
|
9032
|
-
const expression = parseExpression(parser, context, 1, 0,
|
|
9003
|
+
const expression = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
9033
9004
|
consume(parser, context, Token.RightBrace);
|
|
9034
9005
|
return finishNode(parser, context, start, line, column, {
|
|
9035
9006
|
type: 'JSXSpreadAttribute',
|
|
@@ -9146,7 +9117,7 @@ function parseJSXExpressionContainer(
|
|
|
9146
9117
|
if (isAttr) report(parser, Errors.InvalidNonEmptyJSXExpr);
|
|
9147
9118
|
expression = parseJSXEmptyExpression(parser, context, parser.startPos, parser.startLine, parser.startColumn);
|
|
9148
9119
|
} else {
|
|
9149
|
-
expression = parseExpression(parser, context, 1, 0,
|
|
9120
|
+
expression = parseExpression(parser, context, 1, 0, tokenPos, linePos, colPos);
|
|
9150
9121
|
}
|
|
9151
9122
|
if (inJSXChild) {
|
|
9152
9123
|
consume(parser, context, Token.RightBrace);
|
|
@@ -9177,7 +9148,7 @@ function parseJSXSpreadChild(
|
|
|
9177
9148
|
column: number
|
|
9178
9149
|
): ESTree.JSXSpreadChild {
|
|
9179
9150
|
consume(parser, context, Token.Ellipsis);
|
|
9180
|
-
const expression = parseExpression(parser, context, 1, 0,
|
|
9151
|
+
const expression = parseExpression(parser, context, 1, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
9181
9152
|
consume(parser, context, Token.RightBrace);
|
|
9182
9153
|
return finishNode(parser, context, start, line, column, {
|
|
9183
9154
|
type: 'JSXSpreadChild',
|