@next-core/brick-utils 2.32.4 → 2.33.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 +18 -31
- package/dist/index.bundle.js +1331 -791
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +1331 -791
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/index.bundle.js
CHANGED
|
@@ -2211,7 +2211,19 @@
|
|
|
2211
2211
|
getRunningContext().LexicalEnvironment = oldEnv;
|
|
2212
2212
|
|
|
2213
2213
|
if (!LoopContinues(result)) {
|
|
2214
|
-
|
|
2214
|
+
var status = UpdateEmpty(result, V);
|
|
2215
|
+
|
|
2216
|
+
if (!(iterationKind === "enumerate" || iteratorRecord.return === undefined)) {
|
|
2217
|
+
// Perform *IteratorClose*
|
|
2218
|
+
// https://tc39.es/ecma262/#sec-iteratorclose
|
|
2219
|
+
var innerResult = iteratorRecord.return();
|
|
2220
|
+
|
|
2221
|
+
if (!innerResult || !["object", "function"].includes(typeof innerResult)) {
|
|
2222
|
+
throw new TypeError("Iterator result is not an object");
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
return status;
|
|
2215
2227
|
}
|
|
2216
2228
|
|
|
2217
2229
|
if (result.Value !== Empty) {
|
|
@@ -3050,62 +3062,15 @@
|
|
|
3050
3062
|
Object.defineProperty(lib, '__esModule', {
|
|
3051
3063
|
value: true
|
|
3052
3064
|
});
|
|
3053
|
-
var lineBreak = /\r\n?|[\n\u2028\u2029]/;
|
|
3054
|
-
var lineBreakG = new RegExp(lineBreak.source, "g");
|
|
3055
|
-
|
|
3056
|
-
function isNewLine(code) {
|
|
3057
|
-
switch (code) {
|
|
3058
|
-
case 10:
|
|
3059
|
-
case 13:
|
|
3060
|
-
case 8232:
|
|
3061
|
-
case 8233:
|
|
3062
|
-
return true;
|
|
3063
|
-
|
|
3064
|
-
default:
|
|
3065
|
-
return false;
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
|
-
|
|
3069
|
-
var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
|
|
3070
|
-
var skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
|
|
3071
|
-
var skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
|
|
3072
|
-
|
|
3073
|
-
function isWhitespace(code) {
|
|
3074
|
-
switch (code) {
|
|
3075
|
-
case 0x0009:
|
|
3076
|
-
case 0x000b:
|
|
3077
|
-
case 0x000c:
|
|
3078
|
-
case 32:
|
|
3079
|
-
case 160:
|
|
3080
|
-
case 5760:
|
|
3081
|
-
case 0x2000:
|
|
3082
|
-
case 0x2001:
|
|
3083
|
-
case 0x2002:
|
|
3084
|
-
case 0x2003:
|
|
3085
|
-
case 0x2004:
|
|
3086
|
-
case 0x2005:
|
|
3087
|
-
case 0x2006:
|
|
3088
|
-
case 0x2007:
|
|
3089
|
-
case 0x2008:
|
|
3090
|
-
case 0x2009:
|
|
3091
|
-
case 0x200a:
|
|
3092
|
-
case 0x202f:
|
|
3093
|
-
case 0x205f:
|
|
3094
|
-
case 0x3000:
|
|
3095
|
-
case 0xfeff:
|
|
3096
|
-
return true;
|
|
3097
|
-
|
|
3098
|
-
default:
|
|
3099
|
-
return false;
|
|
3100
|
-
}
|
|
3101
|
-
}
|
|
3102
3065
|
|
|
3103
3066
|
class Position {
|
|
3104
|
-
constructor(line, col) {
|
|
3067
|
+
constructor(line, col, index) {
|
|
3105
3068
|
this.line = void 0;
|
|
3106
3069
|
this.column = void 0;
|
|
3070
|
+
this.index = void 0;
|
|
3107
3071
|
this.line = line;
|
|
3108
3072
|
this.column = col;
|
|
3073
|
+
indexes.set(this, index);
|
|
3109
3074
|
}
|
|
3110
3075
|
|
|
3111
3076
|
}
|
|
@@ -3122,26 +3087,14 @@
|
|
|
3122
3087
|
|
|
3123
3088
|
}
|
|
3124
3089
|
|
|
3125
|
-
|
|
3126
|
-
var line = 1;
|
|
3127
|
-
var lineStart = 0;
|
|
3128
|
-
var match;
|
|
3129
|
-
lineBreakG.lastIndex = 0;
|
|
3130
|
-
|
|
3131
|
-
while ((match = lineBreakG.exec(input)) && match.index < offset) {
|
|
3132
|
-
line++;
|
|
3133
|
-
lineStart = lineBreakG.lastIndex;
|
|
3134
|
-
}
|
|
3135
|
-
|
|
3136
|
-
return new Position(line, offset - lineStart);
|
|
3137
|
-
}
|
|
3090
|
+
var indexes = new WeakMap();
|
|
3138
3091
|
|
|
3139
3092
|
function createPositionWithColumnOffset(position, columnOffset) {
|
|
3140
3093
|
var {
|
|
3141
3094
|
line,
|
|
3142
3095
|
column
|
|
3143
3096
|
} = position;
|
|
3144
|
-
return new Position(line, column + columnOffset);
|
|
3097
|
+
return new Position(line, column + columnOffset, indexes.get(position) + columnOffset);
|
|
3145
3098
|
}
|
|
3146
3099
|
|
|
3147
3100
|
class BaseParser {
|
|
@@ -3563,13 +3516,7 @@
|
|
|
3563
3516
|
}
|
|
3564
3517
|
|
|
3565
3518
|
class ParserError extends CommentsParser {
|
|
3566
|
-
|
|
3567
|
-
var loc;
|
|
3568
|
-
if (pos === this.state.start) loc = this.state.startLoc;else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;else if (pos === this.state.end) loc = this.state.endLoc;else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;else loc = getLineInfo(this.input, pos);
|
|
3569
|
-
return loc;
|
|
3570
|
-
}
|
|
3571
|
-
|
|
3572
|
-
raise(pos, _ref) {
|
|
3519
|
+
raise(_ref, origin) {
|
|
3573
3520
|
var {
|
|
3574
3521
|
code,
|
|
3575
3522
|
reasonCode,
|
|
@@ -3580,13 +3527,13 @@
|
|
|
3580
3527
|
params[_key - 2] = arguments[_key];
|
|
3581
3528
|
}
|
|
3582
3529
|
|
|
3583
|
-
return this.raiseWithData(
|
|
3530
|
+
return this.raiseWithData(origin.node ? origin.node.loc.start : origin.at, {
|
|
3584
3531
|
code,
|
|
3585
3532
|
reasonCode
|
|
3586
3533
|
}, template, ...params);
|
|
3587
3534
|
}
|
|
3588
3535
|
|
|
3589
|
-
raiseOverwrite(
|
|
3536
|
+
raiseOverwrite(loc, _ref2) {
|
|
3590
3537
|
var {
|
|
3591
3538
|
code,
|
|
3592
3539
|
template
|
|
@@ -3596,7 +3543,7 @@
|
|
|
3596
3543
|
params[_key2 - 2] = arguments[_key2];
|
|
3597
3544
|
}
|
|
3598
3545
|
|
|
3599
|
-
var
|
|
3546
|
+
var pos = indexes.get(loc);
|
|
3600
3547
|
var message = template.replace(/%(\d+)/g, (_, i) => params[i]) + " (".concat(loc.line, ":").concat(loc.column, ")");
|
|
3601
3548
|
|
|
3602
3549
|
if (this.options.errorRecovery) {
|
|
@@ -3622,12 +3569,12 @@
|
|
|
3622
3569
|
}, message);
|
|
3623
3570
|
}
|
|
3624
3571
|
|
|
3625
|
-
raiseWithData(
|
|
3572
|
+
raiseWithData(loc, data, errorTemplate) {
|
|
3626
3573
|
for (var _len3 = arguments.length, params = new Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) {
|
|
3627
3574
|
params[_key3 - 3] = arguments[_key3];
|
|
3628
3575
|
}
|
|
3629
3576
|
|
|
3630
|
-
var
|
|
3577
|
+
var pos = indexes.get(loc);
|
|
3631
3578
|
var message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + " (".concat(loc.line, ":").concat(loc.column, ")");
|
|
3632
3579
|
return this._raise(Object.assign({
|
|
3633
3580
|
loc,
|
|
@@ -3716,9 +3663,9 @@
|
|
|
3716
3663
|
var expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start);
|
|
3717
3664
|
expression.value = directiveLiteral.extra.expressionValue;
|
|
3718
3665
|
expression.raw = directiveLiteral.extra.raw;
|
|
3719
|
-
stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.
|
|
3666
|
+
stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.loc.end);
|
|
3720
3667
|
stmt.directive = directiveLiteral.extra.raw.slice(1, -1);
|
|
3721
|
-
return this.finishNodeAt(stmt, "ExpressionStatement", directive.
|
|
3668
|
+
return this.finishNodeAt(stmt, "ExpressionStatement", directive.loc.end);
|
|
3722
3669
|
}
|
|
3723
3670
|
|
|
3724
3671
|
initFunction(node, isAsync) {
|
|
@@ -3900,9 +3847,13 @@
|
|
|
3900
3847
|
|
|
3901
3848
|
toAssignableObjectExpressionProp(prop) {
|
|
3902
3849
|
if (prop.kind === "get" || prop.kind === "set") {
|
|
3903
|
-
this.raise(
|
|
3850
|
+
this.raise(ErrorMessages.PatternHasAccessor, {
|
|
3851
|
+
node: prop.key
|
|
3852
|
+
});
|
|
3904
3853
|
} else if (prop.method) {
|
|
3905
|
-
this.raise(
|
|
3854
|
+
this.raise(ErrorMessages.PatternHasMethod, {
|
|
3855
|
+
node: prop.key
|
|
3856
|
+
});
|
|
3906
3857
|
} else {
|
|
3907
3858
|
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
3908
3859
|
args[_key5 - 1] = arguments[_key5];
|
|
@@ -4573,10 +4524,6 @@
|
|
|
4573
4524
|
return tokenTypes[token];
|
|
4574
4525
|
}
|
|
4575
4526
|
|
|
4576
|
-
function isTokenType(obj) {
|
|
4577
|
-
return typeof obj === "number";
|
|
4578
|
-
}
|
|
4579
|
-
|
|
4580
4527
|
{
|
|
4581
4528
|
tokenTypes[8].updateContext = context => {
|
|
4582
4529
|
context.pop();
|
|
@@ -4745,7 +4692,6 @@
|
|
|
4745
4692
|
constructor(raise, inModule) {
|
|
4746
4693
|
this.scopeStack = [];
|
|
4747
4694
|
this.undefinedExports = new Map();
|
|
4748
|
-
this.undefinedPrivateNames = new Map();
|
|
4749
4695
|
this.raise = raise;
|
|
4750
4696
|
this.inModule = inModule;
|
|
4751
4697
|
}
|
|
@@ -4811,11 +4757,11 @@
|
|
|
4811
4757
|
return !!(scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_PROGRAM);
|
|
4812
4758
|
}
|
|
4813
4759
|
|
|
4814
|
-
declareName(name, bindingType,
|
|
4760
|
+
declareName(name, bindingType, loc) {
|
|
4815
4761
|
var scope = this.currentScope();
|
|
4816
4762
|
|
|
4817
4763
|
if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
|
|
4818
|
-
this.checkRedeclarationInScope(scope, name, bindingType,
|
|
4764
|
+
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
|
4819
4765
|
|
|
4820
4766
|
if (bindingType & BIND_SCOPE_FUNCTION) {
|
|
4821
4767
|
scope.functions.add(name);
|
|
@@ -4829,7 +4775,7 @@
|
|
|
4829
4775
|
} else if (bindingType & BIND_SCOPE_VAR) {
|
|
4830
4776
|
for (var i = this.scopeStack.length - 1; i >= 0; --i) {
|
|
4831
4777
|
scope = this.scopeStack[i];
|
|
4832
|
-
this.checkRedeclarationInScope(scope, name, bindingType,
|
|
4778
|
+
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
|
4833
4779
|
scope.var.add(name);
|
|
4834
4780
|
this.maybeExportDefined(scope, name);
|
|
4835
4781
|
if (scope.flags & SCOPE_VAR) break;
|
|
@@ -4847,9 +4793,11 @@
|
|
|
4847
4793
|
}
|
|
4848
4794
|
}
|
|
4849
4795
|
|
|
4850
|
-
checkRedeclarationInScope(scope, name, bindingType,
|
|
4796
|
+
checkRedeclarationInScope(scope, name, bindingType, loc) {
|
|
4851
4797
|
if (this.isRedeclaredInScope(scope, name, bindingType)) {
|
|
4852
|
-
this.raise(
|
|
4798
|
+
this.raise(ErrorMessages.VarRedeclaration, {
|
|
4799
|
+
at: loc
|
|
4800
|
+
}, name);
|
|
4853
4801
|
}
|
|
4854
4802
|
}
|
|
4855
4803
|
|
|
@@ -4874,7 +4822,7 @@
|
|
|
4874
4822
|
var topLevelScope = this.scopeStack[0];
|
|
4875
4823
|
|
|
4876
4824
|
if (!topLevelScope.lexical.has(name) && !topLevelScope.var.has(name) && !topLevelScope.functions.has(name)) {
|
|
4877
|
-
this.undefinedExports.set(name, id.start);
|
|
4825
|
+
this.undefinedExports.set(name, id.loc.start);
|
|
4878
4826
|
}
|
|
4879
4827
|
}
|
|
4880
4828
|
|
|
@@ -4921,11 +4869,11 @@
|
|
|
4921
4869
|
return new FlowScope(flags);
|
|
4922
4870
|
}
|
|
4923
4871
|
|
|
4924
|
-
declareName(name, bindingType,
|
|
4872
|
+
declareName(name, bindingType, loc) {
|
|
4925
4873
|
var scope = this.currentScope();
|
|
4926
4874
|
|
|
4927
4875
|
if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {
|
|
4928
|
-
this.checkRedeclarationInScope(scope, name, bindingType,
|
|
4876
|
+
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
|
4929
4877
|
this.maybeExportDefined(scope, name);
|
|
4930
4878
|
scope.declareFunctions.add(name);
|
|
4931
4879
|
return;
|
|
@@ -4952,6 +4900,56 @@
|
|
|
4952
4900
|
|
|
4953
4901
|
}
|
|
4954
4902
|
|
|
4903
|
+
var lineBreak = /\r\n?|[\n\u2028\u2029]/;
|
|
4904
|
+
var lineBreakG = new RegExp(lineBreak.source, "g");
|
|
4905
|
+
|
|
4906
|
+
function isNewLine(code) {
|
|
4907
|
+
switch (code) {
|
|
4908
|
+
case 10:
|
|
4909
|
+
case 13:
|
|
4910
|
+
case 8232:
|
|
4911
|
+
case 8233:
|
|
4912
|
+
return true;
|
|
4913
|
+
|
|
4914
|
+
default:
|
|
4915
|
+
return false;
|
|
4916
|
+
}
|
|
4917
|
+
}
|
|
4918
|
+
|
|
4919
|
+
var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
|
|
4920
|
+
var skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
|
|
4921
|
+
var skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
|
|
4922
|
+
|
|
4923
|
+
function isWhitespace(code) {
|
|
4924
|
+
switch (code) {
|
|
4925
|
+
case 0x0009:
|
|
4926
|
+
case 0x000b:
|
|
4927
|
+
case 0x000c:
|
|
4928
|
+
case 32:
|
|
4929
|
+
case 160:
|
|
4930
|
+
case 5760:
|
|
4931
|
+
case 0x2000:
|
|
4932
|
+
case 0x2001:
|
|
4933
|
+
case 0x2002:
|
|
4934
|
+
case 0x2003:
|
|
4935
|
+
case 0x2004:
|
|
4936
|
+
case 0x2005:
|
|
4937
|
+
case 0x2006:
|
|
4938
|
+
case 0x2007:
|
|
4939
|
+
case 0x2008:
|
|
4940
|
+
case 0x2009:
|
|
4941
|
+
case 0x200a:
|
|
4942
|
+
case 0x202f:
|
|
4943
|
+
case 0x205f:
|
|
4944
|
+
case 0x3000:
|
|
4945
|
+
case 0xfeff:
|
|
4946
|
+
return true;
|
|
4947
|
+
|
|
4948
|
+
default:
|
|
4949
|
+
return false;
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
|
|
4955
4953
|
class State {
|
|
4956
4954
|
constructor() {
|
|
4957
4955
|
this.strict = void 0;
|
|
@@ -4987,7 +4985,6 @@
|
|
|
4987
4985
|
this.lastTokEndLoc = null;
|
|
4988
4986
|
this.lastTokStartLoc = null;
|
|
4989
4987
|
this.lastTokStart = 0;
|
|
4990
|
-
this.lastTokEnd = 0;
|
|
4991
4988
|
this.context = [types.brace];
|
|
4992
4989
|
this.canStartJSXElement = true;
|
|
4993
4990
|
this.containsEsc = false;
|
|
@@ -5005,11 +5002,11 @@
|
|
|
5005
5002
|
this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
|
|
5006
5003
|
this.curLine = startLine;
|
|
5007
5004
|
this.lineStart = -startColumn;
|
|
5008
|
-
this.startLoc = this.endLoc = new Position(startLine, startColumn);
|
|
5005
|
+
this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
|
|
5009
5006
|
}
|
|
5010
5007
|
|
|
5011
5008
|
curPosition() {
|
|
5012
|
-
return new Position(this.curLine, this.pos - this.lineStart);
|
|
5009
|
+
return new Position(this.curLine, this.pos - this.lineStart, this.pos);
|
|
5013
5010
|
}
|
|
5014
5011
|
|
|
5015
5012
|
clone(skipArrays) {
|
|
@@ -5083,7 +5080,6 @@
|
|
|
5083
5080
|
this.pushToken(new Token(this.state));
|
|
5084
5081
|
}
|
|
5085
5082
|
|
|
5086
|
-
this.state.lastTokEnd = this.state.end;
|
|
5087
5083
|
this.state.lastTokStart = this.state.start;
|
|
5088
5084
|
this.state.lastTokEndLoc = this.state.endLoc;
|
|
5089
5085
|
this.state.lastTokStartLoc = this.state.startLoc;
|
|
@@ -5110,9 +5106,13 @@
|
|
|
5110
5106
|
type: state.type,
|
|
5111
5107
|
start: state.start,
|
|
5112
5108
|
end: state.end,
|
|
5113
|
-
lastTokEnd: state.end,
|
|
5114
5109
|
context: [this.curContext()],
|
|
5115
|
-
inType: state.inType
|
|
5110
|
+
inType: state.inType,
|
|
5111
|
+
startLoc: state.startLoc,
|
|
5112
|
+
lastTokEndLoc: state.lastTokEndLoc,
|
|
5113
|
+
curLine: state.curLine,
|
|
5114
|
+
lineStart: state.lineStart,
|
|
5115
|
+
curPosition: state.curPosition
|
|
5116
5116
|
};
|
|
5117
5117
|
}
|
|
5118
5118
|
|
|
@@ -5158,7 +5158,15 @@
|
|
|
5158
5158
|
this.state.strict = strict;
|
|
5159
5159
|
|
|
5160
5160
|
if (strict) {
|
|
5161
|
-
this.state.strictErrors.forEach(
|
|
5161
|
+
this.state.strictErrors.forEach(_ref5 => {
|
|
5162
|
+
var {
|
|
5163
|
+
message,
|
|
5164
|
+
loc
|
|
5165
|
+
} = _ref5;
|
|
5166
|
+
return this.raise(message, {
|
|
5167
|
+
at: loc
|
|
5168
|
+
});
|
|
5169
|
+
});
|
|
5162
5170
|
this.state.strictErrors.clear();
|
|
5163
5171
|
}
|
|
5164
5172
|
}
|
|
@@ -5185,7 +5193,13 @@
|
|
|
5185
5193
|
if (!this.isLookahead) startLoc = this.state.curPosition();
|
|
5186
5194
|
var start = this.state.pos;
|
|
5187
5195
|
var end = this.input.indexOf("*/", start + 2);
|
|
5188
|
-
|
|
5196
|
+
|
|
5197
|
+
if (end === -1) {
|
|
5198
|
+
throw this.raise(ErrorMessages.UnterminatedComment, {
|
|
5199
|
+
at: this.state.curPosition()
|
|
5200
|
+
});
|
|
5201
|
+
}
|
|
5202
|
+
|
|
5189
5203
|
this.state.pos = end + 2;
|
|
5190
5204
|
lineBreakG.lastIndex = start + 2;
|
|
5191
5205
|
|
|
@@ -5343,12 +5357,12 @@
|
|
|
5343
5357
|
|
|
5344
5358
|
finishToken(type, val) {
|
|
5345
5359
|
this.state.end = this.state.pos;
|
|
5360
|
+
this.state.endLoc = this.state.curPosition();
|
|
5346
5361
|
var prevType = this.state.type;
|
|
5347
5362
|
this.state.type = type;
|
|
5348
5363
|
this.state.value = val;
|
|
5349
5364
|
|
|
5350
5365
|
if (!this.isLookahead) {
|
|
5351
|
-
this.state.endLoc = this.state.curPosition();
|
|
5352
5366
|
this.updateContext(prevType);
|
|
5353
5367
|
}
|
|
5354
5368
|
}
|
|
@@ -5367,14 +5381,18 @@
|
|
|
5367
5381
|
var next = this.codePointAtPos(nextPos);
|
|
5368
5382
|
|
|
5369
5383
|
if (next >= 48 && next <= 57) {
|
|
5370
|
-
throw this.raise(
|
|
5384
|
+
throw this.raise(ErrorMessages.UnexpectedDigitAfterHash, {
|
|
5385
|
+
at: this.state.curPosition()
|
|
5386
|
+
});
|
|
5371
5387
|
}
|
|
5372
5388
|
|
|
5373
5389
|
if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
|
|
5374
5390
|
this.expectPlugin("recordAndTuple");
|
|
5375
5391
|
|
|
5376
5392
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") {
|
|
5377
|
-
throw this.raise(
|
|
5393
|
+
throw this.raise(next === 123 ? ErrorMessages.RecordExpressionHashIncorrectStartSyntaxType : ErrorMessages.TupleExpressionHashIncorrectStartSyntaxType, {
|
|
5394
|
+
at: this.state.curPosition()
|
|
5395
|
+
});
|
|
5378
5396
|
}
|
|
5379
5397
|
|
|
5380
5398
|
this.state.pos += 2;
|
|
@@ -5478,7 +5496,9 @@
|
|
|
5478
5496
|
|
|
5479
5497
|
if (this.hasPlugin("recordAndTuple") && next === 125) {
|
|
5480
5498
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
|
5481
|
-
throw this.raise(
|
|
5499
|
+
throw this.raise(ErrorMessages.RecordExpressionBarIncorrectEndSyntaxType, {
|
|
5500
|
+
at: this.state.curPosition()
|
|
5501
|
+
});
|
|
5482
5502
|
}
|
|
5483
5503
|
|
|
5484
5504
|
this.state.pos += 2;
|
|
@@ -5488,7 +5508,9 @@
|
|
|
5488
5508
|
|
|
5489
5509
|
if (this.hasPlugin("recordAndTuple") && next === 93) {
|
|
5490
5510
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
|
5491
|
-
throw this.raise(
|
|
5511
|
+
throw this.raise(ErrorMessages.TupleExpressionBarIncorrectEndSyntaxType, {
|
|
5512
|
+
at: this.state.curPosition()
|
|
5513
|
+
});
|
|
5492
5514
|
}
|
|
5493
5515
|
|
|
5494
5516
|
this.state.pos += 2;
|
|
@@ -5645,7 +5667,9 @@
|
|
|
5645
5667
|
case 91:
|
|
5646
5668
|
if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
|
|
5647
5669
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
|
5648
|
-
throw this.raise(
|
|
5670
|
+
throw this.raise(ErrorMessages.TupleExpressionBarIncorrectStartSyntaxType, {
|
|
5671
|
+
at: this.state.curPosition()
|
|
5672
|
+
});
|
|
5649
5673
|
}
|
|
5650
5674
|
|
|
5651
5675
|
this.state.pos += 2;
|
|
@@ -5665,7 +5689,9 @@
|
|
|
5665
5689
|
case 123:
|
|
5666
5690
|
if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
|
|
5667
5691
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
|
5668
|
-
throw this.raise(
|
|
5692
|
+
throw this.raise(ErrorMessages.RecordExpressionBarIncorrectStartSyntaxType, {
|
|
5693
|
+
at: this.state.curPosition()
|
|
5694
|
+
});
|
|
5669
5695
|
}
|
|
5670
5696
|
|
|
5671
5697
|
this.state.pos += 2;
|
|
@@ -5798,7 +5824,9 @@
|
|
|
5798
5824
|
|
|
5799
5825
|
}
|
|
5800
5826
|
|
|
5801
|
-
throw this.raise(
|
|
5827
|
+
throw this.raise(ErrorMessages.InvalidOrUnexpectedToken, {
|
|
5828
|
+
at: this.state.curPosition()
|
|
5829
|
+
}, String.fromCodePoint(code));
|
|
5802
5830
|
}
|
|
5803
5831
|
|
|
5804
5832
|
finishOp(type, size) {
|
|
@@ -5808,6 +5836,7 @@
|
|
|
5808
5836
|
}
|
|
5809
5837
|
|
|
5810
5838
|
readRegexp() {
|
|
5839
|
+
var startLoc = this.state.startLoc;
|
|
5811
5840
|
var start = this.state.start + 1;
|
|
5812
5841
|
var escaped, inClass;
|
|
5813
5842
|
var {
|
|
@@ -5816,13 +5845,17 @@
|
|
|
5816
5845
|
|
|
5817
5846
|
for (;; ++pos) {
|
|
5818
5847
|
if (pos >= this.length) {
|
|
5819
|
-
throw this.raise(
|
|
5848
|
+
throw this.raise(ErrorMessages.UnterminatedRegExp, {
|
|
5849
|
+
at: createPositionWithColumnOffset(startLoc, 1)
|
|
5850
|
+
});
|
|
5820
5851
|
}
|
|
5821
5852
|
|
|
5822
5853
|
var ch = this.input.charCodeAt(pos);
|
|
5823
5854
|
|
|
5824
5855
|
if (isNewLine(ch)) {
|
|
5825
|
-
throw this.raise(
|
|
5856
|
+
throw this.raise(ErrorMessages.UnterminatedRegExp, {
|
|
5857
|
+
at: createPositionWithColumnOffset(startLoc, 1)
|
|
5858
|
+
});
|
|
5826
5859
|
}
|
|
5827
5860
|
|
|
5828
5861
|
if (escaped) {
|
|
@@ -5850,10 +5883,14 @@
|
|
|
5850
5883
|
|
|
5851
5884
|
if (VALID_REGEX_FLAGS.has(cp)) {
|
|
5852
5885
|
if (mods.includes(char)) {
|
|
5853
|
-
this.raise(
|
|
5886
|
+
this.raise(ErrorMessages.DuplicateRegExpFlags, {
|
|
5887
|
+
at: createPositionWithColumnOffset(startLoc, pos + 2 - start)
|
|
5888
|
+
});
|
|
5854
5889
|
}
|
|
5855
5890
|
} else if (isIdentifierChar(cp) || cp === 92) {
|
|
5856
|
-
this.raise(
|
|
5891
|
+
this.raise(ErrorMessages.MalformedRegExpFlags, {
|
|
5892
|
+
at: createPositionWithColumnOffset(startLoc, pos + 2 - start)
|
|
5893
|
+
});
|
|
5857
5894
|
} else {
|
|
5858
5895
|
break;
|
|
5859
5896
|
}
|
|
@@ -5886,13 +5923,19 @@
|
|
|
5886
5923
|
var next = this.input.charCodeAt(this.state.pos + 1);
|
|
5887
5924
|
|
|
5888
5925
|
if (allowedSiblings.indexOf(next) === -1) {
|
|
5889
|
-
this.raise(
|
|
5926
|
+
this.raise(ErrorMessages.UnexpectedNumericSeparator, {
|
|
5927
|
+
at: this.state.curPosition()
|
|
5928
|
+
});
|
|
5890
5929
|
} else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
|
|
5891
|
-
this.raise(
|
|
5930
|
+
this.raise(ErrorMessages.UnexpectedNumericSeparator, {
|
|
5931
|
+
at: this.state.curPosition()
|
|
5932
|
+
});
|
|
5892
5933
|
}
|
|
5893
5934
|
|
|
5894
5935
|
if (!allowNumSeparator) {
|
|
5895
|
-
this.raise(
|
|
5936
|
+
this.raise(ErrorMessages.NumericSeparatorInEscapeSequence, {
|
|
5937
|
+
at: this.state.curPosition()
|
|
5938
|
+
});
|
|
5896
5939
|
}
|
|
5897
5940
|
|
|
5898
5941
|
++this.state.pos;
|
|
@@ -5912,7 +5955,9 @@
|
|
|
5912
5955
|
if (val >= radix) {
|
|
5913
5956
|
if (this.options.errorRecovery && val <= 9) {
|
|
5914
5957
|
val = 0;
|
|
5915
|
-
this.raise(
|
|
5958
|
+
this.raise(ErrorMessages.InvalidDigit, {
|
|
5959
|
+
at: this.state.curPosition()
|
|
5960
|
+
}, radix);
|
|
5916
5961
|
} else if (forceLen) {
|
|
5917
5962
|
val = 0;
|
|
5918
5963
|
invalid = true;
|
|
@@ -5933,13 +5978,15 @@
|
|
|
5933
5978
|
}
|
|
5934
5979
|
|
|
5935
5980
|
readRadixNumber(radix) {
|
|
5936
|
-
var
|
|
5981
|
+
var startLoc = this.state.curPosition();
|
|
5937
5982
|
var isBigInt = false;
|
|
5938
5983
|
this.state.pos += 2;
|
|
5939
5984
|
var val = this.readInt(radix);
|
|
5940
5985
|
|
|
5941
5986
|
if (val == null) {
|
|
5942
|
-
this.raise(
|
|
5987
|
+
this.raise(ErrorMessages.InvalidDigit, {
|
|
5988
|
+
at: createPositionWithColumnOffset(startLoc, 2)
|
|
5989
|
+
}, radix);
|
|
5943
5990
|
}
|
|
5944
5991
|
|
|
5945
5992
|
var next = this.input.charCodeAt(this.state.pos);
|
|
@@ -5948,15 +5995,19 @@
|
|
|
5948
5995
|
++this.state.pos;
|
|
5949
5996
|
isBigInt = true;
|
|
5950
5997
|
} else if (next === 109) {
|
|
5951
|
-
throw this.raise(
|
|
5998
|
+
throw this.raise(ErrorMessages.InvalidDecimal, {
|
|
5999
|
+
at: startLoc
|
|
6000
|
+
});
|
|
5952
6001
|
}
|
|
5953
6002
|
|
|
5954
6003
|
if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
|
|
5955
|
-
throw this.raise(
|
|
6004
|
+
throw this.raise(ErrorMessages.NumberIdentifier, {
|
|
6005
|
+
at: this.state.curPosition()
|
|
6006
|
+
});
|
|
5956
6007
|
}
|
|
5957
6008
|
|
|
5958
6009
|
if (isBigInt) {
|
|
5959
|
-
var str = this.input.slice(
|
|
6010
|
+
var str = this.input.slice(indexes.get(startLoc), this.state.pos).replace(/[_n]/g, "");
|
|
5960
6011
|
this.finishToken(127, str);
|
|
5961
6012
|
return;
|
|
5962
6013
|
}
|
|
@@ -5966,6 +6017,7 @@
|
|
|
5966
6017
|
|
|
5967
6018
|
readNumber(startsWithDot) {
|
|
5968
6019
|
var start = this.state.pos;
|
|
6020
|
+
var startLoc = this.state.curPosition();
|
|
5969
6021
|
var isFloat = false;
|
|
5970
6022
|
var isBigInt = false;
|
|
5971
6023
|
var isDecimal = false;
|
|
@@ -5973,20 +6025,24 @@
|
|
|
5973
6025
|
var isOctal = false;
|
|
5974
6026
|
|
|
5975
6027
|
if (!startsWithDot && this.readInt(10) === null) {
|
|
5976
|
-
this.raise(
|
|
6028
|
+
this.raise(ErrorMessages.InvalidNumber, {
|
|
6029
|
+
at: this.state.curPosition()
|
|
6030
|
+
});
|
|
5977
6031
|
}
|
|
5978
6032
|
|
|
5979
6033
|
var hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
|
5980
6034
|
|
|
5981
6035
|
if (hasLeadingZero) {
|
|
5982
6036
|
var integer = this.input.slice(start, this.state.pos);
|
|
5983
|
-
this.recordStrictModeErrors(
|
|
6037
|
+
this.recordStrictModeErrors(ErrorMessages.StrictOctalLiteral, startLoc);
|
|
5984
6038
|
|
|
5985
6039
|
if (!this.state.strict) {
|
|
5986
6040
|
var underscorePos = integer.indexOf("_");
|
|
5987
6041
|
|
|
5988
6042
|
if (underscorePos > 0) {
|
|
5989
|
-
this.raise(
|
|
6043
|
+
this.raise(ErrorMessages.ZeroDigitNumericSeparator, {
|
|
6044
|
+
at: createPositionWithColumnOffset(startLoc, underscorePos)
|
|
6045
|
+
});
|
|
5990
6046
|
}
|
|
5991
6047
|
}
|
|
5992
6048
|
|
|
@@ -6010,7 +6066,9 @@
|
|
|
6010
6066
|
}
|
|
6011
6067
|
|
|
6012
6068
|
if (this.readInt(10) === null) {
|
|
6013
|
-
this.raise(
|
|
6069
|
+
this.raise(ErrorMessages.InvalidOrMissingExponent, {
|
|
6070
|
+
at: startLoc
|
|
6071
|
+
});
|
|
6014
6072
|
}
|
|
6015
6073
|
|
|
6016
6074
|
isFloat = true;
|
|
@@ -6020,7 +6078,9 @@
|
|
|
6020
6078
|
|
|
6021
6079
|
if (next === 110) {
|
|
6022
6080
|
if (isFloat || hasLeadingZero) {
|
|
6023
|
-
this.raise(
|
|
6081
|
+
this.raise(ErrorMessages.InvalidBigIntLiteral, {
|
|
6082
|
+
at: startLoc
|
|
6083
|
+
});
|
|
6024
6084
|
}
|
|
6025
6085
|
|
|
6026
6086
|
++this.state.pos;
|
|
@@ -6028,10 +6088,12 @@
|
|
|
6028
6088
|
}
|
|
6029
6089
|
|
|
6030
6090
|
if (next === 109) {
|
|
6031
|
-
this.expectPlugin("decimal", this.state.
|
|
6091
|
+
this.expectPlugin("decimal", this.state.curPosition());
|
|
6032
6092
|
|
|
6033
6093
|
if (hasExponent || hasLeadingZero) {
|
|
6034
|
-
this.raise(
|
|
6094
|
+
this.raise(ErrorMessages.InvalidDecimal, {
|
|
6095
|
+
at: startLoc
|
|
6096
|
+
});
|
|
6035
6097
|
}
|
|
6036
6098
|
|
|
6037
6099
|
++this.state.pos;
|
|
@@ -6039,7 +6101,9 @@
|
|
|
6039
6101
|
}
|
|
6040
6102
|
|
|
6041
6103
|
if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
|
|
6042
|
-
throw this.raise(
|
|
6104
|
+
throw this.raise(ErrorMessages.NumberIdentifier, {
|
|
6105
|
+
at: this.state.curPosition()
|
|
6106
|
+
});
|
|
6043
6107
|
}
|
|
6044
6108
|
|
|
6045
6109
|
var str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
|
|
@@ -6063,13 +6127,15 @@
|
|
|
6063
6127
|
var code;
|
|
6064
6128
|
|
|
6065
6129
|
if (ch === 123) {
|
|
6066
|
-
|
|
6130
|
+
++this.state.pos;
|
|
6067
6131
|
code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, true, throwOnInvalid);
|
|
6068
6132
|
++this.state.pos;
|
|
6069
6133
|
|
|
6070
6134
|
if (code !== null && code > 0x10ffff) {
|
|
6071
6135
|
if (throwOnInvalid) {
|
|
6072
|
-
this.raise(
|
|
6136
|
+
this.raise(ErrorMessages.InvalidCodePoint, {
|
|
6137
|
+
at: this.state.curPosition()
|
|
6138
|
+
});
|
|
6073
6139
|
} else {
|
|
6074
6140
|
return null;
|
|
6075
6141
|
}
|
|
@@ -6087,7 +6153,9 @@
|
|
|
6087
6153
|
|
|
6088
6154
|
for (;;) {
|
|
6089
6155
|
if (this.state.pos >= this.length) {
|
|
6090
|
-
throw this.raise(
|
|
6156
|
+
throw this.raise(ErrorMessages.UnterminatedString, {
|
|
6157
|
+
at: this.state.startLoc
|
|
6158
|
+
});
|
|
6091
6159
|
}
|
|
6092
6160
|
|
|
6093
6161
|
var ch = this.input.charCodeAt(this.state.pos);
|
|
@@ -6102,7 +6170,9 @@
|
|
|
6102
6170
|
++this.state.curLine;
|
|
6103
6171
|
this.state.lineStart = this.state.pos;
|
|
6104
6172
|
} else if (isNewLine(ch)) {
|
|
6105
|
-
throw this.raise(
|
|
6173
|
+
throw this.raise(ErrorMessages.UnterminatedString, {
|
|
6174
|
+
at: this.state.startLoc
|
|
6175
|
+
});
|
|
6106
6176
|
} else {
|
|
6107
6177
|
++this.state.pos;
|
|
6108
6178
|
}
|
|
@@ -6114,7 +6184,7 @@
|
|
|
6114
6184
|
|
|
6115
6185
|
readTemplateContinuation() {
|
|
6116
6186
|
if (!this.match(8)) {
|
|
6117
|
-
this.unexpected(
|
|
6187
|
+
this.unexpected(null, 8);
|
|
6118
6188
|
}
|
|
6119
6189
|
|
|
6120
6190
|
this.state.pos--;
|
|
@@ -6129,7 +6199,9 @@
|
|
|
6129
6199
|
|
|
6130
6200
|
for (;;) {
|
|
6131
6201
|
if (this.state.pos >= this.length) {
|
|
6132
|
-
throw this.raise(
|
|
6202
|
+
throw this.raise(ErrorMessages.UnterminatedTemplate, {
|
|
6203
|
+
at: createPositionWithColumnOffset(this.state.startLoc, 1)
|
|
6204
|
+
});
|
|
6133
6205
|
}
|
|
6134
6206
|
|
|
6135
6207
|
var ch = this.input.charCodeAt(this.state.pos);
|
|
@@ -6187,11 +6259,18 @@
|
|
|
6187
6259
|
}
|
|
6188
6260
|
}
|
|
6189
6261
|
|
|
6190
|
-
recordStrictModeErrors(
|
|
6191
|
-
|
|
6192
|
-
|
|
6262
|
+
recordStrictModeErrors(message, loc) {
|
|
6263
|
+
var index = indexes.get(loc);
|
|
6264
|
+
|
|
6265
|
+
if (this.state.strict && !this.state.strictErrors.has(index)) {
|
|
6266
|
+
this.raise(message, {
|
|
6267
|
+
at: loc
|
|
6268
|
+
});
|
|
6193
6269
|
} else {
|
|
6194
|
-
this.state.strictErrors.set(
|
|
6270
|
+
this.state.strictErrors.set(index, {
|
|
6271
|
+
loc,
|
|
6272
|
+
message
|
|
6273
|
+
});
|
|
6195
6274
|
}
|
|
6196
6275
|
}
|
|
6197
6276
|
|
|
@@ -6250,12 +6329,12 @@
|
|
|
6250
6329
|
if (inTemplate) {
|
|
6251
6330
|
return null;
|
|
6252
6331
|
} else {
|
|
6253
|
-
this.recordStrictModeErrors(this.state.
|
|
6332
|
+
this.recordStrictModeErrors(ErrorMessages.StrictNumericEscape, createPositionWithColumnOffset(this.state.curPosition(), -1));
|
|
6254
6333
|
}
|
|
6255
6334
|
|
|
6256
6335
|
default:
|
|
6257
6336
|
if (ch >= 48 && ch <= 55) {
|
|
6258
|
-
var codePos = this.state.
|
|
6337
|
+
var codePos = createPositionWithColumnOffset(this.state.curPosition(), -1);
|
|
6259
6338
|
var match = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/);
|
|
6260
6339
|
var octalStr = match[0];
|
|
6261
6340
|
var octal = parseInt(octalStr, 8);
|
|
@@ -6272,7 +6351,7 @@
|
|
|
6272
6351
|
if (inTemplate) {
|
|
6273
6352
|
return null;
|
|
6274
6353
|
} else {
|
|
6275
|
-
this.recordStrictModeErrors(
|
|
6354
|
+
this.recordStrictModeErrors(ErrorMessages.StrictNumericEscape, codePos);
|
|
6276
6355
|
}
|
|
6277
6356
|
}
|
|
6278
6357
|
|
|
@@ -6284,14 +6363,16 @@
|
|
|
6284
6363
|
}
|
|
6285
6364
|
|
|
6286
6365
|
readHexChar(len, forceLen, throwOnInvalid) {
|
|
6287
|
-
var
|
|
6366
|
+
var codeLoc = this.state.curPosition();
|
|
6288
6367
|
var n = this.readInt(16, len, forceLen, false);
|
|
6289
6368
|
|
|
6290
6369
|
if (n === null) {
|
|
6291
6370
|
if (throwOnInvalid) {
|
|
6292
|
-
this.raise(
|
|
6371
|
+
this.raise(ErrorMessages.InvalidEscapeSequence, {
|
|
6372
|
+
at: codeLoc
|
|
6373
|
+
});
|
|
6293
6374
|
} else {
|
|
6294
|
-
this.state.pos =
|
|
6375
|
+
this.state.pos = indexes.get(codeLoc) - 1;
|
|
6295
6376
|
}
|
|
6296
6377
|
}
|
|
6297
6378
|
|
|
@@ -6316,11 +6397,13 @@
|
|
|
6316
6397
|
} else if (ch === 92) {
|
|
6317
6398
|
this.state.containsEsc = true;
|
|
6318
6399
|
word += this.input.slice(chunkStart, this.state.pos);
|
|
6319
|
-
var escStart = this.state.
|
|
6400
|
+
var escStart = this.state.curPosition();
|
|
6320
6401
|
var identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
|
|
6321
6402
|
|
|
6322
6403
|
if (this.input.charCodeAt(++this.state.pos) !== 117) {
|
|
6323
|
-
this.raise(
|
|
6404
|
+
this.raise(ErrorMessages.MissingUnicodeEscape, {
|
|
6405
|
+
at: this.state.curPosition()
|
|
6406
|
+
});
|
|
6324
6407
|
chunkStart = this.state.pos - 1;
|
|
6325
6408
|
continue;
|
|
6326
6409
|
}
|
|
@@ -6330,7 +6413,9 @@
|
|
|
6330
6413
|
|
|
6331
6414
|
if (esc !== null) {
|
|
6332
6415
|
if (!identifierCheck(esc)) {
|
|
6333
|
-
this.raise(
|
|
6416
|
+
this.raise(ErrorMessages.EscapedCharNotAnIdentifier, {
|
|
6417
|
+
at: escStart
|
|
6418
|
+
});
|
|
6334
6419
|
}
|
|
6335
6420
|
|
|
6336
6421
|
word += String.fromCodePoint(esc);
|
|
@@ -6362,7 +6447,9 @@
|
|
|
6362
6447
|
} = this.state;
|
|
6363
6448
|
|
|
6364
6449
|
if (tokenIsKeyword(type) && this.state.containsEsc) {
|
|
6365
|
-
this.raise(
|
|
6450
|
+
this.raise(ErrorMessages.InvalidEscapedReservedWord, {
|
|
6451
|
+
at: this.state.startLoc
|
|
6452
|
+
}, tokenLabelName(type));
|
|
6366
6453
|
}
|
|
6367
6454
|
}
|
|
6368
6455
|
|
|
@@ -6398,18 +6485,20 @@
|
|
|
6398
6485
|
var oldClassScope = this.stack.pop();
|
|
6399
6486
|
var current = this.current();
|
|
6400
6487
|
|
|
6401
|
-
for (var [name,
|
|
6488
|
+
for (var [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
|
|
6402
6489
|
if (current) {
|
|
6403
6490
|
if (!current.undefinedPrivateNames.has(name)) {
|
|
6404
|
-
current.undefinedPrivateNames.set(name,
|
|
6491
|
+
current.undefinedPrivateNames.set(name, loc);
|
|
6405
6492
|
}
|
|
6406
6493
|
} else {
|
|
6407
|
-
this.raise(
|
|
6494
|
+
this.raise(ErrorMessages.InvalidPrivateFieldResolution, {
|
|
6495
|
+
at: loc
|
|
6496
|
+
}, name);
|
|
6408
6497
|
}
|
|
6409
6498
|
}
|
|
6410
6499
|
}
|
|
6411
6500
|
|
|
6412
|
-
declarePrivateName(name, elementType,
|
|
6501
|
+
declarePrivateName(name, elementType, loc) {
|
|
6413
6502
|
var {
|
|
6414
6503
|
privateNames,
|
|
6415
6504
|
loneAccessors,
|
|
@@ -6433,14 +6522,16 @@
|
|
|
6433
6522
|
}
|
|
6434
6523
|
|
|
6435
6524
|
if (redefined) {
|
|
6436
|
-
this.raise(
|
|
6525
|
+
this.raise(ErrorMessages.PrivateNameRedeclaration, {
|
|
6526
|
+
at: loc
|
|
6527
|
+
}, name);
|
|
6437
6528
|
}
|
|
6438
6529
|
|
|
6439
6530
|
privateNames.add(name);
|
|
6440
6531
|
undefinedPrivateNames.delete(name);
|
|
6441
6532
|
}
|
|
6442
6533
|
|
|
6443
|
-
usePrivateName(name,
|
|
6534
|
+
usePrivateName(name, loc) {
|
|
6444
6535
|
var classScope;
|
|
6445
6536
|
|
|
6446
6537
|
for (classScope of this.stack) {
|
|
@@ -6448,9 +6539,11 @@
|
|
|
6448
6539
|
}
|
|
6449
6540
|
|
|
6450
6541
|
if (classScope) {
|
|
6451
|
-
classScope.undefinedPrivateNames.set(name,
|
|
6542
|
+
classScope.undefinedPrivateNames.set(name, loc);
|
|
6452
6543
|
} else {
|
|
6453
|
-
this.raise(
|
|
6544
|
+
this.raise(ErrorMessages.InvalidPrivateFieldResolution, {
|
|
6545
|
+
at: loc
|
|
6546
|
+
}, name);
|
|
6454
6547
|
}
|
|
6455
6548
|
}
|
|
6456
6549
|
|
|
@@ -6484,12 +6577,15 @@
|
|
|
6484
6577
|
this.errors = new Map();
|
|
6485
6578
|
}
|
|
6486
6579
|
|
|
6487
|
-
recordDeclarationError(
|
|
6488
|
-
this.errors.set(
|
|
6580
|
+
recordDeclarationError(message, loc) {
|
|
6581
|
+
this.errors.set(indexes.get(loc), {
|
|
6582
|
+
message,
|
|
6583
|
+
loc
|
|
6584
|
+
});
|
|
6489
6585
|
}
|
|
6490
6586
|
|
|
6491
|
-
clearDeclarationError(
|
|
6492
|
-
this.errors.delete(
|
|
6587
|
+
clearDeclarationError(loc) {
|
|
6588
|
+
this.errors.delete(indexes.get(loc));
|
|
6493
6589
|
}
|
|
6494
6590
|
|
|
6495
6591
|
iterateErrors(iterator) {
|
|
@@ -6512,7 +6608,7 @@
|
|
|
6512
6608
|
this.stack.pop();
|
|
6513
6609
|
}
|
|
6514
6610
|
|
|
6515
|
-
recordParameterInitializerError(
|
|
6611
|
+
recordParameterInitializerError(loc, template) {
|
|
6516
6612
|
var {
|
|
6517
6613
|
stack
|
|
6518
6614
|
} = this;
|
|
@@ -6521,7 +6617,7 @@
|
|
|
6521
6617
|
|
|
6522
6618
|
while (!scope.isCertainlyParameterDeclaration()) {
|
|
6523
6619
|
if (scope.canBeArrowParameterDeclaration()) {
|
|
6524
|
-
scope.recordDeclarationError(
|
|
6620
|
+
scope.recordDeclarationError(template, loc);
|
|
6525
6621
|
} else {
|
|
6526
6622
|
return;
|
|
6527
6623
|
}
|
|
@@ -6529,25 +6625,29 @@
|
|
|
6529
6625
|
scope = stack[--i];
|
|
6530
6626
|
}
|
|
6531
6627
|
|
|
6532
|
-
this.raise(
|
|
6628
|
+
this.raise(template, {
|
|
6629
|
+
at: loc
|
|
6630
|
+
});
|
|
6533
6631
|
}
|
|
6534
6632
|
|
|
6535
|
-
recordParenthesizedIdentifierError(
|
|
6633
|
+
recordParenthesizedIdentifierError(template, loc) {
|
|
6536
6634
|
var {
|
|
6537
6635
|
stack
|
|
6538
6636
|
} = this;
|
|
6539
6637
|
var scope = stack[stack.length - 1];
|
|
6540
6638
|
|
|
6541
6639
|
if (scope.isCertainlyParameterDeclaration()) {
|
|
6542
|
-
this.raise(
|
|
6640
|
+
this.raise(template, {
|
|
6641
|
+
at: loc
|
|
6642
|
+
});
|
|
6543
6643
|
} else if (scope.canBeArrowParameterDeclaration()) {
|
|
6544
|
-
scope.recordDeclarationError(
|
|
6644
|
+
scope.recordDeclarationError(template, loc);
|
|
6545
6645
|
} else {
|
|
6546
6646
|
return;
|
|
6547
6647
|
}
|
|
6548
6648
|
}
|
|
6549
6649
|
|
|
6550
|
-
recordAsyncArrowParametersError(
|
|
6650
|
+
recordAsyncArrowParametersError(template, loc) {
|
|
6551
6651
|
var {
|
|
6552
6652
|
stack
|
|
6553
6653
|
} = this;
|
|
@@ -6556,7 +6656,7 @@
|
|
|
6556
6656
|
|
|
6557
6657
|
while (scope.canBeArrowParameterDeclaration()) {
|
|
6558
6658
|
if (scope.type === kMaybeAsyncArrowParameterDeclaration) {
|
|
6559
|
-
scope.recordDeclarationError(
|
|
6659
|
+
scope.recordDeclarationError(template, loc);
|
|
6560
6660
|
}
|
|
6561
6661
|
|
|
6562
6662
|
scope = stack[--i];
|
|
@@ -6569,13 +6669,19 @@
|
|
|
6569
6669
|
} = this;
|
|
6570
6670
|
var currentScope = stack[stack.length - 1];
|
|
6571
6671
|
if (!currentScope.canBeArrowParameterDeclaration()) return;
|
|
6572
|
-
currentScope.iterateErrors(
|
|
6573
|
-
|
|
6672
|
+
currentScope.iterateErrors(_ref6 => {
|
|
6673
|
+
var {
|
|
6674
|
+
message,
|
|
6675
|
+
loc
|
|
6676
|
+
} = _ref6;
|
|
6677
|
+
this.raise(message, {
|
|
6678
|
+
at: loc
|
|
6679
|
+
});
|
|
6574
6680
|
var i = stack.length - 2;
|
|
6575
6681
|
var scope = stack[i];
|
|
6576
6682
|
|
|
6577
6683
|
while (scope.canBeArrowParameterDeclaration()) {
|
|
6578
|
-
scope.clearDeclarationError(
|
|
6684
|
+
scope.clearDeclarationError(loc);
|
|
6579
6685
|
scope = stack[--i];
|
|
6580
6686
|
}
|
|
6581
6687
|
});
|
|
@@ -6645,10 +6751,19 @@
|
|
|
6645
6751
|
}
|
|
6646
6752
|
|
|
6647
6753
|
class UtilParser extends Tokenizer {
|
|
6648
|
-
addExtra(node, key,
|
|
6754
|
+
addExtra(node, key, value) {
|
|
6755
|
+
var enumerable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
6649
6756
|
if (!node) return;
|
|
6650
6757
|
var extra = node.extra = node.extra || {};
|
|
6651
|
-
|
|
6758
|
+
|
|
6759
|
+
if (enumerable) {
|
|
6760
|
+
extra[key] = value;
|
|
6761
|
+
} else {
|
|
6762
|
+
Object.defineProperty(extra, key, {
|
|
6763
|
+
enumerable,
|
|
6764
|
+
value
|
|
6765
|
+
});
|
|
6766
|
+
}
|
|
6652
6767
|
}
|
|
6653
6768
|
|
|
6654
6769
|
isContextual(token) {
|
|
@@ -6681,7 +6796,15 @@
|
|
|
6681
6796
|
}
|
|
6682
6797
|
|
|
6683
6798
|
expectContextual(token, template) {
|
|
6684
|
-
if (!this.eatContextual(token))
|
|
6799
|
+
if (!this.eatContextual(token)) {
|
|
6800
|
+
if (template != null) {
|
|
6801
|
+
throw this.raise(template, {
|
|
6802
|
+
at: this.state.startLoc
|
|
6803
|
+
});
|
|
6804
|
+
}
|
|
6805
|
+
|
|
6806
|
+
throw this.unexpected(null, token);
|
|
6807
|
+
}
|
|
6685
6808
|
}
|
|
6686
6809
|
|
|
6687
6810
|
canInsertSemicolon() {
|
|
@@ -6689,7 +6812,7 @@
|
|
|
6689
6812
|
}
|
|
6690
6813
|
|
|
6691
6814
|
hasPrecedingLineBreak() {
|
|
6692
|
-
return lineBreak.test(this.input.slice(this.state.
|
|
6815
|
+
return lineBreak.test(this.input.slice(indexes.get(this.state.lastTokEndLoc), this.state.start));
|
|
6693
6816
|
}
|
|
6694
6817
|
|
|
6695
6818
|
hasFollowingLineBreak() {
|
|
@@ -6704,41 +6827,37 @@
|
|
|
6704
6827
|
semicolon() {
|
|
6705
6828
|
var allowAsi = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
6706
6829
|
if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
|
|
6707
|
-
this.raise(
|
|
6830
|
+
this.raise(ErrorMessages.MissingSemicolon, {
|
|
6831
|
+
at: this.state.lastTokEndLoc
|
|
6832
|
+
});
|
|
6708
6833
|
}
|
|
6709
6834
|
|
|
6710
|
-
expect(type,
|
|
6711
|
-
this.eat(type) || this.unexpected(
|
|
6835
|
+
expect(type, loc) {
|
|
6836
|
+
this.eat(type) || this.unexpected(loc, type);
|
|
6712
6837
|
}
|
|
6713
6838
|
|
|
6714
6839
|
assertNoSpace() {
|
|
6715
6840
|
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Unexpected space.";
|
|
6716
6841
|
|
|
6717
|
-
if (this.state.start > this.state.
|
|
6718
|
-
this.raise(
|
|
6842
|
+
if (this.state.start > indexes.get(this.state.lastTokEndLoc)) {
|
|
6843
|
+
this.raise({
|
|
6719
6844
|
code: ErrorCodes.SyntaxError,
|
|
6720
6845
|
reasonCode: "UnexpectedSpace",
|
|
6721
6846
|
template: message
|
|
6847
|
+
}, {
|
|
6848
|
+
at: this.state.lastTokEndLoc
|
|
6722
6849
|
});
|
|
6723
6850
|
}
|
|
6724
6851
|
}
|
|
6725
6852
|
|
|
6726
|
-
unexpected(
|
|
6727
|
-
|
|
6853
|
+
unexpected(loc, type) {
|
|
6854
|
+
throw this.raise({
|
|
6728
6855
|
code: ErrorCodes.SyntaxError,
|
|
6729
6856
|
reasonCode: "UnexpectedToken",
|
|
6730
|
-
template: "Unexpected token"
|
|
6731
|
-
}
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
messageOrType = {
|
|
6735
|
-
code: ErrorCodes.SyntaxError,
|
|
6736
|
-
reasonCode: "UnexpectedToken",
|
|
6737
|
-
template: "Unexpected token, expected \"".concat(tokenLabelName(messageOrType), "\"")
|
|
6738
|
-
};
|
|
6739
|
-
}
|
|
6740
|
-
|
|
6741
|
-
throw this.raise(pos != null ? pos : this.state.start, messageOrType);
|
|
6857
|
+
template: type != null ? "Unexpected token, expected \"".concat(tokenLabelName(type), "\"") : "Unexpected token"
|
|
6858
|
+
}, {
|
|
6859
|
+
at: loc != null ? loc : this.state.startLoc
|
|
6860
|
+
});
|
|
6742
6861
|
}
|
|
6743
6862
|
|
|
6744
6863
|
getPluginNamesFromConfigs(pluginConfigs) {
|
|
@@ -6751,9 +6870,9 @@
|
|
|
6751
6870
|
});
|
|
6752
6871
|
}
|
|
6753
6872
|
|
|
6754
|
-
expectPlugin(pluginConfig,
|
|
6873
|
+
expectPlugin(pluginConfig, loc) {
|
|
6755
6874
|
if (!this.hasPlugin(pluginConfig)) {
|
|
6756
|
-
throw this.raiseWithData(
|
|
6875
|
+
throw this.raiseWithData(loc != null ? loc : this.state.startLoc, {
|
|
6757
6876
|
missingPlugin: this.getPluginNamesFromConfigs([pluginConfig])
|
|
6758
6877
|
}, "This experimental syntax requires enabling the parser plugin: ".concat(JSON.stringify(pluginConfig), "."));
|
|
6759
6878
|
}
|
|
@@ -6761,9 +6880,9 @@
|
|
|
6761
6880
|
return true;
|
|
6762
6881
|
}
|
|
6763
6882
|
|
|
6764
|
-
expectOnePlugin(pluginConfigs
|
|
6883
|
+
expectOnePlugin(pluginConfigs) {
|
|
6765
6884
|
if (!pluginConfigs.some(c => this.hasPlugin(c))) {
|
|
6766
|
-
throw this.raiseWithData(
|
|
6885
|
+
throw this.raiseWithData(this.state.startLoc, {
|
|
6767
6886
|
missingPlugin: this.getPluginNamesFromConfigs(pluginConfigs)
|
|
6768
6887
|
}, "This experimental syntax requires enabling one of the following parser plugin(s): ".concat(pluginConfigs.map(c => JSON.stringify(c)).join(", "), "."));
|
|
6769
6888
|
}
|
|
@@ -6833,26 +6952,30 @@
|
|
|
6833
6952
|
checkExpressionErrors(refExpressionErrors, andThrow) {
|
|
6834
6953
|
if (!refExpressionErrors) return false;
|
|
6835
6954
|
var {
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6955
|
+
shorthandAssignLoc,
|
|
6956
|
+
doubleProtoLoc,
|
|
6957
|
+
optionalParametersLoc
|
|
6839
6958
|
} = refExpressionErrors;
|
|
6840
|
-
var hasErrors =
|
|
6959
|
+
var hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc;
|
|
6841
6960
|
|
|
6842
6961
|
if (!andThrow) {
|
|
6843
6962
|
return hasErrors;
|
|
6844
|
-
}
|
|
6845
|
-
if (shorthandAssign >= 0) {
|
|
6846
|
-
this.raise(shorthandAssign, ErrorMessages.InvalidCoverInitializedName);
|
|
6847
|
-
}
|
|
6963
|
+
}
|
|
6848
6964
|
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6965
|
+
if (shorthandAssignLoc != null) {
|
|
6966
|
+
this.raise(ErrorMessages.InvalidCoverInitializedName, {
|
|
6967
|
+
at: shorthandAssignLoc
|
|
6968
|
+
});
|
|
6969
|
+
}
|
|
6852
6970
|
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6971
|
+
if (doubleProtoLoc != null) {
|
|
6972
|
+
this.raise(ErrorMessages.DuplicateProto, {
|
|
6973
|
+
at: doubleProtoLoc
|
|
6974
|
+
});
|
|
6975
|
+
}
|
|
6976
|
+
|
|
6977
|
+
if (optionalParametersLoc != null) {
|
|
6978
|
+
this.unexpected(optionalParametersLoc);
|
|
6856
6979
|
}
|
|
6857
6980
|
}
|
|
6858
6981
|
|
|
@@ -6927,9 +7050,9 @@
|
|
|
6927
7050
|
|
|
6928
7051
|
class ExpressionErrors {
|
|
6929
7052
|
constructor() {
|
|
6930
|
-
this.
|
|
6931
|
-
this.
|
|
6932
|
-
this.
|
|
7053
|
+
this.shorthandAssignLoc = null;
|
|
7054
|
+
this.doubleProtoLoc = null;
|
|
7055
|
+
this.optionalParametersLoc = null;
|
|
6933
7056
|
}
|
|
6934
7057
|
|
|
6935
7058
|
}
|
|
@@ -7039,14 +7162,14 @@
|
|
|
7039
7162
|
}
|
|
7040
7163
|
|
|
7041
7164
|
finishNode(node, type) {
|
|
7042
|
-
return this.finishNodeAt(node, type, this.state.
|
|
7165
|
+
return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
|
|
7043
7166
|
}
|
|
7044
7167
|
|
|
7045
|
-
finishNodeAt(node, type,
|
|
7168
|
+
finishNodeAt(node, type, endLoc) {
|
|
7046
7169
|
node.type = type;
|
|
7047
|
-
node.end =
|
|
7048
|
-
node.loc.end =
|
|
7049
|
-
if (this.options.ranges) node.range[1] =
|
|
7170
|
+
node.end = indexes.get(endLoc);
|
|
7171
|
+
node.loc.end = endLoc;
|
|
7172
|
+
if (this.options.ranges) node.range[1] = node.end;
|
|
7050
7173
|
if (this.options.attachComment) this.processComment(node);
|
|
7051
7174
|
return node;
|
|
7052
7175
|
}
|
|
@@ -7058,11 +7181,10 @@
|
|
|
7058
7181
|
}
|
|
7059
7182
|
|
|
7060
7183
|
resetEndLocation(node) {
|
|
7061
|
-
var
|
|
7062
|
-
|
|
7063
|
-
node.end = end;
|
|
7184
|
+
var endLoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEndLoc;
|
|
7185
|
+
node.end = indexes.get(endLoc);
|
|
7064
7186
|
node.loc.end = endLoc;
|
|
7065
|
-
if (this.options.ranges) node.range[1] = end;
|
|
7187
|
+
if (this.options.ranges) node.range[1] = node.end;
|
|
7066
7188
|
}
|
|
7067
7189
|
|
|
7068
7190
|
resetStartLocationFromNode(node, locationNode) {
|
|
@@ -7208,12 +7330,14 @@
|
|
|
7208
7330
|
|
|
7209
7331
|
flowParsePredicate() {
|
|
7210
7332
|
var node = this.startNode();
|
|
7211
|
-
var
|
|
7333
|
+
var moduloLoc = this.state.startLoc;
|
|
7212
7334
|
this.next();
|
|
7213
7335
|
this.expectContextual(103);
|
|
7214
7336
|
|
|
7215
|
-
if (this.state.lastTokStart >
|
|
7216
|
-
this.raise(
|
|
7337
|
+
if (this.state.lastTokStart > indexes.get(moduloLoc) + 1) {
|
|
7338
|
+
this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, {
|
|
7339
|
+
at: moduloLoc
|
|
7340
|
+
});
|
|
7217
7341
|
}
|
|
7218
7342
|
|
|
7219
7343
|
if (this.eat(10)) {
|
|
@@ -7276,7 +7400,7 @@
|
|
|
7276
7400
|
id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
|
|
7277
7401
|
this.resetEndLocation(id);
|
|
7278
7402
|
this.semicolon();
|
|
7279
|
-
this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.start);
|
|
7403
|
+
this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.loc.start);
|
|
7280
7404
|
return this.finishNode(node, "DeclareFunction");
|
|
7281
7405
|
}
|
|
7282
7406
|
|
|
@@ -7292,7 +7416,9 @@
|
|
|
7292
7416
|
return this.flowParseDeclareModuleExports(node);
|
|
7293
7417
|
} else {
|
|
7294
7418
|
if (insideModule) {
|
|
7295
|
-
this.raise(
|
|
7419
|
+
this.raise(FlowErrors.NestedDeclareModule, {
|
|
7420
|
+
at: this.state.lastTokStartLoc
|
|
7421
|
+
});
|
|
7296
7422
|
}
|
|
7297
7423
|
|
|
7298
7424
|
return this.flowParseDeclareModule(node);
|
|
@@ -7313,7 +7439,7 @@
|
|
|
7313
7439
|
flowParseDeclareVariable(node) {
|
|
7314
7440
|
this.next();
|
|
7315
7441
|
node.id = this.flowParseTypeAnnotatableIdentifier(true);
|
|
7316
|
-
this.scope.declareName(node.id.name, BIND_VAR, node.id.start);
|
|
7442
|
+
this.scope.declareName(node.id.name, BIND_VAR, node.id.loc.start);
|
|
7317
7443
|
this.semicolon();
|
|
7318
7444
|
return this.finishNode(node, "DeclareVariable");
|
|
7319
7445
|
}
|
|
@@ -7338,7 +7464,9 @@
|
|
|
7338
7464
|
this.next();
|
|
7339
7465
|
|
|
7340
7466
|
if (!this.isContextual(122) && !this.match(83)) {
|
|
7341
|
-
this.raise(
|
|
7467
|
+
this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, {
|
|
7468
|
+
at: this.state.lastTokStartLoc
|
|
7469
|
+
});
|
|
7342
7470
|
}
|
|
7343
7471
|
|
|
7344
7472
|
this.parseImport(_bodyNode);
|
|
@@ -7358,17 +7486,23 @@
|
|
|
7358
7486
|
body.forEach(bodyElement => {
|
|
7359
7487
|
if (isEsModuleType(bodyElement)) {
|
|
7360
7488
|
if (kind === "CommonJS") {
|
|
7361
|
-
this.raise(
|
|
7489
|
+
this.raise(FlowErrors.AmbiguousDeclareModuleKind, {
|
|
7490
|
+
node: bodyElement
|
|
7491
|
+
});
|
|
7362
7492
|
}
|
|
7363
7493
|
|
|
7364
7494
|
kind = "ES";
|
|
7365
7495
|
} else if (bodyElement.type === "DeclareModuleExports") {
|
|
7366
7496
|
if (hasModuleExport) {
|
|
7367
|
-
this.raise(
|
|
7497
|
+
this.raise(FlowErrors.DuplicateDeclareModuleExports, {
|
|
7498
|
+
node: bodyElement
|
|
7499
|
+
});
|
|
7368
7500
|
}
|
|
7369
7501
|
|
|
7370
7502
|
if (kind === "ES") {
|
|
7371
|
-
this.raise(
|
|
7503
|
+
this.raise(FlowErrors.AmbiguousDeclareModuleKind, {
|
|
7504
|
+
node: bodyElement
|
|
7505
|
+
});
|
|
7372
7506
|
}
|
|
7373
7507
|
|
|
7374
7508
|
kind = "CommonJS";
|
|
@@ -7396,7 +7530,9 @@
|
|
|
7396
7530
|
if (this.match(71) || this.isLet() || (this.isContextual(122) || this.isContextual(121)) && !insideModule) {
|
|
7397
7531
|
var label = this.state.value;
|
|
7398
7532
|
var suggestion = exportSuggestions[label];
|
|
7399
|
-
throw this.raise(
|
|
7533
|
+
throw this.raise(FlowErrors.UnsupportedDeclareExportKind, {
|
|
7534
|
+
at: this.state.startLoc
|
|
7535
|
+
}, label, suggestion);
|
|
7400
7536
|
}
|
|
7401
7537
|
|
|
7402
7538
|
if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(123)) {
|
|
@@ -7451,7 +7587,7 @@
|
|
|
7451
7587
|
flowParseInterfaceish(node) {
|
|
7452
7588
|
var isClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
7453
7589
|
node.id = this.flowParseRestrictedIdentifier(!isClass, true);
|
|
7454
|
-
this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.start);
|
|
7590
|
+
this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.loc.start);
|
|
7455
7591
|
|
|
7456
7592
|
if (this.match(45)) {
|
|
7457
7593
|
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
|
@@ -7514,23 +7650,27 @@
|
|
|
7514
7650
|
|
|
7515
7651
|
checkNotUnderscore(word) {
|
|
7516
7652
|
if (word === "_") {
|
|
7517
|
-
this.raise(
|
|
7653
|
+
this.raise(FlowErrors.UnexpectedReservedUnderscore, {
|
|
7654
|
+
at: this.state.startLoc
|
|
7655
|
+
});
|
|
7518
7656
|
}
|
|
7519
7657
|
}
|
|
7520
7658
|
|
|
7521
7659
|
checkReservedType(word, startLoc, declaration) {
|
|
7522
7660
|
if (!reservedTypes.has(word)) return;
|
|
7523
|
-
this.raise(
|
|
7661
|
+
this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, {
|
|
7662
|
+
at: startLoc
|
|
7663
|
+
}, word);
|
|
7524
7664
|
}
|
|
7525
7665
|
|
|
7526
7666
|
flowParseRestrictedIdentifier(liberal, declaration) {
|
|
7527
|
-
this.checkReservedType(this.state.value, this.state.
|
|
7667
|
+
this.checkReservedType(this.state.value, this.state.startLoc, declaration);
|
|
7528
7668
|
return this.parseIdentifier(liberal);
|
|
7529
7669
|
}
|
|
7530
7670
|
|
|
7531
7671
|
flowParseTypeAlias(node) {
|
|
7532
7672
|
node.id = this.flowParseRestrictedIdentifier(false, true);
|
|
7533
|
-
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
|
|
7673
|
+
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start);
|
|
7534
7674
|
|
|
7535
7675
|
if (this.match(45)) {
|
|
7536
7676
|
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
|
@@ -7546,7 +7686,7 @@
|
|
|
7546
7686
|
flowParseOpaqueType(node, declare) {
|
|
7547
7687
|
this.expectContextual(122);
|
|
7548
7688
|
node.id = this.flowParseRestrictedIdentifier(true, true);
|
|
7549
|
-
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
|
|
7689
|
+
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start);
|
|
7550
7690
|
|
|
7551
7691
|
if (this.match(45)) {
|
|
7552
7692
|
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
|
@@ -7572,7 +7712,7 @@
|
|
|
7572
7712
|
|
|
7573
7713
|
flowParseTypeParameter() {
|
|
7574
7714
|
var requireDefault = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
7575
|
-
var
|
|
7715
|
+
var nodeStartLoc = this.state.startLoc;
|
|
7576
7716
|
var node = this.startNode();
|
|
7577
7717
|
var variance = this.flowParseVariance();
|
|
7578
7718
|
var ident = this.flowParseTypeAnnotatableIdentifier();
|
|
@@ -7585,7 +7725,9 @@
|
|
|
7585
7725
|
node.default = this.flowParseType();
|
|
7586
7726
|
} else {
|
|
7587
7727
|
if (requireDefault) {
|
|
7588
|
-
this.raise(
|
|
7728
|
+
this.raise(FlowErrors.MissingTypeParamDefault, {
|
|
7729
|
+
at: nodeStartLoc
|
|
7730
|
+
});
|
|
7589
7731
|
}
|
|
7590
7732
|
}
|
|
7591
7733
|
|
|
@@ -7777,14 +7919,14 @@
|
|
|
7777
7919
|
return this.finishNode(node, "ObjectTypeCallProperty");
|
|
7778
7920
|
}
|
|
7779
7921
|
|
|
7780
|
-
flowParseObjectType(
|
|
7922
|
+
flowParseObjectType(_ref7) {
|
|
7781
7923
|
var {
|
|
7782
7924
|
allowStatic,
|
|
7783
7925
|
allowExact,
|
|
7784
7926
|
allowSpread,
|
|
7785
7927
|
allowProto,
|
|
7786
7928
|
allowInexact
|
|
7787
|
-
} =
|
|
7929
|
+
} = _ref7;
|
|
7788
7930
|
var oldInType = this.state.inType;
|
|
7789
7931
|
this.state.inType = true;
|
|
7790
7932
|
var nodeStart = this.startNode();
|
|
@@ -7810,8 +7952,8 @@
|
|
|
7810
7952
|
|
|
7811
7953
|
while (!this.match(endDelim)) {
|
|
7812
7954
|
var isStatic = false;
|
|
7813
|
-
var
|
|
7814
|
-
var
|
|
7955
|
+
var protoStartLoc = null;
|
|
7956
|
+
var inexactStartLoc = null;
|
|
7815
7957
|
var node = this.startNode();
|
|
7816
7958
|
|
|
7817
7959
|
if (allowProto && this.isContextual(111)) {
|
|
@@ -7819,7 +7961,7 @@
|
|
|
7819
7961
|
|
|
7820
7962
|
if (lookahead.type !== 14 && lookahead.type !== 17) {
|
|
7821
7963
|
this.next();
|
|
7822
|
-
|
|
7964
|
+
protoStartLoc = this.state.startLoc;
|
|
7823
7965
|
allowStatic = false;
|
|
7824
7966
|
}
|
|
7825
7967
|
}
|
|
@@ -7836,13 +7978,13 @@
|
|
|
7836
7978
|
var variance = this.flowParseVariance();
|
|
7837
7979
|
|
|
7838
7980
|
if (this.eat(0)) {
|
|
7839
|
-
if (
|
|
7840
|
-
this.unexpected(
|
|
7981
|
+
if (protoStartLoc != null) {
|
|
7982
|
+
this.unexpected(protoStartLoc);
|
|
7841
7983
|
}
|
|
7842
7984
|
|
|
7843
7985
|
if (this.eat(0)) {
|
|
7844
7986
|
if (variance) {
|
|
7845
|
-
this.unexpected(variance.start);
|
|
7987
|
+
this.unexpected(variance.loc.start);
|
|
7846
7988
|
}
|
|
7847
7989
|
|
|
7848
7990
|
nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
|
|
@@ -7850,12 +7992,12 @@
|
|
|
7850
7992
|
nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
|
|
7851
7993
|
}
|
|
7852
7994
|
} else if (this.match(10) || this.match(45)) {
|
|
7853
|
-
if (
|
|
7854
|
-
this.unexpected(
|
|
7995
|
+
if (protoStartLoc != null) {
|
|
7996
|
+
this.unexpected(protoStartLoc);
|
|
7855
7997
|
}
|
|
7856
7998
|
|
|
7857
7999
|
if (variance) {
|
|
7858
|
-
this.unexpected(variance.start);
|
|
8000
|
+
this.unexpected(variance.loc.start);
|
|
7859
8001
|
}
|
|
7860
8002
|
|
|
7861
8003
|
nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
|
|
@@ -7871,11 +8013,11 @@
|
|
|
7871
8013
|
}
|
|
7872
8014
|
}
|
|
7873
8015
|
|
|
7874
|
-
var propOrInexact = this.flowParseObjectTypeProperty(node, isStatic,
|
|
8016
|
+
var propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
|
|
7875
8017
|
|
|
7876
8018
|
if (propOrInexact === null) {
|
|
7877
8019
|
inexact = true;
|
|
7878
|
-
|
|
8020
|
+
inexactStartLoc = this.state.lastTokStartLoc;
|
|
7879
8021
|
} else {
|
|
7880
8022
|
nodeStart.properties.push(propOrInexact);
|
|
7881
8023
|
}
|
|
@@ -7883,8 +8025,10 @@
|
|
|
7883
8025
|
|
|
7884
8026
|
this.flowObjectTypeSemicolon();
|
|
7885
8027
|
|
|
7886
|
-
if (
|
|
7887
|
-
this.raise(
|
|
8028
|
+
if (inexactStartLoc && !this.match(8) && !this.match(9)) {
|
|
8029
|
+
this.raise(FlowErrors.UnexpectedExplicitInexactInObject, {
|
|
8030
|
+
at: inexactStartLoc
|
|
8031
|
+
});
|
|
7888
8032
|
}
|
|
7889
8033
|
}
|
|
7890
8034
|
|
|
@@ -7899,34 +8043,44 @@
|
|
|
7899
8043
|
return out;
|
|
7900
8044
|
}
|
|
7901
8045
|
|
|
7902
|
-
flowParseObjectTypeProperty(node, isStatic,
|
|
8046
|
+
flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
|
|
7903
8047
|
if (this.eat(21)) {
|
|
7904
8048
|
var isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
|
|
7905
8049
|
|
|
7906
8050
|
if (isInexactToken) {
|
|
7907
8051
|
if (!allowSpread) {
|
|
7908
|
-
this.raise(
|
|
8052
|
+
this.raise(FlowErrors.InexactInsideNonObject, {
|
|
8053
|
+
at: this.state.lastTokStartLoc
|
|
8054
|
+
});
|
|
7909
8055
|
} else if (!allowInexact) {
|
|
7910
|
-
this.raise(
|
|
8056
|
+
this.raise(FlowErrors.InexactInsideExact, {
|
|
8057
|
+
at: this.state.lastTokStartLoc
|
|
8058
|
+
});
|
|
7911
8059
|
}
|
|
7912
8060
|
|
|
7913
8061
|
if (variance) {
|
|
7914
|
-
this.raise(
|
|
8062
|
+
this.raise(FlowErrors.InexactVariance, {
|
|
8063
|
+
node: variance
|
|
8064
|
+
});
|
|
7915
8065
|
}
|
|
7916
8066
|
|
|
7917
8067
|
return null;
|
|
7918
8068
|
}
|
|
7919
8069
|
|
|
7920
8070
|
if (!allowSpread) {
|
|
7921
|
-
this.raise(
|
|
8071
|
+
this.raise(FlowErrors.UnexpectedSpreadType, {
|
|
8072
|
+
at: this.state.lastTokStartLoc
|
|
8073
|
+
});
|
|
7922
8074
|
}
|
|
7923
8075
|
|
|
7924
|
-
if (
|
|
7925
|
-
this.unexpected(
|
|
8076
|
+
if (protoStartLoc != null) {
|
|
8077
|
+
this.unexpected(protoStartLoc);
|
|
7926
8078
|
}
|
|
7927
8079
|
|
|
7928
8080
|
if (variance) {
|
|
7929
|
-
this.raise(
|
|
8081
|
+
this.raise(FlowErrors.SpreadVariance, {
|
|
8082
|
+
node: variance
|
|
8083
|
+
});
|
|
7930
8084
|
}
|
|
7931
8085
|
|
|
7932
8086
|
node.argument = this.flowParseType();
|
|
@@ -7934,19 +8088,19 @@
|
|
|
7934
8088
|
} else {
|
|
7935
8089
|
node.key = this.flowParseObjectPropertyKey();
|
|
7936
8090
|
node.static = isStatic;
|
|
7937
|
-
node.proto =
|
|
8091
|
+
node.proto = protoStartLoc != null;
|
|
7938
8092
|
node.kind = kind;
|
|
7939
8093
|
var optional = false;
|
|
7940
8094
|
|
|
7941
8095
|
if (this.match(45) || this.match(10)) {
|
|
7942
8096
|
node.method = true;
|
|
7943
8097
|
|
|
7944
|
-
if (
|
|
7945
|
-
this.unexpected(
|
|
8098
|
+
if (protoStartLoc != null) {
|
|
8099
|
+
this.unexpected(protoStartLoc);
|
|
7946
8100
|
}
|
|
7947
8101
|
|
|
7948
8102
|
if (variance) {
|
|
7949
|
-
this.unexpected(variance.start);
|
|
8103
|
+
this.unexpected(variance.loc.start);
|
|
7950
8104
|
}
|
|
7951
8105
|
|
|
7952
8106
|
node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
|
|
@@ -7956,7 +8110,9 @@
|
|
|
7956
8110
|
}
|
|
7957
8111
|
|
|
7958
8112
|
if (!allowSpread && node.key.name === "constructor" && node.value.this) {
|
|
7959
|
-
this.raise(
|
|
8113
|
+
this.raise(FlowErrors.ThisParamBannedInConstructor, {
|
|
8114
|
+
node: node.value.this
|
|
8115
|
+
});
|
|
7960
8116
|
}
|
|
7961
8117
|
} else {
|
|
7962
8118
|
if (kind !== "init") this.unexpected();
|
|
@@ -7977,23 +8133,24 @@
|
|
|
7977
8133
|
|
|
7978
8134
|
flowCheckGetterSetterParams(property) {
|
|
7979
8135
|
var paramCount = property.kind === "get" ? 0 : 1;
|
|
7980
|
-
var start = property.start;
|
|
7981
8136
|
var length = property.value.params.length + (property.value.rest ? 1 : 0);
|
|
7982
8137
|
|
|
7983
8138
|
if (property.value.this) {
|
|
7984
|
-
this.raise(property.
|
|
8139
|
+
this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, {
|
|
8140
|
+
node: property.value.this
|
|
8141
|
+
});
|
|
7985
8142
|
}
|
|
7986
8143
|
|
|
7987
8144
|
if (length !== paramCount) {
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
}
|
|
7991
|
-
this.raise(start, ErrorMessages.BadSetterArity);
|
|
7992
|
-
}
|
|
8145
|
+
this.raise(property.kind === "get" ? ErrorMessages.BadGetterArity : ErrorMessages.BadSetterArity, {
|
|
8146
|
+
node: property
|
|
8147
|
+
});
|
|
7993
8148
|
}
|
|
7994
8149
|
|
|
7995
8150
|
if (property.kind === "set" && property.value.rest) {
|
|
7996
|
-
this.raise(
|
|
8151
|
+
this.raise(ErrorMessages.BadSetterRestParameter, {
|
|
8152
|
+
node: property
|
|
8153
|
+
});
|
|
7997
8154
|
}
|
|
7998
8155
|
}
|
|
7999
8156
|
|
|
@@ -8062,7 +8219,9 @@
|
|
|
8062
8219
|
|
|
8063
8220
|
if (lh.type === 14 || lh.type === 17) {
|
|
8064
8221
|
if (isThis && !first) {
|
|
8065
|
-
this.raise(
|
|
8222
|
+
this.raise(FlowErrors.ThisParamMustBeFirst, {
|
|
8223
|
+
node
|
|
8224
|
+
});
|
|
8066
8225
|
}
|
|
8067
8226
|
|
|
8068
8227
|
name = this.parseIdentifier(isThis);
|
|
@@ -8071,7 +8230,9 @@
|
|
|
8071
8230
|
optional = true;
|
|
8072
8231
|
|
|
8073
8232
|
if (isThis) {
|
|
8074
|
-
this.raise(
|
|
8233
|
+
this.raise(FlowErrors.ThisParamMayNotBeOptional, {
|
|
8234
|
+
node
|
|
8235
|
+
});
|
|
8075
8236
|
}
|
|
8076
8237
|
}
|
|
8077
8238
|
|
|
@@ -8264,7 +8425,9 @@
|
|
|
8264
8425
|
return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
|
|
8265
8426
|
}
|
|
8266
8427
|
|
|
8267
|
-
throw this.raise(
|
|
8428
|
+
throw this.raise(FlowErrors.UnexpectedSubtractionOperand, {
|
|
8429
|
+
at: this.state.startLoc
|
|
8430
|
+
});
|
|
8268
8431
|
}
|
|
8269
8432
|
|
|
8270
8433
|
throw this.unexpected();
|
|
@@ -8436,7 +8599,7 @@
|
|
|
8436
8599
|
|
|
8437
8600
|
typeCastToParameter(node) {
|
|
8438
8601
|
node.expression.typeAnnotation = node.typeAnnotation;
|
|
8439
|
-
this.resetEndLocation(node.expression, node.typeAnnotation.
|
|
8602
|
+
this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
|
|
8440
8603
|
return node.expression;
|
|
8441
8604
|
}
|
|
8442
8605
|
|
|
@@ -8601,7 +8764,9 @@
|
|
|
8601
8764
|
}
|
|
8602
8765
|
|
|
8603
8766
|
if (failed && valid.length > 1) {
|
|
8604
|
-
this.raise(
|
|
8767
|
+
this.raise(FlowErrors.AmbiguousConditionalArrow, {
|
|
8768
|
+
at: state.startLoc
|
|
8769
|
+
});
|
|
8605
8770
|
}
|
|
8606
8771
|
|
|
8607
8772
|
if (failed && valid.length === 1) {
|
|
@@ -8667,7 +8832,7 @@
|
|
|
8667
8832
|
finishArrowValidation(node) {
|
|
8668
8833
|
var _node$extra;
|
|
8669
8834
|
|
|
8670
|
-
this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.
|
|
8835
|
+
this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
|
|
8671
8836
|
this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
|
|
8672
8837
|
super.checkParams(node, false, true);
|
|
8673
8838
|
this.scope.exit();
|
|
@@ -8776,11 +8941,13 @@
|
|
|
8776
8941
|
}
|
|
8777
8942
|
|
|
8778
8943
|
maybeParseExportNamespaceSpecifier(node) {
|
|
8779
|
-
var
|
|
8944
|
+
var {
|
|
8945
|
+
startLoc
|
|
8946
|
+
} = this.state;
|
|
8780
8947
|
var hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
|
|
8781
8948
|
|
|
8782
8949
|
if (hasNamespace && node.exportKind === "type") {
|
|
8783
|
-
this.unexpected(
|
|
8950
|
+
this.unexpected(startLoc);
|
|
8784
8951
|
}
|
|
8785
8952
|
|
|
8786
8953
|
return hasNamespace;
|
|
@@ -8795,7 +8962,9 @@
|
|
|
8795
8962
|
}
|
|
8796
8963
|
|
|
8797
8964
|
parseClassMember(classBody, member, state) {
|
|
8798
|
-
var
|
|
8965
|
+
var {
|
|
8966
|
+
startLoc
|
|
8967
|
+
} = this.state;
|
|
8799
8968
|
|
|
8800
8969
|
if (this.isContextual(117)) {
|
|
8801
8970
|
if (this.parseClassMemberFromModifier(classBody, member)) {
|
|
@@ -8809,9 +8978,13 @@
|
|
|
8809
8978
|
|
|
8810
8979
|
if (member.declare) {
|
|
8811
8980
|
if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
|
|
8812
|
-
this.raise(
|
|
8981
|
+
this.raise(FlowErrors.DeclareClassElement, {
|
|
8982
|
+
at: startLoc
|
|
8983
|
+
});
|
|
8813
8984
|
} else if (member.value) {
|
|
8814
|
-
this.raise(
|
|
8985
|
+
this.raise(FlowErrors.DeclareClassFieldInitializer, {
|
|
8986
|
+
node: member.value
|
|
8987
|
+
});
|
|
8815
8988
|
}
|
|
8816
8989
|
}
|
|
8817
8990
|
}
|
|
@@ -8825,7 +8998,9 @@
|
|
|
8825
8998
|
var fullWord = "@@" + word;
|
|
8826
8999
|
|
|
8827
9000
|
if (!this.isIterator(word) || !this.state.inType) {
|
|
8828
|
-
this.raise(
|
|
9001
|
+
this.raise(ErrorMessages.InvalidIdentifier, {
|
|
9002
|
+
at: this.state.curPosition()
|
|
9003
|
+
}, fullWord);
|
|
8829
9004
|
}
|
|
8830
9005
|
|
|
8831
9006
|
this.finishToken(124, fullWord);
|
|
@@ -8870,7 +9045,7 @@
|
|
|
8870
9045
|
}
|
|
8871
9046
|
}
|
|
8872
9047
|
|
|
8873
|
-
toAssignableList(exprList,
|
|
9048
|
+
toAssignableList(exprList, trailingCommaLoc, isLHS) {
|
|
8874
9049
|
for (var i = 0; i < exprList.length; i++) {
|
|
8875
9050
|
var expr = exprList[i];
|
|
8876
9051
|
|
|
@@ -8879,7 +9054,7 @@
|
|
|
8879
9054
|
}
|
|
8880
9055
|
}
|
|
8881
9056
|
|
|
8882
|
-
return super.toAssignableList(exprList,
|
|
9057
|
+
return super.toAssignableList(exprList, trailingCommaLoc, isLHS);
|
|
8883
9058
|
}
|
|
8884
9059
|
|
|
8885
9060
|
toReferencedList(exprList, isParenthesizedExpr) {
|
|
@@ -8889,7 +9064,9 @@
|
|
|
8889
9064
|
var expr = exprList[i];
|
|
8890
9065
|
|
|
8891
9066
|
if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
|
|
8892
|
-
this.raise(
|
|
9067
|
+
this.raise(FlowErrors.TypeCastInPattern, {
|
|
9068
|
+
node: expr.typeAnnotation
|
|
9069
|
+
});
|
|
8893
9070
|
}
|
|
8894
9071
|
}
|
|
8895
9072
|
|
|
@@ -8946,7 +9123,7 @@
|
|
|
8946
9123
|
|
|
8947
9124
|
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
|
8948
9125
|
if (method.variance) {
|
|
8949
|
-
this.unexpected(method.variance.start);
|
|
9126
|
+
this.unexpected(method.variance.loc.start);
|
|
8950
9127
|
}
|
|
8951
9128
|
|
|
8952
9129
|
delete method.variance;
|
|
@@ -8961,20 +9138,24 @@
|
|
|
8961
9138
|
var params = method.params;
|
|
8962
9139
|
|
|
8963
9140
|
if (params.length > 0 && this.isThisParam(params[0])) {
|
|
8964
|
-
this.raise(
|
|
9141
|
+
this.raise(FlowErrors.ThisParamBannedInConstructor, {
|
|
9142
|
+
node: method
|
|
9143
|
+
});
|
|
8965
9144
|
}
|
|
8966
9145
|
} else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
|
|
8967
9146
|
var _params2 = method.value.params;
|
|
8968
9147
|
|
|
8969
9148
|
if (_params2.length > 0 && this.isThisParam(_params2[0])) {
|
|
8970
|
-
this.raise(
|
|
9149
|
+
this.raise(FlowErrors.ThisParamBannedInConstructor, {
|
|
9150
|
+
node: method
|
|
9151
|
+
});
|
|
8971
9152
|
}
|
|
8972
9153
|
}
|
|
8973
9154
|
}
|
|
8974
9155
|
|
|
8975
9156
|
pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
|
|
8976
9157
|
if (method.variance) {
|
|
8977
|
-
this.unexpected(method.variance.start);
|
|
9158
|
+
this.unexpected(method.variance.loc.start);
|
|
8978
9159
|
}
|
|
8979
9160
|
|
|
8980
9161
|
delete method.variance;
|
|
@@ -9021,9 +9202,13 @@
|
|
|
9021
9202
|
var param = params[0];
|
|
9022
9203
|
|
|
9023
9204
|
if (this.isThisParam(param) && method.kind === "get") {
|
|
9024
|
-
this.raise(
|
|
9205
|
+
this.raise(FlowErrors.GetterMayNotHaveThisParam, {
|
|
9206
|
+
node: param
|
|
9207
|
+
});
|
|
9025
9208
|
} else if (this.isThisParam(param)) {
|
|
9026
|
-
this.raise(
|
|
9209
|
+
this.raise(FlowErrors.SetterMayNotHaveThisParam, {
|
|
9210
|
+
node: param
|
|
9211
|
+
});
|
|
9027
9212
|
}
|
|
9028
9213
|
}
|
|
9029
9214
|
}
|
|
@@ -9034,7 +9219,7 @@
|
|
|
9034
9219
|
|
|
9035
9220
|
parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
|
|
9036
9221
|
if (prop.variance) {
|
|
9037
|
-
this.unexpected(prop.variance.start);
|
|
9222
|
+
this.unexpected(prop.variance.loc.start);
|
|
9038
9223
|
}
|
|
9039
9224
|
|
|
9040
9225
|
delete prop.variance;
|
|
@@ -9055,11 +9240,15 @@
|
|
|
9055
9240
|
parseAssignableListItemTypes(param) {
|
|
9056
9241
|
if (this.eat(17)) {
|
|
9057
9242
|
if (param.type !== "Identifier") {
|
|
9058
|
-
this.raise(
|
|
9243
|
+
this.raise(FlowErrors.PatternIsOptional, {
|
|
9244
|
+
node: param
|
|
9245
|
+
});
|
|
9059
9246
|
}
|
|
9060
9247
|
|
|
9061
9248
|
if (this.isThisParam(param)) {
|
|
9062
|
-
this.raise(
|
|
9249
|
+
this.raise(FlowErrors.ThisParamMayNotBeOptional, {
|
|
9250
|
+
node: param
|
|
9251
|
+
});
|
|
9063
9252
|
}
|
|
9064
9253
|
|
|
9065
9254
|
param.optional = true;
|
|
@@ -9068,11 +9257,15 @@
|
|
|
9068
9257
|
if (this.match(14)) {
|
|
9069
9258
|
param.typeAnnotation = this.flowParseTypeAnnotation();
|
|
9070
9259
|
} else if (this.isThisParam(param)) {
|
|
9071
|
-
this.raise(
|
|
9260
|
+
this.raise(FlowErrors.ThisParamAnnotationRequired, {
|
|
9261
|
+
node: param
|
|
9262
|
+
});
|
|
9072
9263
|
}
|
|
9073
9264
|
|
|
9074
9265
|
if (this.match(29) && this.isThisParam(param)) {
|
|
9075
|
-
this.raise(
|
|
9266
|
+
this.raise(FlowErrors.ThisParamNoDefault, {
|
|
9267
|
+
node: param
|
|
9268
|
+
});
|
|
9076
9269
|
}
|
|
9077
9270
|
|
|
9078
9271
|
this.resetEndLocation(param);
|
|
@@ -9083,7 +9276,9 @@
|
|
|
9083
9276
|
var node = super.parseMaybeDefault(startPos, startLoc, left);
|
|
9084
9277
|
|
|
9085
9278
|
if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
|
|
9086
|
-
this.raise(
|
|
9279
|
+
this.raise(FlowErrors.TypeBeforeInitializer, {
|
|
9280
|
+
node: node.typeAnnotation
|
|
9281
|
+
});
|
|
9087
9282
|
}
|
|
9088
9283
|
|
|
9089
9284
|
return node;
|
|
@@ -9120,7 +9315,7 @@
|
|
|
9120
9315
|
} = lh;
|
|
9121
9316
|
|
|
9122
9317
|
if (kind === "type" && type === 51) {
|
|
9123
|
-
this.unexpected(lh.
|
|
9318
|
+
this.unexpected(null, lh.type);
|
|
9124
9319
|
}
|
|
9125
9320
|
|
|
9126
9321
|
if (isMaybeDefaultImport(type) || type === 5 || type === 51) {
|
|
@@ -9164,7 +9359,9 @@
|
|
|
9164
9359
|
specifier.importKind = specifierTypeKind;
|
|
9165
9360
|
} else {
|
|
9166
9361
|
if (importedIsString) {
|
|
9167
|
-
throw this.raise(
|
|
9362
|
+
throw this.raise(ErrorMessages.ImportBindingIsString, {
|
|
9363
|
+
node: specifier
|
|
9364
|
+
}, firstIdent.value);
|
|
9168
9365
|
}
|
|
9169
9366
|
|
|
9170
9367
|
specifier.imported = firstIdent;
|
|
@@ -9182,15 +9379,17 @@
|
|
|
9182
9379
|
var specifierIsTypeImport = hasTypeImportKind(specifier);
|
|
9183
9380
|
|
|
9184
9381
|
if (isInTypeOnlyImport && specifierIsTypeImport) {
|
|
9185
|
-
this.raise(
|
|
9382
|
+
this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, {
|
|
9383
|
+
node: specifier
|
|
9384
|
+
});
|
|
9186
9385
|
}
|
|
9187
9386
|
|
|
9188
9387
|
if (isInTypeOnlyImport || specifierIsTypeImport) {
|
|
9189
|
-
this.checkReservedType(specifier.local.name, specifier.local.start, true);
|
|
9388
|
+
this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
|
|
9190
9389
|
}
|
|
9191
9390
|
|
|
9192
9391
|
if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
|
|
9193
|
-
this.checkReservedWord(specifier.local.name, specifier.start, true, true);
|
|
9392
|
+
this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
|
|
9194
9393
|
}
|
|
9195
9394
|
|
|
9196
9395
|
this.checkLVal(specifier.local, "import specifier", BIND_LEXICAL);
|
|
@@ -9287,7 +9486,9 @@
|
|
|
9287
9486
|
if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
|
|
9288
9487
|
if (!arrow.error && !arrow.aborted) {
|
|
9289
9488
|
if (arrow.node.async) {
|
|
9290
|
-
this.raise(
|
|
9489
|
+
this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, {
|
|
9490
|
+
node: typeParameters
|
|
9491
|
+
});
|
|
9291
9492
|
}
|
|
9292
9493
|
|
|
9293
9494
|
return arrow.node;
|
|
@@ -9308,7 +9509,9 @@
|
|
|
9308
9509
|
|
|
9309
9510
|
if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
|
|
9310
9511
|
if (arrow.thrown) throw arrow.error;
|
|
9311
|
-
throw this.raise(
|
|
9512
|
+
throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, {
|
|
9513
|
+
node: typeParameters
|
|
9514
|
+
});
|
|
9312
9515
|
}
|
|
9313
9516
|
|
|
9314
9517
|
return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
|
|
@@ -9353,7 +9556,9 @@
|
|
|
9353
9556
|
|
|
9354
9557
|
for (var i = 0; i < node.params.length; i++) {
|
|
9355
9558
|
if (this.isThisParam(node.params[i]) && i > 0) {
|
|
9356
|
-
this.raise(
|
|
9559
|
+
this.raise(FlowErrors.ThisParamMustBeFirst, {
|
|
9560
|
+
node: node.params[i]
|
|
9561
|
+
});
|
|
9357
9562
|
}
|
|
9358
9563
|
}
|
|
9359
9564
|
|
|
@@ -9478,7 +9683,9 @@
|
|
|
9478
9683
|
var fileNode = super.parseTopLevel(file, program);
|
|
9479
9684
|
|
|
9480
9685
|
if (this.state.hasFlowComment) {
|
|
9481
|
-
this.raise(
|
|
9686
|
+
this.raise(FlowErrors.UnterminatedFlowComment, {
|
|
9687
|
+
at: this.state.curPosition()
|
|
9688
|
+
});
|
|
9482
9689
|
}
|
|
9483
9690
|
|
|
9484
9691
|
return fileNode;
|
|
@@ -9487,7 +9694,9 @@
|
|
|
9487
9694
|
skipBlockComment() {
|
|
9488
9695
|
if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
|
|
9489
9696
|
if (this.state.hasFlowComment) {
|
|
9490
|
-
this.
|
|
9697
|
+
throw this.raise(FlowErrors.NestedFlowComment, {
|
|
9698
|
+
at: this.state.startLoc
|
|
9699
|
+
});
|
|
9491
9700
|
}
|
|
9492
9701
|
|
|
9493
9702
|
this.hasFlowCommentCompletion();
|
|
@@ -9497,13 +9706,15 @@
|
|
|
9497
9706
|
}
|
|
9498
9707
|
|
|
9499
9708
|
if (this.state.hasFlowComment) {
|
|
9500
|
-
var end = this.input.indexOf("*-/", this.state.pos
|
|
9709
|
+
var end = this.input.indexOf("*-/", this.state.pos + 2);
|
|
9501
9710
|
|
|
9502
9711
|
if (end === -1) {
|
|
9503
|
-
throw this.raise(
|
|
9712
|
+
throw this.raise(ErrorMessages.UnterminatedComment, {
|
|
9713
|
+
at: this.state.curPosition()
|
|
9714
|
+
});
|
|
9504
9715
|
}
|
|
9505
9716
|
|
|
9506
|
-
this.state.pos = end + 3;
|
|
9717
|
+
this.state.pos = end + 2 + 3;
|
|
9507
9718
|
return;
|
|
9508
9719
|
}
|
|
9509
9720
|
|
|
@@ -9542,93 +9753,64 @@
|
|
|
9542
9753
|
var end = this.input.indexOf("*/", this.state.pos);
|
|
9543
9754
|
|
|
9544
9755
|
if (end === -1) {
|
|
9545
|
-
throw this.raise(
|
|
9756
|
+
throw this.raise(ErrorMessages.UnterminatedComment, {
|
|
9757
|
+
at: this.state.curPosition()
|
|
9758
|
+
});
|
|
9546
9759
|
}
|
|
9547
9760
|
}
|
|
9548
9761
|
|
|
9549
|
-
flowEnumErrorBooleanMemberNotInitialized(
|
|
9550
|
-
var {
|
|
9551
|
-
enumName,
|
|
9552
|
-
memberName
|
|
9553
|
-
} = _ref6;
|
|
9554
|
-
this.raise(pos, FlowErrors.EnumBooleanMemberNotInitialized, memberName, enumName);
|
|
9555
|
-
}
|
|
9556
|
-
|
|
9557
|
-
flowEnumErrorInvalidMemberName(pos, _ref7) {
|
|
9558
|
-
var {
|
|
9559
|
-
enumName,
|
|
9560
|
-
memberName
|
|
9561
|
-
} = _ref7;
|
|
9562
|
-
var suggestion = memberName[0].toUpperCase() + memberName.slice(1);
|
|
9563
|
-
this.raise(pos, FlowErrors.EnumInvalidMemberName, memberName, suggestion, enumName);
|
|
9564
|
-
}
|
|
9565
|
-
|
|
9566
|
-
flowEnumErrorDuplicateMemberName(pos, _ref8) {
|
|
9762
|
+
flowEnumErrorBooleanMemberNotInitialized(loc, _ref8) {
|
|
9567
9763
|
var {
|
|
9568
9764
|
enumName,
|
|
9569
9765
|
memberName
|
|
9570
9766
|
} = _ref8;
|
|
9571
|
-
this.raise(
|
|
9767
|
+
this.raise(FlowErrors.EnumBooleanMemberNotInitialized, {
|
|
9768
|
+
at: loc
|
|
9769
|
+
}, memberName, enumName);
|
|
9572
9770
|
}
|
|
9573
9771
|
|
|
9574
|
-
|
|
9575
|
-
var {
|
|
9576
|
-
enumName
|
|
9577
|
-
} = _ref9;
|
|
9578
|
-
this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName);
|
|
9579
|
-
}
|
|
9580
|
-
|
|
9581
|
-
flowEnumErrorInvalidExplicitType(pos, _ref10) {
|
|
9772
|
+
flowEnumErrorInvalidExplicitType(loc, _ref9) {
|
|
9582
9773
|
var {
|
|
9583
9774
|
enumName,
|
|
9584
9775
|
suppliedType
|
|
9585
|
-
} =
|
|
9586
|
-
return this.raise(
|
|
9776
|
+
} = _ref9;
|
|
9777
|
+
return this.raise(suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, {
|
|
9778
|
+
at: loc
|
|
9779
|
+
}, enumName, suppliedType);
|
|
9587
9780
|
}
|
|
9588
9781
|
|
|
9589
|
-
flowEnumErrorInvalidMemberInitializer(
|
|
9782
|
+
flowEnumErrorInvalidMemberInitializer(loc, _ref10) {
|
|
9590
9783
|
var {
|
|
9591
9784
|
enumName,
|
|
9592
9785
|
explicitType,
|
|
9593
9786
|
memberName
|
|
9594
|
-
} =
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
case "boolean":
|
|
9599
|
-
case "number":
|
|
9600
|
-
case "string":
|
|
9601
|
-
message = FlowErrors.EnumInvalidMemberInitializerPrimaryType;
|
|
9602
|
-
break;
|
|
9603
|
-
|
|
9604
|
-
case "symbol":
|
|
9605
|
-
message = FlowErrors.EnumInvalidMemberInitializerSymbolType;
|
|
9606
|
-
break;
|
|
9607
|
-
|
|
9608
|
-
default:
|
|
9609
|
-
message = FlowErrors.EnumInvalidMemberInitializerUnknownType;
|
|
9610
|
-
}
|
|
9611
|
-
|
|
9612
|
-
return this.raise(pos, message, enumName, memberName, explicitType);
|
|
9787
|
+
} = _ref10;
|
|
9788
|
+
return this.raise(explicitType === "boolean" || explicitType === "number" || explicitType === "string" ? FlowErrors.EnumInvalidMemberInitializerPrimaryType : explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerUnknownType, {
|
|
9789
|
+
at: loc
|
|
9790
|
+
}, enumName, memberName, explicitType);
|
|
9613
9791
|
}
|
|
9614
9792
|
|
|
9615
|
-
flowEnumErrorNumberMemberNotInitialized(
|
|
9793
|
+
flowEnumErrorNumberMemberNotInitialized(loc, _ref11) {
|
|
9616
9794
|
var {
|
|
9617
9795
|
enumName,
|
|
9618
9796
|
memberName
|
|
9619
|
-
} =
|
|
9620
|
-
this.raise(
|
|
9797
|
+
} = _ref11;
|
|
9798
|
+
this.raise(FlowErrors.EnumNumberMemberNotInitialized, {
|
|
9799
|
+
at: loc
|
|
9800
|
+
}, enumName, memberName);
|
|
9621
9801
|
}
|
|
9622
9802
|
|
|
9623
|
-
flowEnumErrorStringMemberInconsistentlyInitailized(
|
|
9803
|
+
flowEnumErrorStringMemberInconsistentlyInitailized(node, _ref12) {
|
|
9624
9804
|
var {
|
|
9625
9805
|
enumName
|
|
9626
|
-
} =
|
|
9627
|
-
this.raise(
|
|
9806
|
+
} = _ref12;
|
|
9807
|
+
this.raise(FlowErrors.EnumStringMemberInconsistentlyInitailized, {
|
|
9808
|
+
node
|
|
9809
|
+
}, enumName);
|
|
9628
9810
|
}
|
|
9629
9811
|
|
|
9630
9812
|
flowEnumMemberInit() {
|
|
9631
|
-
var
|
|
9813
|
+
var startLoc = this.state.startLoc;
|
|
9632
9814
|
|
|
9633
9815
|
var endOfInit = () => this.match(12) || this.match(8);
|
|
9634
9816
|
|
|
@@ -9640,14 +9822,14 @@
|
|
|
9640
9822
|
if (endOfInit()) {
|
|
9641
9823
|
return {
|
|
9642
9824
|
type: "number",
|
|
9643
|
-
|
|
9825
|
+
loc: literal.loc.start,
|
|
9644
9826
|
value: literal
|
|
9645
9827
|
};
|
|
9646
9828
|
}
|
|
9647
9829
|
|
|
9648
9830
|
return {
|
|
9649
9831
|
type: "invalid",
|
|
9650
|
-
|
|
9832
|
+
loc: startLoc
|
|
9651
9833
|
};
|
|
9652
9834
|
}
|
|
9653
9835
|
|
|
@@ -9658,14 +9840,14 @@
|
|
|
9658
9840
|
if (endOfInit()) {
|
|
9659
9841
|
return {
|
|
9660
9842
|
type: "string",
|
|
9661
|
-
|
|
9843
|
+
loc: _literal.loc.start,
|
|
9662
9844
|
value: _literal
|
|
9663
9845
|
};
|
|
9664
9846
|
}
|
|
9665
9847
|
|
|
9666
9848
|
return {
|
|
9667
9849
|
type: "invalid",
|
|
9668
|
-
|
|
9850
|
+
loc: startLoc
|
|
9669
9851
|
};
|
|
9670
9852
|
}
|
|
9671
9853
|
|
|
@@ -9677,31 +9859,31 @@
|
|
|
9677
9859
|
if (endOfInit()) {
|
|
9678
9860
|
return {
|
|
9679
9861
|
type: "boolean",
|
|
9680
|
-
|
|
9862
|
+
loc: _literal2.loc.start,
|
|
9681
9863
|
value: _literal2
|
|
9682
9864
|
};
|
|
9683
9865
|
}
|
|
9684
9866
|
|
|
9685
9867
|
return {
|
|
9686
9868
|
type: "invalid",
|
|
9687
|
-
|
|
9869
|
+
loc: startLoc
|
|
9688
9870
|
};
|
|
9689
9871
|
}
|
|
9690
9872
|
|
|
9691
9873
|
default:
|
|
9692
9874
|
return {
|
|
9693
9875
|
type: "invalid",
|
|
9694
|
-
|
|
9876
|
+
loc: startLoc
|
|
9695
9877
|
};
|
|
9696
9878
|
}
|
|
9697
9879
|
}
|
|
9698
9880
|
|
|
9699
9881
|
flowEnumMemberRaw() {
|
|
9700
|
-
var
|
|
9882
|
+
var loc = this.state.startLoc;
|
|
9701
9883
|
var id = this.parseIdentifier(true);
|
|
9702
9884
|
var init = this.eat(29) ? this.flowEnumMemberInit() : {
|
|
9703
9885
|
type: "none",
|
|
9704
|
-
|
|
9886
|
+
loc
|
|
9705
9887
|
};
|
|
9706
9888
|
return {
|
|
9707
9889
|
id,
|
|
@@ -9709,7 +9891,7 @@
|
|
|
9709
9891
|
};
|
|
9710
9892
|
}
|
|
9711
9893
|
|
|
9712
|
-
flowEnumCheckExplicitTypeMismatch(
|
|
9894
|
+
flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
|
|
9713
9895
|
var {
|
|
9714
9896
|
explicitType
|
|
9715
9897
|
} = context;
|
|
@@ -9719,15 +9901,15 @@
|
|
|
9719
9901
|
}
|
|
9720
9902
|
|
|
9721
9903
|
if (explicitType !== expectedType) {
|
|
9722
|
-
this.flowEnumErrorInvalidMemberInitializer(
|
|
9904
|
+
this.flowEnumErrorInvalidMemberInitializer(loc, context);
|
|
9723
9905
|
}
|
|
9724
9906
|
}
|
|
9725
9907
|
|
|
9726
|
-
flowEnumMembers(
|
|
9908
|
+
flowEnumMembers(_ref13) {
|
|
9727
9909
|
var {
|
|
9728
9910
|
enumName,
|
|
9729
9911
|
explicitType
|
|
9730
|
-
} =
|
|
9912
|
+
} = _ref13;
|
|
9731
9913
|
var seenNames = new Set();
|
|
9732
9914
|
var members = {
|
|
9733
9915
|
booleanMembers: [],
|
|
@@ -9755,17 +9937,15 @@
|
|
|
9755
9937
|
}
|
|
9756
9938
|
|
|
9757
9939
|
if (/^[a-z]/.test(memberName)) {
|
|
9758
|
-
this.
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
});
|
|
9940
|
+
this.raise(FlowErrors.EnumInvalidMemberName, {
|
|
9941
|
+
node: id
|
|
9942
|
+
}, memberName, memberName[0].toUpperCase() + memberName.slice(1), enumName);
|
|
9762
9943
|
}
|
|
9763
9944
|
|
|
9764
9945
|
if (seenNames.has(memberName)) {
|
|
9765
|
-
this.
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
});
|
|
9946
|
+
this.raise(FlowErrors.EnumDuplicateMemberName, {
|
|
9947
|
+
node: id
|
|
9948
|
+
}, memberName, enumName);
|
|
9769
9949
|
}
|
|
9770
9950
|
|
|
9771
9951
|
seenNames.add(memberName);
|
|
@@ -9779,7 +9959,7 @@
|
|
|
9779
9959
|
switch (init.type) {
|
|
9780
9960
|
case "boolean":
|
|
9781
9961
|
{
|
|
9782
|
-
this.flowEnumCheckExplicitTypeMismatch(init.
|
|
9962
|
+
this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
|
|
9783
9963
|
memberNode.init = init.value;
|
|
9784
9964
|
members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
|
|
9785
9965
|
break;
|
|
@@ -9787,7 +9967,7 @@
|
|
|
9787
9967
|
|
|
9788
9968
|
case "number":
|
|
9789
9969
|
{
|
|
9790
|
-
this.flowEnumCheckExplicitTypeMismatch(init.
|
|
9970
|
+
this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
|
|
9791
9971
|
memberNode.init = init.value;
|
|
9792
9972
|
members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
|
|
9793
9973
|
break;
|
|
@@ -9795,7 +9975,7 @@
|
|
|
9795
9975
|
|
|
9796
9976
|
case "string":
|
|
9797
9977
|
{
|
|
9798
|
-
this.flowEnumCheckExplicitTypeMismatch(init.
|
|
9978
|
+
this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
|
|
9799
9979
|
memberNode.init = init.value;
|
|
9800
9980
|
members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
|
|
9801
9981
|
break;
|
|
@@ -9803,18 +9983,18 @@
|
|
|
9803
9983
|
|
|
9804
9984
|
case "invalid":
|
|
9805
9985
|
{
|
|
9806
|
-
throw this.flowEnumErrorInvalidMemberInitializer(init.
|
|
9986
|
+
throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
|
|
9807
9987
|
}
|
|
9808
9988
|
|
|
9809
9989
|
case "none":
|
|
9810
9990
|
{
|
|
9811
9991
|
switch (explicitType) {
|
|
9812
9992
|
case "boolean":
|
|
9813
|
-
this.flowEnumErrorBooleanMemberNotInitialized(init.
|
|
9993
|
+
this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
|
|
9814
9994
|
break;
|
|
9815
9995
|
|
|
9816
9996
|
case "number":
|
|
9817
|
-
this.flowEnumErrorNumberMemberNotInitialized(init.
|
|
9997
|
+
this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
|
|
9818
9998
|
break;
|
|
9819
9999
|
|
|
9820
10000
|
default:
|
|
@@ -9834,10 +10014,10 @@
|
|
|
9834
10014
|
};
|
|
9835
10015
|
}
|
|
9836
10016
|
|
|
9837
|
-
flowEnumStringMembers(initializedMembers, defaultedMembers,
|
|
10017
|
+
flowEnumStringMembers(initializedMembers, defaultedMembers, _ref14) {
|
|
9838
10018
|
var {
|
|
9839
10019
|
enumName
|
|
9840
|
-
} =
|
|
10020
|
+
} = _ref14;
|
|
9841
10021
|
|
|
9842
10022
|
if (initializedMembers.length === 0) {
|
|
9843
10023
|
return defaultedMembers;
|
|
@@ -9845,7 +10025,7 @@
|
|
|
9845
10025
|
return initializedMembers;
|
|
9846
10026
|
} else if (defaultedMembers.length > initializedMembers.length) {
|
|
9847
10027
|
for (var member of initializedMembers) {
|
|
9848
|
-
this.flowEnumErrorStringMemberInconsistentlyInitailized(member
|
|
10028
|
+
this.flowEnumErrorStringMemberInconsistentlyInitailized(member, {
|
|
9849
10029
|
enumName
|
|
9850
10030
|
});
|
|
9851
10031
|
}
|
|
@@ -9853,7 +10033,7 @@
|
|
|
9853
10033
|
return defaultedMembers;
|
|
9854
10034
|
} else {
|
|
9855
10035
|
for (var _member of defaultedMembers) {
|
|
9856
|
-
this.flowEnumErrorStringMemberInconsistentlyInitailized(_member
|
|
10036
|
+
this.flowEnumErrorStringMemberInconsistentlyInitailized(_member, {
|
|
9857
10037
|
enumName
|
|
9858
10038
|
});
|
|
9859
10039
|
}
|
|
@@ -9862,14 +10042,14 @@
|
|
|
9862
10042
|
}
|
|
9863
10043
|
}
|
|
9864
10044
|
|
|
9865
|
-
flowEnumParseExplicitType(
|
|
10045
|
+
flowEnumParseExplicitType(_ref15) {
|
|
9866
10046
|
var {
|
|
9867
10047
|
enumName
|
|
9868
|
-
} =
|
|
10048
|
+
} = _ref15;
|
|
9869
10049
|
|
|
9870
10050
|
if (this.eatContextual(97)) {
|
|
9871
10051
|
if (!tokenIsIdentifier(this.state.type)) {
|
|
9872
|
-
throw this.flowEnumErrorInvalidExplicitType(this.state.
|
|
10052
|
+
throw this.flowEnumErrorInvalidExplicitType(this.state.startLoc, {
|
|
9873
10053
|
enumName,
|
|
9874
10054
|
suppliedType: null
|
|
9875
10055
|
});
|
|
@@ -9881,7 +10061,7 @@
|
|
|
9881
10061
|
this.next();
|
|
9882
10062
|
|
|
9883
10063
|
if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
|
|
9884
|
-
this.flowEnumErrorInvalidExplicitType(this.state.
|
|
10064
|
+
this.flowEnumErrorInvalidExplicitType(this.state.startLoc, {
|
|
9885
10065
|
enumName,
|
|
9886
10066
|
suppliedType: value
|
|
9887
10067
|
});
|
|
@@ -9893,11 +10073,9 @@
|
|
|
9893
10073
|
return null;
|
|
9894
10074
|
}
|
|
9895
10075
|
|
|
9896
|
-
flowEnumBody(node,
|
|
9897
|
-
var
|
|
9898
|
-
|
|
9899
|
-
nameLoc
|
|
9900
|
-
} = _ref17;
|
|
10076
|
+
flowEnumBody(node, id) {
|
|
10077
|
+
var enumName = id.name;
|
|
10078
|
+
var nameLoc = id.loc.start;
|
|
9901
10079
|
var explicitType = this.flowEnumParseExplicitType({
|
|
9902
10080
|
enumName
|
|
9903
10081
|
});
|
|
@@ -9961,7 +10139,7 @@
|
|
|
9961
10139
|
return this.finishNode(node, "EnumStringBody");
|
|
9962
10140
|
} else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
|
|
9963
10141
|
for (var member of members.defaultedMembers) {
|
|
9964
|
-
this.flowEnumErrorBooleanMemberNotInitialized(member.start, {
|
|
10142
|
+
this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
|
|
9965
10143
|
enumName,
|
|
9966
10144
|
memberName: member.id.name
|
|
9967
10145
|
});
|
|
@@ -9972,7 +10150,7 @@
|
|
|
9972
10150
|
return this.finishNode(node, "EnumBooleanBody");
|
|
9973
10151
|
} else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
|
|
9974
10152
|
for (var _member2 of members.defaultedMembers) {
|
|
9975
|
-
this.flowEnumErrorNumberMemberNotInitialized(_member2.start, {
|
|
10153
|
+
this.flowEnumErrorNumberMemberNotInitialized(_member2.loc.start, {
|
|
9976
10154
|
enumName,
|
|
9977
10155
|
memberName: _member2.id.name
|
|
9978
10156
|
});
|
|
@@ -9982,9 +10160,9 @@
|
|
|
9982
10160
|
this.expect(8);
|
|
9983
10161
|
return this.finishNode(node, "EnumNumberBody");
|
|
9984
10162
|
} else {
|
|
9985
|
-
this.
|
|
9986
|
-
|
|
9987
|
-
});
|
|
10163
|
+
this.raise(FlowErrors.EnumInconsistentMemberValues, {
|
|
10164
|
+
at: nameLoc
|
|
10165
|
+
}, enumName);
|
|
9988
10166
|
return empty();
|
|
9989
10167
|
}
|
|
9990
10168
|
}
|
|
@@ -9994,10 +10172,7 @@
|
|
|
9994
10172
|
flowParseEnumDeclaration(node) {
|
|
9995
10173
|
var id = this.parseIdentifier();
|
|
9996
10174
|
node.id = id;
|
|
9997
|
-
node.body = this.flowEnumBody(this.startNode(),
|
|
9998
|
-
enumName: id.name,
|
|
9999
|
-
nameLoc: id.start
|
|
10000
|
-
});
|
|
10175
|
+
node.body = this.flowEnumBody(this.startNode(), id);
|
|
10001
10176
|
return this.finishNode(node, "EnumDeclaration");
|
|
10002
10177
|
}
|
|
10003
10178
|
|
|
@@ -10312,7 +10487,9 @@
|
|
|
10312
10487
|
|
|
10313
10488
|
for (;;) {
|
|
10314
10489
|
if (this.state.pos >= this.length) {
|
|
10315
|
-
throw this.raise(
|
|
10490
|
+
throw this.raise(JsxErrors.UnterminatedJsxContent, {
|
|
10491
|
+
at: this.state.startLoc
|
|
10492
|
+
});
|
|
10316
10493
|
}
|
|
10317
10494
|
|
|
10318
10495
|
var ch = this.input.charCodeAt(this.state.pos);
|
|
@@ -10376,7 +10553,9 @@
|
|
|
10376
10553
|
|
|
10377
10554
|
for (;;) {
|
|
10378
10555
|
if (this.state.pos >= this.length) {
|
|
10379
|
-
throw this.raise(
|
|
10556
|
+
throw this.raise(ErrorMessages.UnterminatedString, {
|
|
10557
|
+
at: this.state.startLoc
|
|
10558
|
+
});
|
|
10380
10559
|
}
|
|
10381
10560
|
|
|
10382
10561
|
var ch = this.input.charCodeAt(this.state.pos);
|
|
@@ -10509,7 +10688,9 @@
|
|
|
10509
10688
|
node = this.jsxParseExpressionContainer(node, types.j_oTag);
|
|
10510
10689
|
|
|
10511
10690
|
if (node.expression.type === "JSXEmptyExpression") {
|
|
10512
|
-
this.raise(
|
|
10691
|
+
this.raise(JsxErrors.AttributeIsEmpty, {
|
|
10692
|
+
node
|
|
10693
|
+
});
|
|
10513
10694
|
}
|
|
10514
10695
|
|
|
10515
10696
|
return node;
|
|
@@ -10519,13 +10700,15 @@
|
|
|
10519
10700
|
return this.parseExprAtom();
|
|
10520
10701
|
|
|
10521
10702
|
default:
|
|
10522
|
-
throw this.raise(
|
|
10703
|
+
throw this.raise(JsxErrors.UnsupportedJsxValue, {
|
|
10704
|
+
at: this.state.startLoc
|
|
10705
|
+
});
|
|
10523
10706
|
}
|
|
10524
10707
|
}
|
|
10525
10708
|
|
|
10526
10709
|
jsxParseEmptyExpression() {
|
|
10527
|
-
var node = this.startNodeAt(this.state.
|
|
10528
|
-
return this.finishNodeAt(node, "JSXEmptyExpression", this.state.
|
|
10710
|
+
var node = this.startNodeAt(indexes.get(this.state.lastTokEndLoc), this.state.lastTokEndLoc);
|
|
10711
|
+
return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
|
|
10529
10712
|
}
|
|
10530
10713
|
|
|
10531
10714
|
jsxParseSpreadChild(node) {
|
|
@@ -10652,13 +10835,19 @@
|
|
|
10652
10835
|
}
|
|
10653
10836
|
}
|
|
10654
10837
|
|
|
10655
|
-
if (isFragment(openingElement) && !isFragment(closingElement)) {
|
|
10656
|
-
this.raise(
|
|
10838
|
+
if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
|
|
10839
|
+
this.raise(JsxErrors.MissingClosingTagFragment, {
|
|
10840
|
+
node: closingElement
|
|
10841
|
+
});
|
|
10657
10842
|
} else if (!isFragment(openingElement) && isFragment(closingElement)) {
|
|
10658
|
-
this.raise(
|
|
10843
|
+
this.raise(JsxErrors.MissingClosingTagElement, {
|
|
10844
|
+
node: closingElement
|
|
10845
|
+
}, getQualifiedJSXName(openingElement.name));
|
|
10659
10846
|
} else if (!isFragment(openingElement) && !isFragment(closingElement)) {
|
|
10660
10847
|
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
|
|
10661
|
-
this.raise(
|
|
10848
|
+
this.raise(JsxErrors.MissingClosingTagElement, {
|
|
10849
|
+
node: closingElement
|
|
10850
|
+
}, getQualifiedJSXName(openingElement.name));
|
|
10662
10851
|
}
|
|
10663
10852
|
}
|
|
10664
10853
|
}
|
|
@@ -10674,7 +10863,9 @@
|
|
|
10674
10863
|
node.children = children;
|
|
10675
10864
|
|
|
10676
10865
|
if (this.match(45)) {
|
|
10677
|
-
throw this.raise(
|
|
10866
|
+
throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, {
|
|
10867
|
+
at: this.state.startLoc
|
|
10868
|
+
});
|
|
10678
10869
|
}
|
|
10679
10870
|
|
|
10680
10871
|
return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
|
|
@@ -10787,7 +10978,7 @@
|
|
|
10787
10978
|
return new TypeScriptScope(flags);
|
|
10788
10979
|
}
|
|
10789
10980
|
|
|
10790
|
-
declareName(name, bindingType,
|
|
10981
|
+
declareName(name, bindingType, loc) {
|
|
10791
10982
|
var scope = this.currentScope();
|
|
10792
10983
|
|
|
10793
10984
|
if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {
|
|
@@ -10800,7 +10991,7 @@
|
|
|
10800
10991
|
|
|
10801
10992
|
if (bindingType & BIND_KIND_TYPE) {
|
|
10802
10993
|
if (!(bindingType & BIND_KIND_VALUE)) {
|
|
10803
|
-
this.checkRedeclarationInScope(scope, name, bindingType,
|
|
10994
|
+
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
|
10804
10995
|
this.maybeExportDefined(scope, name);
|
|
10805
10996
|
}
|
|
10806
10997
|
|
|
@@ -11001,49 +11192,61 @@
|
|
|
11001
11192
|
}
|
|
11002
11193
|
|
|
11003
11194
|
tsParseModifiers(modified, allowedModifiers, disallowedModifiers, errorTemplate, stopOnStartOfClassStaticBlock) {
|
|
11004
|
-
var enforceOrder = (
|
|
11195
|
+
var enforceOrder = (loc, modifier, before, after) => {
|
|
11005
11196
|
if (modifier === before && modified[after]) {
|
|
11006
|
-
this.raise(
|
|
11197
|
+
this.raise(TSErrors.InvalidModifiersOrder, {
|
|
11198
|
+
at: loc
|
|
11199
|
+
}, before, after);
|
|
11007
11200
|
}
|
|
11008
11201
|
};
|
|
11009
11202
|
|
|
11010
|
-
var incompatible = (
|
|
11203
|
+
var incompatible = (loc, modifier, mod1, mod2) => {
|
|
11011
11204
|
if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
|
|
11012
|
-
this.raise(
|
|
11205
|
+
this.raise(TSErrors.IncompatibleModifiers, {
|
|
11206
|
+
at: loc
|
|
11207
|
+
}, mod1, mod2);
|
|
11013
11208
|
}
|
|
11014
11209
|
};
|
|
11015
11210
|
|
|
11016
11211
|
for (;;) {
|
|
11017
|
-
var
|
|
11212
|
+
var {
|
|
11213
|
+
startLoc
|
|
11214
|
+
} = this.state;
|
|
11018
11215
|
var modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
|
|
11019
11216
|
if (!modifier) break;
|
|
11020
11217
|
|
|
11021
11218
|
if (tsIsAccessModifier(modifier)) {
|
|
11022
11219
|
if (modified.accessibility) {
|
|
11023
|
-
this.raise(
|
|
11220
|
+
this.raise(TSErrors.DuplicateAccessibilityModifier, {
|
|
11221
|
+
at: startLoc
|
|
11222
|
+
});
|
|
11024
11223
|
} else {
|
|
11025
|
-
enforceOrder(
|
|
11026
|
-
enforceOrder(
|
|
11027
|
-
enforceOrder(
|
|
11224
|
+
enforceOrder(startLoc, modifier, modifier, "override");
|
|
11225
|
+
enforceOrder(startLoc, modifier, modifier, "static");
|
|
11226
|
+
enforceOrder(startLoc, modifier, modifier, "readonly");
|
|
11028
11227
|
modified.accessibility = modifier;
|
|
11029
11228
|
}
|
|
11030
11229
|
} else {
|
|
11031
11230
|
if (Object.hasOwnProperty.call(modified, modifier)) {
|
|
11032
|
-
this.raise(
|
|
11231
|
+
this.raise(TSErrors.DuplicateModifier, {
|
|
11232
|
+
at: startLoc
|
|
11233
|
+
}, modifier);
|
|
11033
11234
|
} else {
|
|
11034
|
-
enforceOrder(
|
|
11035
|
-
enforceOrder(
|
|
11036
|
-
enforceOrder(
|
|
11037
|
-
enforceOrder(
|
|
11038
|
-
incompatible(
|
|
11039
|
-
incompatible(
|
|
11235
|
+
enforceOrder(startLoc, modifier, "static", "readonly");
|
|
11236
|
+
enforceOrder(startLoc, modifier, "static", "override");
|
|
11237
|
+
enforceOrder(startLoc, modifier, "override", "readonly");
|
|
11238
|
+
enforceOrder(startLoc, modifier, "abstract", "override");
|
|
11239
|
+
incompatible(startLoc, modifier, "declare", "override");
|
|
11240
|
+
incompatible(startLoc, modifier, "static", "abstract");
|
|
11040
11241
|
}
|
|
11041
11242
|
|
|
11042
11243
|
modified[modifier] = true;
|
|
11043
11244
|
}
|
|
11044
11245
|
|
|
11045
11246
|
if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
|
|
11046
|
-
this.raise(
|
|
11247
|
+
this.raise(errorTemplate, {
|
|
11248
|
+
at: startLoc
|
|
11249
|
+
}, modifier);
|
|
11047
11250
|
}
|
|
11048
11251
|
}
|
|
11049
11252
|
}
|
|
@@ -11148,7 +11351,9 @@
|
|
|
11148
11351
|
this.expect(10);
|
|
11149
11352
|
|
|
11150
11353
|
if (!this.match(125)) {
|
|
11151
|
-
this.raise(
|
|
11354
|
+
this.raise(TSErrors.UnsupportedImportTypeArgument, {
|
|
11355
|
+
at: this.state.startLoc
|
|
11356
|
+
});
|
|
11152
11357
|
}
|
|
11153
11358
|
|
|
11154
11359
|
node.argument = this.parseExprAtom();
|
|
@@ -11246,7 +11451,9 @@
|
|
|
11246
11451
|
node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true, refTrailingCommaPos);
|
|
11247
11452
|
|
|
11248
11453
|
if (node.params.length === 0) {
|
|
11249
|
-
this.raise(
|
|
11454
|
+
this.raise(TSErrors.EmptyTypeParameters, {
|
|
11455
|
+
node
|
|
11456
|
+
});
|
|
11250
11457
|
}
|
|
11251
11458
|
|
|
11252
11459
|
if (refTrailingCommaPos.value !== -1) {
|
|
@@ -11267,21 +11474,25 @@
|
|
|
11267
11474
|
|
|
11268
11475
|
tsFillSignature(returnToken, signature) {
|
|
11269
11476
|
var returnTokenRequired = returnToken === 19;
|
|
11477
|
+
var paramsKey = "parameters";
|
|
11478
|
+
var returnTypeKey = "typeAnnotation";
|
|
11270
11479
|
signature.typeParameters = this.tsTryParseTypeParameters();
|
|
11271
11480
|
this.expect(10);
|
|
11272
|
-
signature
|
|
11481
|
+
signature[paramsKey] = this.tsParseBindingListForSignature();
|
|
11273
11482
|
|
|
11274
11483
|
if (returnTokenRequired) {
|
|
11275
|
-
signature
|
|
11484
|
+
signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
|
11276
11485
|
} else if (this.match(returnToken)) {
|
|
11277
|
-
signature
|
|
11486
|
+
signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
|
11278
11487
|
}
|
|
11279
11488
|
}
|
|
11280
11489
|
|
|
11281
11490
|
tsParseBindingListForSignature() {
|
|
11282
11491
|
return this.parseBindingList(11, 41).map(pattern => {
|
|
11283
11492
|
if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") {
|
|
11284
|
-
this.raise(
|
|
11493
|
+
this.raise(TSErrors.UnsupportedSignatureParameterKind, {
|
|
11494
|
+
node: pattern
|
|
11495
|
+
}, pattern.type);
|
|
11285
11496
|
}
|
|
11286
11497
|
|
|
11287
11498
|
return pattern;
|
|
@@ -11334,47 +11545,67 @@
|
|
|
11334
11545
|
|
|
11335
11546
|
if (this.match(10) || this.match(45)) {
|
|
11336
11547
|
if (readonly) {
|
|
11337
|
-
this.raise(
|
|
11548
|
+
this.raise(TSErrors.ReadonlyForMethodSignature, {
|
|
11549
|
+
node
|
|
11550
|
+
});
|
|
11338
11551
|
}
|
|
11339
11552
|
|
|
11340
11553
|
var method = nodeAny;
|
|
11341
11554
|
|
|
11342
11555
|
if (method.kind && this.match(45)) {
|
|
11343
|
-
this.raise(
|
|
11556
|
+
this.raise(TSErrors.AccesorCannotHaveTypeParameters, {
|
|
11557
|
+
at: this.state.curPosition()
|
|
11558
|
+
});
|
|
11344
11559
|
}
|
|
11345
11560
|
|
|
11346
11561
|
this.tsFillSignature(14, method);
|
|
11347
11562
|
this.tsParseTypeMemberSemicolon();
|
|
11563
|
+
var paramsKey = "parameters";
|
|
11564
|
+
var returnTypeKey = "typeAnnotation";
|
|
11348
11565
|
|
|
11349
11566
|
if (method.kind === "get") {
|
|
11350
|
-
if (method.
|
|
11351
|
-
this.raise(
|
|
11567
|
+
if (method[paramsKey].length > 0) {
|
|
11568
|
+
this.raise(ErrorMessages.BadGetterArity, {
|
|
11569
|
+
at: this.state.curPosition()
|
|
11570
|
+
});
|
|
11352
11571
|
|
|
11353
|
-
if (this.isThisParam(method
|
|
11354
|
-
this.raise(
|
|
11572
|
+
if (this.isThisParam(method[paramsKey][0])) {
|
|
11573
|
+
this.raise(TSErrors.AccesorCannotDeclareThisParameter, {
|
|
11574
|
+
at: this.state.curPosition()
|
|
11575
|
+
});
|
|
11355
11576
|
}
|
|
11356
11577
|
}
|
|
11357
11578
|
} else if (method.kind === "set") {
|
|
11358
|
-
if (method.
|
|
11359
|
-
this.raise(
|
|
11579
|
+
if (method[paramsKey].length !== 1) {
|
|
11580
|
+
this.raise(ErrorMessages.BadSetterArity, {
|
|
11581
|
+
at: this.state.curPosition()
|
|
11582
|
+
});
|
|
11360
11583
|
} else {
|
|
11361
|
-
var firstParameter = method
|
|
11584
|
+
var firstParameter = method[paramsKey][0];
|
|
11362
11585
|
|
|
11363
11586
|
if (this.isThisParam(firstParameter)) {
|
|
11364
|
-
this.raise(
|
|
11587
|
+
this.raise(TSErrors.AccesorCannotDeclareThisParameter, {
|
|
11588
|
+
at: this.state.curPosition()
|
|
11589
|
+
});
|
|
11365
11590
|
}
|
|
11366
11591
|
|
|
11367
11592
|
if (firstParameter.type === "Identifier" && firstParameter.optional) {
|
|
11368
|
-
this.raise(
|
|
11593
|
+
this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, {
|
|
11594
|
+
at: this.state.curPosition()
|
|
11595
|
+
});
|
|
11369
11596
|
}
|
|
11370
11597
|
|
|
11371
11598
|
if (firstParameter.type === "RestElement") {
|
|
11372
|
-
this.raise(
|
|
11599
|
+
this.raise(TSErrors.SetAccesorCannotHaveRestParameter, {
|
|
11600
|
+
at: this.state.curPosition()
|
|
11601
|
+
});
|
|
11373
11602
|
}
|
|
11374
11603
|
}
|
|
11375
11604
|
|
|
11376
|
-
if (method
|
|
11377
|
-
this.raise(
|
|
11605
|
+
if (method[returnTypeKey]) {
|
|
11606
|
+
this.raise(TSErrors.SetAccesorCannotHaveReturnType, {
|
|
11607
|
+
node: method[returnTypeKey]
|
|
11608
|
+
});
|
|
11378
11609
|
}
|
|
11379
11610
|
} else {
|
|
11380
11611
|
method.kind = "method";
|
|
@@ -11516,7 +11747,9 @@
|
|
|
11516
11747
|
} = elementNode;
|
|
11517
11748
|
|
|
11518
11749
|
if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
|
|
11519
|
-
this.raise(
|
|
11750
|
+
this.raise(TSErrors.OptionalTypeBeforeRequired, {
|
|
11751
|
+
node: elementNode
|
|
11752
|
+
});
|
|
11520
11753
|
}
|
|
11521
11754
|
|
|
11522
11755
|
seenOptionalElement = seenOptionalElement || type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType";
|
|
@@ -11530,7 +11763,9 @@
|
|
|
11530
11763
|
labeledElements = (_labeledElements = labeledElements) != null ? _labeledElements : isLabeled;
|
|
11531
11764
|
|
|
11532
11765
|
if (labeledElements !== isLabeled) {
|
|
11533
|
-
this.raise(
|
|
11766
|
+
this.raise(TSErrors.MixedLabeledAndUnlabeledElements, {
|
|
11767
|
+
node: elementNode
|
|
11768
|
+
});
|
|
11534
11769
|
}
|
|
11535
11770
|
});
|
|
11536
11771
|
return this.finishNode(node, "TSTupleType");
|
|
@@ -11553,7 +11788,9 @@
|
|
|
11553
11788
|
if (type.type === "TSTypeReference" && !type.typeParameters && type.typeName.type === "Identifier") {
|
|
11554
11789
|
labeledNode.label = type.typeName;
|
|
11555
11790
|
} else {
|
|
11556
|
-
this.raise(
|
|
11791
|
+
this.raise(TSErrors.InvalidTupleMemberLabel, {
|
|
11792
|
+
node: type
|
|
11793
|
+
});
|
|
11557
11794
|
labeledNode.label = type;
|
|
11558
11795
|
}
|
|
11559
11796
|
|
|
@@ -11749,7 +11986,9 @@
|
|
|
11749
11986
|
return;
|
|
11750
11987
|
|
|
11751
11988
|
default:
|
|
11752
|
-
this.raise(
|
|
11989
|
+
this.raise(TSErrors.UnexpectedReadonly, {
|
|
11990
|
+
node
|
|
11991
|
+
});
|
|
11753
11992
|
}
|
|
11754
11993
|
}
|
|
11755
11994
|
|
|
@@ -11948,7 +12187,9 @@
|
|
|
11948
12187
|
}
|
|
11949
12188
|
|
|
11950
12189
|
if (containsEsc) {
|
|
11951
|
-
this.raise(
|
|
12190
|
+
this.raise(ErrorMessages.InvalidEscapedReservedWord, {
|
|
12191
|
+
at: this.state.lastTokStartLoc
|
|
12192
|
+
}, "asserts");
|
|
11952
12193
|
}
|
|
11953
12194
|
|
|
11954
12195
|
return true;
|
|
@@ -12002,7 +12243,9 @@
|
|
|
12002
12243
|
|
|
12003
12244
|
tsParseTypeAssertion() {
|
|
12004
12245
|
if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
|
|
12005
|
-
this.raise(
|
|
12246
|
+
this.raise(TSErrors.ReservedTypeAssertion, {
|
|
12247
|
+
at: this.state.startLoc
|
|
12248
|
+
});
|
|
12006
12249
|
}
|
|
12007
12250
|
|
|
12008
12251
|
var node = this.startNode();
|
|
@@ -12016,11 +12259,13 @@
|
|
|
12016
12259
|
}
|
|
12017
12260
|
|
|
12018
12261
|
tsParseHeritageClause(descriptor) {
|
|
12019
|
-
var
|
|
12262
|
+
var originalStartLoc = this.state.startLoc;
|
|
12020
12263
|
var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
|
|
12021
12264
|
|
|
12022
12265
|
if (!delimitedList.length) {
|
|
12023
|
-
this.raise(
|
|
12266
|
+
this.raise(TSErrors.EmptyHeritageClauseType, {
|
|
12267
|
+
at: originalStartLoc
|
|
12268
|
+
}, descriptor);
|
|
12024
12269
|
}
|
|
12025
12270
|
|
|
12026
12271
|
return delimitedList;
|
|
@@ -12043,7 +12288,9 @@
|
|
|
12043
12288
|
this.checkLVal(node.id, "typescript interface declaration", BIND_TS_INTERFACE);
|
|
12044
12289
|
} else {
|
|
12045
12290
|
node.id = null;
|
|
12046
|
-
this.raise(
|
|
12291
|
+
this.raise(TSErrors.MissingInterfaceName, {
|
|
12292
|
+
at: this.state.startLoc
|
|
12293
|
+
});
|
|
12047
12294
|
}
|
|
12048
12295
|
|
|
12049
12296
|
node.typeParameters = this.tsTryParseTypeParameters();
|
|
@@ -12203,7 +12450,9 @@
|
|
|
12203
12450
|
var moduleReference = this.tsParseModuleReference();
|
|
12204
12451
|
|
|
12205
12452
|
if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
|
|
12206
|
-
this.raise(
|
|
12453
|
+
this.raise(TSErrors.ImportAliasHasImportType, {
|
|
12454
|
+
node: moduleReference
|
|
12455
|
+
});
|
|
12207
12456
|
}
|
|
12208
12457
|
|
|
12209
12458
|
node.moduleReference = moduleReference;
|
|
@@ -12437,7 +12686,9 @@
|
|
|
12437
12686
|
}));
|
|
12438
12687
|
|
|
12439
12688
|
if (node.params.length === 0) {
|
|
12440
|
-
this.raise(
|
|
12689
|
+
this.raise(TSErrors.EmptyTypeArguments, {
|
|
12690
|
+
node
|
|
12691
|
+
});
|
|
12441
12692
|
}
|
|
12442
12693
|
|
|
12443
12694
|
this.expect(46);
|
|
@@ -12468,7 +12719,9 @@
|
|
|
12468
12719
|
readonly = modified.readonly;
|
|
12469
12720
|
|
|
12470
12721
|
if (allowModifiers === false && (accessibility || readonly || override)) {
|
|
12471
|
-
this.raise(
|
|
12722
|
+
this.raise(TSErrors.UnexpectedParameterModifier, {
|
|
12723
|
+
at: startLoc
|
|
12724
|
+
});
|
|
12472
12725
|
}
|
|
12473
12726
|
}
|
|
12474
12727
|
|
|
@@ -12488,7 +12741,9 @@
|
|
|
12488
12741
|
if (override) pp.override = override;
|
|
12489
12742
|
|
|
12490
12743
|
if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
|
|
12491
|
-
this.raise(
|
|
12744
|
+
this.raise(TSErrors.UnsupportedParameterPropertyKind, {
|
|
12745
|
+
node: pp
|
|
12746
|
+
});
|
|
12492
12747
|
}
|
|
12493
12748
|
|
|
12494
12749
|
pp.parameter = elt;
|
|
@@ -12517,7 +12772,9 @@
|
|
|
12517
12772
|
}
|
|
12518
12773
|
|
|
12519
12774
|
if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
|
|
12520
|
-
this.raise(
|
|
12775
|
+
this.raise(TSErrors.DeclareFunctionHasImplementation, {
|
|
12776
|
+
node
|
|
12777
|
+
});
|
|
12521
12778
|
|
|
12522
12779
|
if (node.declare) {
|
|
12523
12780
|
super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
|
|
@@ -12539,7 +12796,9 @@
|
|
|
12539
12796
|
tsCheckForInvalidTypeCasts(items) {
|
|
12540
12797
|
items.forEach(node => {
|
|
12541
12798
|
if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
|
|
12542
|
-
this.raise(
|
|
12799
|
+
this.raise(TSErrors.UnexpectedTypeAnnotation, {
|
|
12800
|
+
node: node.typeAnnotation
|
|
12801
|
+
});
|
|
12543
12802
|
}
|
|
12544
12803
|
});
|
|
12545
12804
|
}
|
|
@@ -12581,7 +12840,7 @@
|
|
|
12581
12840
|
}
|
|
12582
12841
|
|
|
12583
12842
|
if (this.match(45)) {
|
|
12584
|
-
var
|
|
12843
|
+
var missingParenErrorLoc;
|
|
12585
12844
|
var result = this.tsTryParseAndCatch(() => {
|
|
12586
12845
|
if (!noCalls && this.atPossibleAsyncArrow(base)) {
|
|
12587
12846
|
var asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startPos, startLoc);
|
|
@@ -12597,7 +12856,7 @@
|
|
|
12597
12856
|
|
|
12598
12857
|
if (typeArguments) {
|
|
12599
12858
|
if (isOptionalCall && !this.match(10)) {
|
|
12600
|
-
|
|
12859
|
+
missingParenErrorLoc = this.state.curPosition();
|
|
12601
12860
|
this.unexpected();
|
|
12602
12861
|
}
|
|
12603
12862
|
|
|
@@ -12622,8 +12881,8 @@
|
|
|
12622
12881
|
this.unexpected();
|
|
12623
12882
|
});
|
|
12624
12883
|
|
|
12625
|
-
if (
|
|
12626
|
-
this.unexpected(
|
|
12884
|
+
if (missingParenErrorLoc) {
|
|
12885
|
+
this.unexpected(missingParenErrorLoc, 10);
|
|
12627
12886
|
}
|
|
12628
12887
|
|
|
12629
12888
|
if (result) return result;
|
|
@@ -12693,7 +12952,9 @@
|
|
|
12693
12952
|
var importNode = super.parseImport(node);
|
|
12694
12953
|
|
|
12695
12954
|
if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
|
|
12696
|
-
this.raise(
|
|
12955
|
+
this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, {
|
|
12956
|
+
node: importNode
|
|
12957
|
+
});
|
|
12697
12958
|
}
|
|
12698
12959
|
|
|
12699
12960
|
return importNode;
|
|
@@ -12800,7 +13061,9 @@
|
|
|
12800
13061
|
this.next();
|
|
12801
13062
|
|
|
12802
13063
|
if (this.tsHasSomeModifiers(member, modifiers)) {
|
|
12803
|
-
this.raise(
|
|
13064
|
+
this.raise(TSErrors.StaticBlockCannotHaveModifier, {
|
|
13065
|
+
at: this.state.curPosition()
|
|
13066
|
+
});
|
|
12804
13067
|
}
|
|
12805
13068
|
|
|
12806
13069
|
this.parseClassStaticBlock(classBody, member);
|
|
@@ -12823,31 +13086,43 @@
|
|
|
12823
13086
|
classBody.body.push(idx);
|
|
12824
13087
|
|
|
12825
13088
|
if (member.abstract) {
|
|
12826
|
-
this.raise(
|
|
13089
|
+
this.raise(TSErrors.IndexSignatureHasAbstract, {
|
|
13090
|
+
node: member
|
|
13091
|
+
});
|
|
12827
13092
|
}
|
|
12828
13093
|
|
|
12829
13094
|
if (member.accessibility) {
|
|
12830
|
-
this.raise(
|
|
13095
|
+
this.raise(TSErrors.IndexSignatureHasAccessibility, {
|
|
13096
|
+
node: member
|
|
13097
|
+
}, member.accessibility);
|
|
12831
13098
|
}
|
|
12832
13099
|
|
|
12833
13100
|
if (member.declare) {
|
|
12834
|
-
this.raise(
|
|
13101
|
+
this.raise(TSErrors.IndexSignatureHasDeclare, {
|
|
13102
|
+
node: member
|
|
13103
|
+
});
|
|
12835
13104
|
}
|
|
12836
13105
|
|
|
12837
13106
|
if (member.override) {
|
|
12838
|
-
this.raise(
|
|
13107
|
+
this.raise(TSErrors.IndexSignatureHasOverride, {
|
|
13108
|
+
node: member
|
|
13109
|
+
});
|
|
12839
13110
|
}
|
|
12840
13111
|
|
|
12841
13112
|
return;
|
|
12842
13113
|
}
|
|
12843
13114
|
|
|
12844
13115
|
if (!this.state.inAbstractClass && member.abstract) {
|
|
12845
|
-
this.raise(
|
|
13116
|
+
this.raise(TSErrors.NonAbstractClassHasAbstractMethod, {
|
|
13117
|
+
node: member
|
|
13118
|
+
});
|
|
12846
13119
|
}
|
|
12847
13120
|
|
|
12848
13121
|
if (member.override) {
|
|
12849
13122
|
if (!state.hadSuperClass) {
|
|
12850
|
-
this.raise(
|
|
13123
|
+
this.raise(TSErrors.OverrideNotInSubClass, {
|
|
13124
|
+
node: member
|
|
13125
|
+
});
|
|
12851
13126
|
}
|
|
12852
13127
|
}
|
|
12853
13128
|
|
|
@@ -12859,11 +13134,15 @@
|
|
|
12859
13134
|
if (optional) methodOrProp.optional = true;
|
|
12860
13135
|
|
|
12861
13136
|
if (methodOrProp.readonly && this.match(10)) {
|
|
12862
|
-
this.raise(
|
|
13137
|
+
this.raise(TSErrors.ClassMethodHasReadonly, {
|
|
13138
|
+
node: methodOrProp
|
|
13139
|
+
});
|
|
12863
13140
|
}
|
|
12864
13141
|
|
|
12865
13142
|
if (methodOrProp.declare && this.match(10)) {
|
|
12866
|
-
this.raise(
|
|
13143
|
+
this.raise(TSErrors.ClassMethodHasDeclare, {
|
|
13144
|
+
node: methodOrProp
|
|
13145
|
+
});
|
|
12867
13146
|
}
|
|
12868
13147
|
}
|
|
12869
13148
|
|
|
@@ -12920,7 +13199,9 @@
|
|
|
12920
13199
|
var isDeclare = this.eatContextual(117);
|
|
12921
13200
|
|
|
12922
13201
|
if (isDeclare && (this.isContextual(117) || !this.shouldParseExportDeclaration())) {
|
|
12923
|
-
throw this.raise(
|
|
13202
|
+
throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, {
|
|
13203
|
+
at: this.state.startLoc
|
|
13204
|
+
});
|
|
12924
13205
|
}
|
|
12925
13206
|
|
|
12926
13207
|
var declaration;
|
|
@@ -12968,14 +13249,18 @@
|
|
|
12968
13249
|
this.parseClassPropertyAnnotation(node);
|
|
12969
13250
|
|
|
12970
13251
|
if (this.state.isAmbientContext && this.match(29)) {
|
|
12971
|
-
this.raise(
|
|
13252
|
+
this.raise(TSErrors.DeclareClassFieldHasInitializer, {
|
|
13253
|
+
at: this.state.startLoc
|
|
13254
|
+
});
|
|
12972
13255
|
}
|
|
12973
13256
|
|
|
12974
13257
|
if (node.abstract && this.match(29)) {
|
|
12975
13258
|
var {
|
|
12976
13259
|
key
|
|
12977
13260
|
} = node;
|
|
12978
|
-
this.raise(
|
|
13261
|
+
this.raise(TSErrors.AbstractPropertyHasInitializer, {
|
|
13262
|
+
at: this.state.startLoc
|
|
13263
|
+
}, key.type === "Identifier" && !node.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
|
|
12979
13264
|
}
|
|
12980
13265
|
|
|
12981
13266
|
return super.parseClassProperty(node);
|
|
@@ -12983,11 +13268,15 @@
|
|
|
12983
13268
|
|
|
12984
13269
|
parseClassPrivateProperty(node) {
|
|
12985
13270
|
if (node.abstract) {
|
|
12986
|
-
this.raise(
|
|
13271
|
+
this.raise(TSErrors.PrivateElementHasAbstract, {
|
|
13272
|
+
node
|
|
13273
|
+
});
|
|
12987
13274
|
}
|
|
12988
13275
|
|
|
12989
13276
|
if (node.accessibility) {
|
|
12990
|
-
this.raise(
|
|
13277
|
+
this.raise(TSErrors.PrivateElementHasAccessibility, {
|
|
13278
|
+
node
|
|
13279
|
+
}, node.accessibility);
|
|
12991
13280
|
}
|
|
12992
13281
|
|
|
12993
13282
|
this.parseClassPropertyAnnotation(node);
|
|
@@ -12998,11 +13287,15 @@
|
|
|
12998
13287
|
var typeParameters = this.tsTryParseTypeParameters();
|
|
12999
13288
|
|
|
13000
13289
|
if (typeParameters && isConstructor) {
|
|
13001
|
-
this.raise(
|
|
13290
|
+
this.raise(TSErrors.ConstructorHasTypeParameters, {
|
|
13291
|
+
node: typeParameters
|
|
13292
|
+
});
|
|
13002
13293
|
}
|
|
13003
13294
|
|
|
13004
13295
|
if (method.declare && (method.kind === "get" || method.kind === "set")) {
|
|
13005
|
-
this.raise(
|
|
13296
|
+
this.raise(TSErrors.DeclareAccessor, {
|
|
13297
|
+
node: method
|
|
13298
|
+
}, method.kind);
|
|
13006
13299
|
}
|
|
13007
13300
|
|
|
13008
13301
|
if (typeParameters) method.typeParameters = typeParameters;
|
|
@@ -13053,7 +13346,7 @@
|
|
|
13053
13346
|
parseVarId(decl, kind) {
|
|
13054
13347
|
super.parseVarId(decl, kind);
|
|
13055
13348
|
|
|
13056
|
-
if (decl.id.type === "Identifier" && this.eat(35)) {
|
|
13349
|
+
if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
|
|
13057
13350
|
decl.definite = true;
|
|
13058
13351
|
}
|
|
13059
13352
|
|
|
@@ -13159,7 +13452,9 @@
|
|
|
13159
13452
|
var _node$extra;
|
|
13160
13453
|
|
|
13161
13454
|
if (node.params.length === 1 && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
|
|
13162
|
-
this.raise(
|
|
13455
|
+
this.raise(TSErrors.ReservedArrowTypeParam, {
|
|
13456
|
+
node
|
|
13457
|
+
});
|
|
13163
13458
|
}
|
|
13164
13459
|
}
|
|
13165
13460
|
|
|
@@ -13192,7 +13487,9 @@
|
|
|
13192
13487
|
parseAssignableListItemTypes(param) {
|
|
13193
13488
|
if (this.eat(17)) {
|
|
13194
13489
|
if (param.type !== "Identifier" && !this.state.isAmbientContext && !this.state.inType) {
|
|
13195
|
-
this.raise(
|
|
13490
|
+
this.raise(TSErrors.PatternIsOptional, {
|
|
13491
|
+
node: param
|
|
13492
|
+
});
|
|
13196
13493
|
}
|
|
13197
13494
|
|
|
13198
13495
|
param.optional = true;
|
|
@@ -13273,7 +13570,9 @@
|
|
|
13273
13570
|
case "TSAsExpression":
|
|
13274
13571
|
case "TSTypeAssertion":
|
|
13275
13572
|
if (!args[0] && contextDescription !== "parenthesized expression" && !((_expr$extra2 = expr.extra) != null && _expr$extra2.parenthesized)) {
|
|
13276
|
-
this.raise(
|
|
13573
|
+
this.raise(ErrorMessages.InvalidLhs, {
|
|
13574
|
+
node: expr
|
|
13575
|
+
}, contextDescription);
|
|
13277
13576
|
break;
|
|
13278
13577
|
}
|
|
13279
13578
|
|
|
@@ -13310,7 +13609,7 @@
|
|
|
13310
13609
|
return call;
|
|
13311
13610
|
}
|
|
13312
13611
|
|
|
13313
|
-
this.unexpected(
|
|
13612
|
+
this.unexpected(null, 10);
|
|
13314
13613
|
}
|
|
13315
13614
|
|
|
13316
13615
|
return super.parseMaybeDecoratorArguments(expr);
|
|
@@ -13319,8 +13618,9 @@
|
|
|
13319
13618
|
checkCommaAfterRest(close) {
|
|
13320
13619
|
if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
|
|
13321
13620
|
this.next();
|
|
13621
|
+
return false;
|
|
13322
13622
|
} else {
|
|
13323
|
-
super.checkCommaAfterRest(close);
|
|
13623
|
+
return super.checkCommaAfterRest(close);
|
|
13324
13624
|
}
|
|
13325
13625
|
}
|
|
13326
13626
|
|
|
@@ -13336,7 +13636,9 @@
|
|
|
13336
13636
|
var node = super.parseMaybeDefault(...arguments);
|
|
13337
13637
|
|
|
13338
13638
|
if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
|
|
13339
|
-
this.raise(
|
|
13639
|
+
this.raise(TSErrors.TypeAnnotationAfterAssign, {
|
|
13640
|
+
node: node.typeAnnotation
|
|
13641
|
+
});
|
|
13340
13642
|
}
|
|
13341
13643
|
|
|
13342
13644
|
return node;
|
|
@@ -13385,7 +13687,9 @@
|
|
|
13385
13687
|
if (!this.state.maybeInArrowParameters) {
|
|
13386
13688
|
exprList[i] = this.typeCastToParameter(expr);
|
|
13387
13689
|
} else {
|
|
13388
|
-
this.raise(
|
|
13690
|
+
this.raise(TSErrors.UnexpectedTypeCastInParameter, {
|
|
13691
|
+
node: expr
|
|
13692
|
+
});
|
|
13389
13693
|
}
|
|
13390
13694
|
|
|
13391
13695
|
break;
|
|
@@ -13397,7 +13701,7 @@
|
|
|
13397
13701
|
|
|
13398
13702
|
typeCastToParameter(node) {
|
|
13399
13703
|
node.expression.typeAnnotation = node.typeAnnotation;
|
|
13400
|
-
this.resetEndLocation(node.expression, node.typeAnnotation.
|
|
13704
|
+
this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
|
|
13401
13705
|
return node.expression;
|
|
13402
13706
|
}
|
|
13403
13707
|
|
|
@@ -13479,7 +13783,9 @@
|
|
|
13479
13783
|
} else if (this.isContextual(121)) {
|
|
13480
13784
|
if (!this.hasFollowingLineBreak()) {
|
|
13481
13785
|
node.abstract = true;
|
|
13482
|
-
this.raise(
|
|
13786
|
+
this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, {
|
|
13787
|
+
node
|
|
13788
|
+
});
|
|
13483
13789
|
this.next();
|
|
13484
13790
|
return this.tsParseInterfaceDeclaration(node);
|
|
13485
13791
|
}
|
|
@@ -13498,7 +13804,9 @@
|
|
|
13498
13804
|
var {
|
|
13499
13805
|
key
|
|
13500
13806
|
} = method;
|
|
13501
|
-
this.raise(
|
|
13807
|
+
this.raise(TSErrors.AbstractMethodHasImplementation, {
|
|
13808
|
+
node: method
|
|
13809
|
+
}, key.type === "Identifier" && !method.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
|
|
13502
13810
|
}
|
|
13503
13811
|
}
|
|
13504
13812
|
|
|
@@ -13557,7 +13865,7 @@
|
|
|
13557
13865
|
var rightOfAs;
|
|
13558
13866
|
var hasTypeSpecifier = false;
|
|
13559
13867
|
var canParseAsKeyword = true;
|
|
13560
|
-
var
|
|
13868
|
+
var loc = leftOfAs.loc.start;
|
|
13561
13869
|
|
|
13562
13870
|
if (this.isContextual(89)) {
|
|
13563
13871
|
var firstAs = this.parseIdentifier();
|
|
@@ -13587,7 +13895,9 @@
|
|
|
13587
13895
|
}
|
|
13588
13896
|
|
|
13589
13897
|
if (hasTypeSpecifier && isInTypeOnlyImportExport) {
|
|
13590
|
-
this.raise(
|
|
13898
|
+
this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, {
|
|
13899
|
+
at: loc
|
|
13900
|
+
});
|
|
13591
13901
|
}
|
|
13592
13902
|
|
|
13593
13903
|
node[leftOfAsKey] = leftOfAs;
|
|
@@ -13610,9 +13920,9 @@
|
|
|
13610
13920
|
|
|
13611
13921
|
};
|
|
13612
13922
|
|
|
13613
|
-
var
|
|
13923
|
+
var PlaceholderErrors = makeErrorTemplates({
|
|
13614
13924
|
ClassNameIsRequired: "A class name is required."
|
|
13615
|
-
}, ErrorCodes.SyntaxError);
|
|
13925
|
+
}, ErrorCodes.SyntaxError, "placeholders");
|
|
13616
13926
|
|
|
13617
13927
|
var placeholders = superClass => class extends superClass {
|
|
13618
13928
|
parsePlaceholder(expectedNode) {
|
|
@@ -13735,7 +14045,9 @@
|
|
|
13735
14045
|
node.body = this.finishPlaceholder(placeholder, "ClassBody");
|
|
13736
14046
|
return this.finishNode(node, type);
|
|
13737
14047
|
} else {
|
|
13738
|
-
this.
|
|
14048
|
+
throw this.raise(PlaceholderErrors.ClassNameIsRequired, {
|
|
14049
|
+
at: this.state.startLoc
|
|
14050
|
+
});
|
|
13739
14051
|
}
|
|
13740
14052
|
} else {
|
|
13741
14053
|
this.parseClassId(node, isStatement, optionalId);
|
|
@@ -13835,7 +14147,7 @@
|
|
|
13835
14147
|
var v8intrinsic = superClass => class extends superClass {
|
|
13836
14148
|
parseV8Intrinsic() {
|
|
13837
14149
|
if (this.match(50)) {
|
|
13838
|
-
var
|
|
14150
|
+
var v8IntrinsicStartLoc = this.state.startLoc;
|
|
13839
14151
|
var node = this.startNode();
|
|
13840
14152
|
this.next();
|
|
13841
14153
|
|
|
@@ -13849,7 +14161,7 @@
|
|
|
13849
14161
|
}
|
|
13850
14162
|
}
|
|
13851
14163
|
|
|
13852
|
-
this.unexpected(
|
|
14164
|
+
this.unexpected(v8IntrinsicStartLoc);
|
|
13853
14165
|
}
|
|
13854
14166
|
}
|
|
13855
14167
|
|
|
@@ -14043,12 +14355,16 @@
|
|
|
14043
14355
|
|
|
14044
14356
|
if (isLHS) {
|
|
14045
14357
|
if (parenthesized.type === "Identifier") {
|
|
14046
|
-
this.expressionScope.recordParenthesizedIdentifierError(
|
|
14358
|
+
this.expressionScope.recordParenthesizedIdentifierError(ErrorMessages.InvalidParenthesizedAssignment, node.loc.start);
|
|
14047
14359
|
} else if (parenthesized.type !== "MemberExpression") {
|
|
14048
|
-
this.raise(
|
|
14360
|
+
this.raise(ErrorMessages.InvalidParenthesizedAssignment, {
|
|
14361
|
+
node
|
|
14362
|
+
});
|
|
14049
14363
|
}
|
|
14050
14364
|
} else {
|
|
14051
|
-
this.raise(
|
|
14365
|
+
this.raise(ErrorMessages.InvalidParenthesizedAssignment, {
|
|
14366
|
+
node
|
|
14367
|
+
});
|
|
14052
14368
|
}
|
|
14053
14369
|
}
|
|
14054
14370
|
|
|
@@ -14070,8 +14386,10 @@
|
|
|
14070
14386
|
var isLast = i === last;
|
|
14071
14387
|
this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
|
|
14072
14388
|
|
|
14073
|
-
if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.
|
|
14074
|
-
this.
|
|
14389
|
+
if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
|
|
14390
|
+
this.raise(ErrorMessages.RestTrailingComma, {
|
|
14391
|
+
at: node.extra.trailingCommaLoc
|
|
14392
|
+
});
|
|
14075
14393
|
}
|
|
14076
14394
|
}
|
|
14077
14395
|
|
|
@@ -14092,12 +14410,14 @@
|
|
|
14092
14410
|
|
|
14093
14411
|
case "ArrayExpression":
|
|
14094
14412
|
node.type = "ArrayPattern";
|
|
14095
|
-
this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.
|
|
14413
|
+
this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
|
|
14096
14414
|
break;
|
|
14097
14415
|
|
|
14098
14416
|
case "AssignmentExpression":
|
|
14099
14417
|
if (node.operator !== "=") {
|
|
14100
|
-
this.raise(
|
|
14418
|
+
this.raise(ErrorMessages.MissingEqInAssignment, {
|
|
14419
|
+
at: node.left.loc.end
|
|
14420
|
+
});
|
|
14101
14421
|
}
|
|
14102
14422
|
|
|
14103
14423
|
node.type = "AssignmentPattern";
|
|
@@ -14115,16 +14435,19 @@
|
|
|
14115
14435
|
|
|
14116
14436
|
toAssignableObjectExpressionProp(prop, isLast, isLHS) {
|
|
14117
14437
|
if (prop.type === "ObjectMethod") {
|
|
14118
|
-
|
|
14119
|
-
|
|
14438
|
+
this.raise(prop.kind === "get" || prop.kind === "set" ? ErrorMessages.PatternHasAccessor : ErrorMessages.PatternHasMethod, {
|
|
14439
|
+
node: prop.key
|
|
14440
|
+
});
|
|
14120
14441
|
} else if (prop.type === "SpreadElement" && !isLast) {
|
|
14121
|
-
this.
|
|
14442
|
+
this.raise(ErrorMessages.RestTrailingComma, {
|
|
14443
|
+
node: prop
|
|
14444
|
+
});
|
|
14122
14445
|
} else {
|
|
14123
14446
|
this.toAssignable(prop, isLHS);
|
|
14124
14447
|
}
|
|
14125
14448
|
}
|
|
14126
14449
|
|
|
14127
|
-
toAssignableList(exprList,
|
|
14450
|
+
toAssignableList(exprList, trailingCommaLoc, isLHS) {
|
|
14128
14451
|
var end = exprList.length;
|
|
14129
14452
|
|
|
14130
14453
|
if (end) {
|
|
@@ -14142,8 +14465,10 @@
|
|
|
14142
14465
|
this.unexpected(arg.start);
|
|
14143
14466
|
}
|
|
14144
14467
|
|
|
14145
|
-
if (
|
|
14146
|
-
this.
|
|
14468
|
+
if (trailingCommaLoc) {
|
|
14469
|
+
this.raise(ErrorMessages.RestTrailingComma, {
|
|
14470
|
+
at: trailingCommaLoc
|
|
14471
|
+
});
|
|
14147
14472
|
}
|
|
14148
14473
|
|
|
14149
14474
|
--end;
|
|
@@ -14157,7 +14482,9 @@
|
|
|
14157
14482
|
this.toAssignable(elt, isLHS);
|
|
14158
14483
|
|
|
14159
14484
|
if (elt.type === "RestElement") {
|
|
14160
|
-
this.
|
|
14485
|
+
this.raise(ErrorMessages.RestTrailingComma, {
|
|
14486
|
+
node: elt
|
|
14487
|
+
});
|
|
14161
14488
|
}
|
|
14162
14489
|
}
|
|
14163
14490
|
}
|
|
@@ -14268,14 +14595,18 @@
|
|
|
14268
14595
|
break;
|
|
14269
14596
|
} else if (this.match(21)) {
|
|
14270
14597
|
elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
|
|
14271
|
-
|
|
14272
|
-
this.
|
|
14273
|
-
|
|
14598
|
+
|
|
14599
|
+
if (!this.checkCommaAfterRest(closeCharCode)) {
|
|
14600
|
+
this.expect(close);
|
|
14601
|
+
break;
|
|
14602
|
+
}
|
|
14274
14603
|
} else {
|
|
14275
14604
|
var decorators = [];
|
|
14276
14605
|
|
|
14277
14606
|
if (this.match(26) && this.hasPlugin("decorators")) {
|
|
14278
|
-
this.raise(
|
|
14607
|
+
this.raise(ErrorMessages.UnsupportedParameterDecorator, {
|
|
14608
|
+
at: this.state.startLoc
|
|
14609
|
+
});
|
|
14279
14610
|
}
|
|
14280
14611
|
|
|
14281
14612
|
while (this.match(26)) {
|
|
@@ -14358,23 +14689,29 @@
|
|
|
14358
14689
|
} = expr;
|
|
14359
14690
|
|
|
14360
14691
|
if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(name, this.inModule) : isStrictBindOnlyReservedWord(name))) {
|
|
14361
|
-
this.raise(
|
|
14692
|
+
this.raise(bindingType === BIND_NONE ? ErrorMessages.StrictEvalArguments : ErrorMessages.StrictEvalArgumentsBinding, {
|
|
14693
|
+
node: expr
|
|
14694
|
+
}, name);
|
|
14362
14695
|
}
|
|
14363
14696
|
|
|
14364
14697
|
if (checkClashes) {
|
|
14365
14698
|
if (checkClashes.has(name)) {
|
|
14366
|
-
this.raise(
|
|
14699
|
+
this.raise(ErrorMessages.ParamDupe, {
|
|
14700
|
+
node: expr
|
|
14701
|
+
});
|
|
14367
14702
|
} else {
|
|
14368
14703
|
checkClashes.add(name);
|
|
14369
14704
|
}
|
|
14370
14705
|
}
|
|
14371
14706
|
|
|
14372
14707
|
if (disallowLetBinding && name === "let") {
|
|
14373
|
-
this.raise(
|
|
14708
|
+
this.raise(ErrorMessages.LetInLexicalBinding, {
|
|
14709
|
+
node: expr
|
|
14710
|
+
});
|
|
14374
14711
|
}
|
|
14375
14712
|
|
|
14376
14713
|
if (!(bindingType & BIND_NONE)) {
|
|
14377
|
-
this.scope.declareName(name, bindingType, expr.start);
|
|
14714
|
+
this.scope.declareName(name, bindingType, expr.loc.start);
|
|
14378
14715
|
}
|
|
14379
14716
|
|
|
14380
14717
|
break;
|
|
@@ -14382,7 +14719,9 @@
|
|
|
14382
14719
|
|
|
14383
14720
|
case "MemberExpression":
|
|
14384
14721
|
if (bindingType !== BIND_NONE) {
|
|
14385
|
-
this.raise(
|
|
14722
|
+
this.raise(ErrorMessages.InvalidPropertyBindingPattern, {
|
|
14723
|
+
node: expr
|
|
14724
|
+
});
|
|
14386
14725
|
}
|
|
14387
14726
|
|
|
14388
14727
|
break;
|
|
@@ -14418,33 +14757,30 @@
|
|
|
14418
14757
|
|
|
14419
14758
|
default:
|
|
14420
14759
|
{
|
|
14421
|
-
this.raise(
|
|
14760
|
+
this.raise(bindingType === BIND_NONE ? ErrorMessages.InvalidLhs : ErrorMessages.InvalidLhsBinding, {
|
|
14761
|
+
node: expr
|
|
14762
|
+
}, contextDescription);
|
|
14422
14763
|
}
|
|
14423
14764
|
}
|
|
14424
14765
|
}
|
|
14425
14766
|
|
|
14426
14767
|
checkToRestConversion(node) {
|
|
14427
14768
|
if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
|
|
14428
|
-
this.raise(
|
|
14769
|
+
this.raise(ErrorMessages.InvalidRestAssignmentPattern, {
|
|
14770
|
+
node: node.argument
|
|
14771
|
+
});
|
|
14429
14772
|
}
|
|
14430
14773
|
}
|
|
14431
14774
|
|
|
14432
14775
|
checkCommaAfterRest(close) {
|
|
14433
|
-
if (this.match(12)) {
|
|
14434
|
-
|
|
14435
|
-
this.raiseTrailingCommaAfterRest(this.state.start);
|
|
14436
|
-
} else {
|
|
14437
|
-
this.raiseRestNotLast(this.state.start);
|
|
14438
|
-
}
|
|
14776
|
+
if (!this.match(12)) {
|
|
14777
|
+
return false;
|
|
14439
14778
|
}
|
|
14440
|
-
}
|
|
14441
|
-
|
|
14442
|
-
raiseRestNotLast(pos) {
|
|
14443
|
-
throw this.raise(pos, ErrorMessages.ElementAfterRest);
|
|
14444
|
-
}
|
|
14445
14779
|
|
|
14446
|
-
|
|
14447
|
-
|
|
14780
|
+
this.raise(this.lookaheadCharCode() === close ? ErrorMessages.RestTrailingComma : ErrorMessages.ElementAfterRest, {
|
|
14781
|
+
at: this.state.startLoc
|
|
14782
|
+
});
|
|
14783
|
+
return true;
|
|
14448
14784
|
}
|
|
14449
14785
|
|
|
14450
14786
|
}
|
|
@@ -14462,17 +14798,21 @@
|
|
|
14462
14798
|
|
|
14463
14799
|
if (name === "__proto__") {
|
|
14464
14800
|
if (isRecord) {
|
|
14465
|
-
this.raise(
|
|
14801
|
+
this.raise(ErrorMessages.RecordNoProto, {
|
|
14802
|
+
node: key
|
|
14803
|
+
});
|
|
14466
14804
|
return;
|
|
14467
14805
|
}
|
|
14468
14806
|
|
|
14469
14807
|
if (protoRef.used) {
|
|
14470
14808
|
if (refExpressionErrors) {
|
|
14471
|
-
if (refExpressionErrors.
|
|
14472
|
-
refExpressionErrors.
|
|
14809
|
+
if (refExpressionErrors.doubleProtoLoc === null) {
|
|
14810
|
+
refExpressionErrors.doubleProtoLoc = key.loc.start;
|
|
14473
14811
|
}
|
|
14474
14812
|
} else {
|
|
14475
|
-
this.raise(
|
|
14813
|
+
this.raise(ErrorMessages.DuplicateProto, {
|
|
14814
|
+
node: key
|
|
14815
|
+
});
|
|
14476
14816
|
}
|
|
14477
14817
|
}
|
|
14478
14818
|
|
|
@@ -14541,9 +14881,9 @@
|
|
|
14541
14881
|
}
|
|
14542
14882
|
|
|
14543
14883
|
setOptionalParametersError(refExpressionErrors, resultError) {
|
|
14544
|
-
var _resultError$
|
|
14884
|
+
var _resultError$loc;
|
|
14545
14885
|
|
|
14546
|
-
refExpressionErrors.
|
|
14886
|
+
refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
|
|
14547
14887
|
}
|
|
14548
14888
|
|
|
14549
14889
|
parseMaybeAssign(refExpressionErrors, afterLeftParse) {
|
|
@@ -14593,12 +14933,12 @@
|
|
|
14593
14933
|
if (this.match(29)) {
|
|
14594
14934
|
node.left = this.toAssignable(left, true);
|
|
14595
14935
|
|
|
14596
|
-
if (refExpressionErrors.
|
|
14597
|
-
refExpressionErrors.
|
|
14936
|
+
if (refExpressionErrors.doubleProtoLoc != null && indexes.get(refExpressionErrors.doubleProtoLoc) >= startPos) {
|
|
14937
|
+
refExpressionErrors.doubleProtoLoc = null;
|
|
14598
14938
|
}
|
|
14599
14939
|
|
|
14600
|
-
if (refExpressionErrors.
|
|
14601
|
-
refExpressionErrors.
|
|
14940
|
+
if (refExpressionErrors.shorthandAssignLoc != null && indexes.get(refExpressionErrors.shorthandAssignLoc) >= startPos) {
|
|
14941
|
+
refExpressionErrors.shorthandAssignLoc = null;
|
|
14602
14942
|
}
|
|
14603
14943
|
} else {
|
|
14604
14944
|
node.left = left;
|
|
@@ -14661,15 +15001,14 @@
|
|
|
14661
15001
|
parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
|
|
14662
15002
|
if (this.isPrivateName(left)) {
|
|
14663
15003
|
var value = this.getPrivateNameSV(left);
|
|
14664
|
-
var {
|
|
14665
|
-
start
|
|
14666
|
-
} = left;
|
|
14667
15004
|
|
|
14668
15005
|
if (minPrec >= tokenOperatorPrecedence(54) || !this.prodParam.hasIn || !this.match(54)) {
|
|
14669
|
-
this.raise(
|
|
15006
|
+
this.raise(ErrorMessages.PrivateInExpectedIn, {
|
|
15007
|
+
node: left
|
|
15008
|
+
}, value);
|
|
14670
15009
|
}
|
|
14671
15010
|
|
|
14672
|
-
this.classScope.usePrivateName(value, start);
|
|
15011
|
+
this.classScope.usePrivateName(value, left.loc.start);
|
|
14673
15012
|
}
|
|
14674
15013
|
|
|
14675
15014
|
var op = this.state.type;
|
|
@@ -14685,7 +15024,7 @@
|
|
|
14685
15024
|
return left;
|
|
14686
15025
|
}
|
|
14687
15026
|
|
|
14688
|
-
this.checkPipelineAtInfixOperator(left,
|
|
15027
|
+
this.checkPipelineAtInfixOperator(left, leftStartLoc);
|
|
14689
15028
|
}
|
|
14690
15029
|
|
|
14691
15030
|
var node = this.startNodeAt(leftStartPos, leftStartLoc);
|
|
@@ -14704,7 +15043,9 @@
|
|
|
14704
15043
|
proposal: "minimal"
|
|
14705
15044
|
}])) {
|
|
14706
15045
|
if (this.state.type === 92 && this.prodParam.hasAwait) {
|
|
14707
|
-
throw this.raise(
|
|
15046
|
+
throw this.raise(ErrorMessages.UnexpectedAwaitAfterPipelineBody, {
|
|
15047
|
+
at: this.state.startLoc
|
|
15048
|
+
});
|
|
14708
15049
|
}
|
|
14709
15050
|
}
|
|
14710
15051
|
|
|
@@ -14713,7 +15054,9 @@
|
|
|
14713
15054
|
var nextOp = this.state.type;
|
|
14714
15055
|
|
|
14715
15056
|
if (coalesce && (nextOp === 39 || nextOp === 40) || logical && nextOp === 38) {
|
|
14716
|
-
throw this.raise(
|
|
15057
|
+
throw this.raise(ErrorMessages.MixingCoalesceWithLogical, {
|
|
15058
|
+
at: this.state.startLoc
|
|
15059
|
+
});
|
|
14717
15060
|
}
|
|
14718
15061
|
|
|
14719
15062
|
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
|
|
@@ -14738,7 +15081,9 @@
|
|
|
14738
15081
|
case "smart":
|
|
14739
15082
|
return this.withTopicBindingContext(() => {
|
|
14740
15083
|
if (this.prodParam.hasYield && this.isContextual(101)) {
|
|
14741
|
-
throw this.raise(
|
|
15084
|
+
throw this.raise(ErrorMessages.PipeBodyIsTighter, {
|
|
15085
|
+
at: this.state.startLoc
|
|
15086
|
+
}, this.state.value);
|
|
14742
15087
|
}
|
|
14743
15088
|
|
|
14744
15089
|
return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startPos, startLoc);
|
|
@@ -14765,16 +15110,20 @@
|
|
|
14765
15110
|
var _body$extra;
|
|
14766
15111
|
|
|
14767
15112
|
var {
|
|
14768
|
-
|
|
15113
|
+
startLoc
|
|
14769
15114
|
} = this.state;
|
|
14770
15115
|
var body = this.parseMaybeAssign();
|
|
14771
15116
|
|
|
14772
15117
|
if (invalidHackPipeBodies.has(body.type) && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
|
|
14773
|
-
this.raise(
|
|
15118
|
+
this.raise(ErrorMessages.PipeUnparenthesizedBody, {
|
|
15119
|
+
at: startLoc
|
|
15120
|
+
}, invalidHackPipeBodies.get(body.type));
|
|
14774
15121
|
}
|
|
14775
15122
|
|
|
14776
15123
|
if (!this.topicReferenceWasUsedInCurrentContext()) {
|
|
14777
|
-
this.raise(
|
|
15124
|
+
this.raise(ErrorMessages.PipeTopicUnused, {
|
|
15125
|
+
at: startLoc
|
|
15126
|
+
});
|
|
14778
15127
|
}
|
|
14779
15128
|
|
|
14780
15129
|
return body;
|
|
@@ -14782,7 +15131,9 @@
|
|
|
14782
15131
|
|
|
14783
15132
|
checkExponentialAfterUnary(node) {
|
|
14784
15133
|
if (this.match(53)) {
|
|
14785
|
-
this.raise(
|
|
15134
|
+
this.raise(ErrorMessages.UnexpectedTokenUnaryExponentiation, {
|
|
15135
|
+
node: node.argument
|
|
15136
|
+
});
|
|
14786
15137
|
}
|
|
14787
15138
|
}
|
|
14788
15139
|
|
|
@@ -14820,9 +15171,13 @@
|
|
|
14820
15171
|
var arg = node.argument;
|
|
14821
15172
|
|
|
14822
15173
|
if (arg.type === "Identifier") {
|
|
14823
|
-
this.raise(
|
|
15174
|
+
this.raise(ErrorMessages.StrictDelete, {
|
|
15175
|
+
node
|
|
15176
|
+
});
|
|
14824
15177
|
} else if (this.hasPropertyAsPrivateName(arg)) {
|
|
14825
|
-
this.raise(
|
|
15178
|
+
this.raise(ErrorMessages.DeletePrivateField, {
|
|
15179
|
+
node
|
|
15180
|
+
});
|
|
14826
15181
|
}
|
|
14827
15182
|
}
|
|
14828
15183
|
|
|
@@ -14842,7 +15197,7 @@
|
|
|
14842
15197
|
var _startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(50);
|
|
14843
15198
|
|
|
14844
15199
|
if (_startsExpr && !this.isAmbiguousAwait()) {
|
|
14845
|
-
this.raiseOverwrite(
|
|
15200
|
+
this.raiseOverwrite(startLoc, ErrorMessages.AwaitNotInAsyncContext);
|
|
14846
15201
|
return this.parseAwait(startPos, startLoc);
|
|
14847
15202
|
}
|
|
14848
15203
|
}
|
|
@@ -14950,10 +15305,12 @@
|
|
|
14950
15305
|
this.expect(3);
|
|
14951
15306
|
} else if (this.match(130)) {
|
|
14952
15307
|
if (base.type === "Super") {
|
|
14953
|
-
this.raise(
|
|
15308
|
+
this.raise(ErrorMessages.SuperPrivateField, {
|
|
15309
|
+
at: startLoc
|
|
15310
|
+
});
|
|
14954
15311
|
}
|
|
14955
15312
|
|
|
14956
|
-
this.classScope.usePrivateName(this.state.value, this.state.
|
|
15313
|
+
this.classScope.usePrivateName(this.state.value, this.state.startLoc);
|
|
14957
15314
|
node.property = this.parsePrivateName();
|
|
14958
15315
|
} else {
|
|
14959
15316
|
node.property = this.parseIdentifier(true);
|
|
@@ -15029,14 +15386,16 @@
|
|
|
15029
15386
|
node.quasi = this.parseTemplate(true);
|
|
15030
15387
|
|
|
15031
15388
|
if (state.optionalChainMember) {
|
|
15032
|
-
this.raise(
|
|
15389
|
+
this.raise(ErrorMessages.OptionalChainingNoTemplate, {
|
|
15390
|
+
at: startLoc
|
|
15391
|
+
});
|
|
15033
15392
|
}
|
|
15034
15393
|
|
|
15035
15394
|
return this.finishNode(node, "TaggedTemplateExpression");
|
|
15036
15395
|
}
|
|
15037
15396
|
|
|
15038
15397
|
atPossibleAsyncArrow(base) {
|
|
15039
|
-
return base.type === "Identifier" && base.name === "async" && this.state.
|
|
15398
|
+
return base.type === "Identifier" && base.name === "async" && indexes.get(this.state.lastTokEndLoc) === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt;
|
|
15040
15399
|
}
|
|
15041
15400
|
|
|
15042
15401
|
finishCallExpression(node, optional) {
|
|
@@ -15050,11 +15409,15 @@
|
|
|
15050
15409
|
}
|
|
15051
15410
|
|
|
15052
15411
|
if (node.arguments.length === 0 || node.arguments.length > 2) {
|
|
15053
|
-
this.raise(
|
|
15412
|
+
this.raise(ErrorMessages.ImportCallArity, {
|
|
15413
|
+
node
|
|
15414
|
+
}, this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? "one or two arguments" : "one argument");
|
|
15054
15415
|
} else {
|
|
15055
15416
|
for (var arg of node.arguments) {
|
|
15056
15417
|
if (arg.type === "SpreadElement") {
|
|
15057
|
-
this.raise(
|
|
15418
|
+
this.raise(ErrorMessages.ImportCallSpreadArgument, {
|
|
15419
|
+
node: arg
|
|
15420
|
+
});
|
|
15058
15421
|
}
|
|
15059
15422
|
}
|
|
15060
15423
|
}
|
|
@@ -15077,11 +15440,13 @@
|
|
|
15077
15440
|
|
|
15078
15441
|
if (this.match(close)) {
|
|
15079
15442
|
if (dynamicImport && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
|
|
15080
|
-
this.raise(
|
|
15443
|
+
this.raise(ErrorMessages.ImportCallArgumentTrailingComma, {
|
|
15444
|
+
at: this.state.lastTokStartLoc
|
|
15445
|
+
});
|
|
15081
15446
|
}
|
|
15082
15447
|
|
|
15083
15448
|
if (nodeForExtra) {
|
|
15084
|
-
this.
|
|
15449
|
+
this.addTrailingCommaExtraToNode(nodeForExtra);
|
|
15085
15450
|
}
|
|
15086
15451
|
|
|
15087
15452
|
this.next();
|
|
@@ -15105,7 +15470,7 @@
|
|
|
15105
15470
|
|
|
15106
15471
|
this.resetPreviousNodeTrailingComments(call);
|
|
15107
15472
|
this.expect(19);
|
|
15108
|
-
this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.
|
|
15473
|
+
this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
|
|
15109
15474
|
|
|
15110
15475
|
if (call.innerComments) {
|
|
15111
15476
|
setInnerComments(node, call.innerComments);
|
|
@@ -15143,7 +15508,9 @@
|
|
|
15143
15508
|
}
|
|
15144
15509
|
|
|
15145
15510
|
if (!this.match(10)) {
|
|
15146
|
-
this.raise(
|
|
15511
|
+
this.raise(ErrorMessages.UnsupportedImport, {
|
|
15512
|
+
at: this.state.lastTokStartLoc
|
|
15513
|
+
});
|
|
15147
15514
|
}
|
|
15148
15515
|
|
|
15149
15516
|
return this.finishNode(node, "Import");
|
|
@@ -15242,13 +15609,17 @@
|
|
|
15242
15609
|
if (callee.type === "MemberExpression") {
|
|
15243
15610
|
return this.finishNode(node, "BindExpression");
|
|
15244
15611
|
} else {
|
|
15245
|
-
throw this.raise(
|
|
15612
|
+
throw this.raise(ErrorMessages.UnsupportedBind, {
|
|
15613
|
+
node: callee
|
|
15614
|
+
});
|
|
15246
15615
|
}
|
|
15247
15616
|
}
|
|
15248
15617
|
|
|
15249
15618
|
case 130:
|
|
15250
15619
|
{
|
|
15251
|
-
this.raise(
|
|
15620
|
+
this.raise(ErrorMessages.PrivateInExpectedIn, {
|
|
15621
|
+
at: this.state.startLoc
|
|
15622
|
+
}, this.state.value);
|
|
15252
15623
|
return this.parsePrivateName();
|
|
15253
15624
|
}
|
|
15254
15625
|
|
|
@@ -15340,7 +15711,7 @@
|
|
|
15340
15711
|
this.state.value = topicTokenValue;
|
|
15341
15712
|
this.state.pos--;
|
|
15342
15713
|
this.state.end--;
|
|
15343
|
-
this.state.endLoc.
|
|
15714
|
+
this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
|
|
15344
15715
|
return this.parseTopicReference(pipeProposal);
|
|
15345
15716
|
} else {
|
|
15346
15717
|
throw this.unexpected();
|
|
@@ -15349,38 +15720,32 @@
|
|
|
15349
15720
|
|
|
15350
15721
|
parseTopicReference(pipeProposal) {
|
|
15351
15722
|
var node = this.startNode();
|
|
15352
|
-
var
|
|
15723
|
+
var startLoc = this.state.startLoc;
|
|
15353
15724
|
var tokenType = this.state.type;
|
|
15354
15725
|
this.next();
|
|
15355
|
-
return this.finishTopicReference(node,
|
|
15726
|
+
return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
|
|
15356
15727
|
}
|
|
15357
15728
|
|
|
15358
|
-
finishTopicReference(node,
|
|
15359
|
-
if (this.testTopicReferenceConfiguration(pipeProposal,
|
|
15360
|
-
var nodeType;
|
|
15361
|
-
|
|
15362
|
-
if (pipeProposal === "smart") {
|
|
15363
|
-
nodeType = "PipelinePrimaryTopicReference";
|
|
15364
|
-
} else {
|
|
15365
|
-
nodeType = "TopicReference";
|
|
15366
|
-
}
|
|
15729
|
+
finishTopicReference(node, startLoc, pipeProposal, tokenType) {
|
|
15730
|
+
if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
|
|
15731
|
+
var nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
|
|
15367
15732
|
|
|
15368
15733
|
if (!this.topicReferenceIsAllowedInCurrentContext()) {
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
}
|
|
15372
|
-
this.raise(start, ErrorMessages.PipeTopicUnbound);
|
|
15373
|
-
}
|
|
15734
|
+
this.raise(pipeProposal === "smart" ? ErrorMessages.PrimaryTopicNotAllowed : ErrorMessages.PipeTopicUnbound, {
|
|
15735
|
+
at: startLoc
|
|
15736
|
+
});
|
|
15374
15737
|
}
|
|
15375
15738
|
|
|
15376
15739
|
this.registerTopicReference();
|
|
15377
15740
|
return this.finishNode(node, nodeType);
|
|
15378
15741
|
} else {
|
|
15379
|
-
throw this.raise(
|
|
15742
|
+
throw this.raise(ErrorMessages.PipeTopicUnconfiguredToken, {
|
|
15743
|
+
at: startLoc
|
|
15744
|
+
}, tokenLabelName(tokenType));
|
|
15380
15745
|
}
|
|
15381
15746
|
}
|
|
15382
15747
|
|
|
15383
|
-
testTopicReferenceConfiguration(pipeProposal,
|
|
15748
|
+
testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
|
|
15384
15749
|
switch (pipeProposal) {
|
|
15385
15750
|
case "hack":
|
|
15386
15751
|
{
|
|
@@ -15393,7 +15758,9 @@
|
|
|
15393
15758
|
return tokenType === 27;
|
|
15394
15759
|
|
|
15395
15760
|
default:
|
|
15396
|
-
throw this.raise(
|
|
15761
|
+
throw this.raise(ErrorMessages.PipeTopicRequiresHackPipes, {
|
|
15762
|
+
at: startLoc
|
|
15763
|
+
});
|
|
15397
15764
|
}
|
|
15398
15765
|
}
|
|
15399
15766
|
|
|
@@ -15403,7 +15770,9 @@
|
|
|
15403
15770
|
this.prodParam.exit();
|
|
15404
15771
|
|
|
15405
15772
|
if (this.hasPrecedingLineBreak()) {
|
|
15406
|
-
this.raise(
|
|
15773
|
+
this.raise(ErrorMessages.LineTerminatorBeforeArrow, {
|
|
15774
|
+
at: this.state.curPosition()
|
|
15775
|
+
});
|
|
15407
15776
|
}
|
|
15408
15777
|
|
|
15409
15778
|
this.expect(19);
|
|
@@ -15440,13 +15809,19 @@
|
|
|
15440
15809
|
this.next();
|
|
15441
15810
|
|
|
15442
15811
|
if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
|
|
15443
|
-
this.raise(
|
|
15812
|
+
this.raise(ErrorMessages.SuperNotAllowed, {
|
|
15813
|
+
node
|
|
15814
|
+
});
|
|
15444
15815
|
} else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
|
|
15445
|
-
this.raise(
|
|
15816
|
+
this.raise(ErrorMessages.UnexpectedSuper, {
|
|
15817
|
+
node
|
|
15818
|
+
});
|
|
15446
15819
|
}
|
|
15447
15820
|
|
|
15448
15821
|
if (!this.match(10) && !this.match(0) && !this.match(16)) {
|
|
15449
|
-
this.raise(
|
|
15822
|
+
this.raise(ErrorMessages.UnsupportedSuper, {
|
|
15823
|
+
node
|
|
15824
|
+
});
|
|
15450
15825
|
}
|
|
15451
15826
|
|
|
15452
15827
|
return this.finishNode(node, "Super");
|
|
@@ -15454,7 +15829,7 @@
|
|
|
15454
15829
|
|
|
15455
15830
|
parsePrivateName() {
|
|
15456
15831
|
var node = this.startNode();
|
|
15457
|
-
var id = this.startNodeAt(this.state.start + 1, new Position(this.state.curLine, this.state.start + 1 - this.state.lineStart));
|
|
15832
|
+
var id = this.startNodeAt(this.state.start + 1, new Position(this.state.curLine, this.state.start + 1 - this.state.lineStart, this.state.start + 1));
|
|
15458
15833
|
var name = this.state.value;
|
|
15459
15834
|
this.next();
|
|
15460
15835
|
node.id = this.createIdentifier(id, name);
|
|
@@ -15487,7 +15862,9 @@
|
|
|
15487
15862
|
node.property = this.parseIdentifier(true);
|
|
15488
15863
|
|
|
15489
15864
|
if (node.property.name !== propertyName || containsEsc) {
|
|
15490
|
-
this.raise(
|
|
15865
|
+
this.raise(ErrorMessages.UnsupportedMetaProperty, {
|
|
15866
|
+
node: node.property
|
|
15867
|
+
}, meta.name, propertyName);
|
|
15491
15868
|
}
|
|
15492
15869
|
|
|
15493
15870
|
return this.finishNode(node, "MetaProperty");
|
|
@@ -15499,7 +15876,9 @@
|
|
|
15499
15876
|
|
|
15500
15877
|
if (this.isContextual(96)) {
|
|
15501
15878
|
if (!this.inModule) {
|
|
15502
|
-
this.raise(
|
|
15879
|
+
this.raise(SourceTypeModuleErrorMessages.ImportMetaOutsideModule, {
|
|
15880
|
+
node: id
|
|
15881
|
+
});
|
|
15503
15882
|
}
|
|
15504
15883
|
|
|
15505
15884
|
this.sawUnambiguousESM = true;
|
|
@@ -15572,17 +15951,17 @@
|
|
|
15572
15951
|
var exprList = [];
|
|
15573
15952
|
var refExpressionErrors = new ExpressionErrors();
|
|
15574
15953
|
var first = true;
|
|
15575
|
-
var
|
|
15576
|
-
var
|
|
15954
|
+
var spreadStartLoc;
|
|
15955
|
+
var optionalCommaStartLoc;
|
|
15577
15956
|
|
|
15578
15957
|
while (!this.match(11)) {
|
|
15579
15958
|
if (first) {
|
|
15580
15959
|
first = false;
|
|
15581
15960
|
} else {
|
|
15582
|
-
this.expect(12, refExpressionErrors.
|
|
15961
|
+
this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
|
|
15583
15962
|
|
|
15584
15963
|
if (this.match(11)) {
|
|
15585
|
-
|
|
15964
|
+
optionalCommaStartLoc = this.state.startLoc;
|
|
15586
15965
|
break;
|
|
15587
15966
|
}
|
|
15588
15967
|
}
|
|
@@ -15590,16 +15969,17 @@
|
|
|
15590
15969
|
if (this.match(21)) {
|
|
15591
15970
|
var spreadNodeStartPos = this.state.start;
|
|
15592
15971
|
var spreadNodeStartLoc = this.state.startLoc;
|
|
15593
|
-
|
|
15972
|
+
spreadStartLoc = this.state.startLoc;
|
|
15594
15973
|
exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc));
|
|
15595
|
-
|
|
15596
|
-
|
|
15974
|
+
|
|
15975
|
+
if (!this.checkCommaAfterRest(41)) {
|
|
15976
|
+
break;
|
|
15977
|
+
}
|
|
15597
15978
|
} else {
|
|
15598
15979
|
exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
|
|
15599
15980
|
}
|
|
15600
15981
|
}
|
|
15601
15982
|
|
|
15602
|
-
var innerEndPos = this.state.lastTokEnd;
|
|
15603
15983
|
var innerEndLoc = this.state.lastTokEndLoc;
|
|
15604
15984
|
this.expect(11);
|
|
15605
15985
|
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
@@ -15616,11 +15996,11 @@
|
|
|
15616
15996
|
this.expressionScope.exit();
|
|
15617
15997
|
|
|
15618
15998
|
if (!exprList.length) {
|
|
15619
|
-
this.unexpected(this.state.
|
|
15999
|
+
this.unexpected(this.state.lastTokStartLoc);
|
|
15620
16000
|
}
|
|
15621
16001
|
|
|
15622
|
-
if (
|
|
15623
|
-
if (
|
|
16002
|
+
if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
|
|
16003
|
+
if (spreadStartLoc) this.unexpected(spreadStartLoc);
|
|
15624
16004
|
this.checkExpressionErrors(refExpressionErrors, true);
|
|
15625
16005
|
this.toReferencedListDeep(exprList, true);
|
|
15626
16006
|
|
|
@@ -15628,7 +16008,7 @@
|
|
|
15628
16008
|
val = this.startNodeAt(innerStartPos, innerStartLoc);
|
|
15629
16009
|
val.expressions = exprList;
|
|
15630
16010
|
this.finishNode(val, "SequenceExpression");
|
|
15631
|
-
this.resetEndLocation(val,
|
|
16011
|
+
this.resetEndLocation(val, innerEndLoc);
|
|
15632
16012
|
} else {
|
|
15633
16013
|
val = exprList[0];
|
|
15634
16014
|
}
|
|
@@ -15636,7 +16016,7 @@
|
|
|
15636
16016
|
if (!this.options.createParenthesizedExpressions) {
|
|
15637
16017
|
this.addExtra(val, "parenthesized", true);
|
|
15638
16018
|
this.addExtra(val, "parenStart", startPos);
|
|
15639
|
-
this.takeSurroundingComments(val, startPos, this.state.
|
|
16019
|
+
this.takeSurroundingComments(val, startPos, indexes.get(this.state.lastTokEndLoc));
|
|
15640
16020
|
return val;
|
|
15641
16021
|
}
|
|
15642
16022
|
|
|
@@ -15670,7 +16050,9 @@
|
|
|
15670
16050
|
var metaProp = this.parseMetaProperty(node, meta, "target");
|
|
15671
16051
|
|
|
15672
16052
|
if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
|
|
15673
|
-
this.raise(
|
|
16053
|
+
this.raise(ErrorMessages.UnexpectedNewTarget, {
|
|
16054
|
+
node: metaProp
|
|
16055
|
+
});
|
|
15674
16056
|
}
|
|
15675
16057
|
|
|
15676
16058
|
return metaProp;
|
|
@@ -15683,11 +16065,17 @@
|
|
|
15683
16065
|
node.callee = this.parseNoCallExpr();
|
|
15684
16066
|
|
|
15685
16067
|
if (node.callee.type === "Import") {
|
|
15686
|
-
this.raise(
|
|
16068
|
+
this.raise(ErrorMessages.ImportCallNotNewExpression, {
|
|
16069
|
+
node: node.callee
|
|
16070
|
+
});
|
|
15687
16071
|
} else if (this.isOptionalChain(node.callee)) {
|
|
15688
|
-
this.raise(
|
|
16072
|
+
this.raise(ErrorMessages.OptionalChainingNoNew, {
|
|
16073
|
+
at: this.state.lastTokEndLoc
|
|
16074
|
+
});
|
|
15689
16075
|
} else if (this.eat(18)) {
|
|
15690
|
-
this.raise(
|
|
16076
|
+
this.raise(ErrorMessages.OptionalChainingNoNew, {
|
|
16077
|
+
at: this.state.startLoc
|
|
16078
|
+
});
|
|
15691
16079
|
}
|
|
15692
16080
|
|
|
15693
16081
|
this.parseNewArguments(node);
|
|
@@ -15707,15 +16095,18 @@
|
|
|
15707
16095
|
parseTemplateElement(isTagged) {
|
|
15708
16096
|
var {
|
|
15709
16097
|
start,
|
|
16098
|
+
startLoc,
|
|
15710
16099
|
end,
|
|
15711
16100
|
value
|
|
15712
16101
|
} = this.state;
|
|
15713
16102
|
var elemStart = start + 1;
|
|
15714
|
-
var elem = this.startNodeAt(elemStart, createPositionWithColumnOffset(
|
|
16103
|
+
var elem = this.startNodeAt(elemStart, createPositionWithColumnOffset(startLoc, 1));
|
|
15715
16104
|
|
|
15716
16105
|
if (value === null) {
|
|
15717
16106
|
if (!isTagged) {
|
|
15718
|
-
this.raise(
|
|
16107
|
+
this.raise(ErrorMessages.InvalidEscapeSequenceTemplate, {
|
|
16108
|
+
at: createPositionWithColumnOffset(startLoc, 2)
|
|
16109
|
+
});
|
|
15719
16110
|
}
|
|
15720
16111
|
}
|
|
15721
16112
|
|
|
@@ -15729,7 +16120,7 @@
|
|
|
15729
16120
|
elem.tail = isTail;
|
|
15730
16121
|
this.next();
|
|
15731
16122
|
this.finishNode(elem, "TemplateElement");
|
|
15732
|
-
this.resetEndLocation(elem,
|
|
16123
|
+
this.resetEndLocation(elem, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
|
|
15733
16124
|
return elem;
|
|
15734
16125
|
}
|
|
15735
16126
|
|
|
@@ -15772,7 +16163,7 @@
|
|
|
15772
16163
|
this.expect(12);
|
|
15773
16164
|
|
|
15774
16165
|
if (this.match(close)) {
|
|
15775
|
-
this.
|
|
16166
|
+
this.addTrailingCommaExtraToNode(node);
|
|
15776
16167
|
break;
|
|
15777
16168
|
}
|
|
15778
16169
|
}
|
|
@@ -15787,7 +16178,9 @@
|
|
|
15787
16178
|
}
|
|
15788
16179
|
|
|
15789
16180
|
if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
|
|
15790
|
-
this.raise(
|
|
16181
|
+
this.raise(ErrorMessages.InvalidRecordProperty, {
|
|
16182
|
+
node: prop
|
|
16183
|
+
});
|
|
15791
16184
|
}
|
|
15792
16185
|
|
|
15793
16186
|
if (prop.shorthand) {
|
|
@@ -15810,6 +16203,11 @@
|
|
|
15810
16203
|
return this.finishNode(node, type);
|
|
15811
16204
|
}
|
|
15812
16205
|
|
|
16206
|
+
addTrailingCommaExtraToNode(node) {
|
|
16207
|
+
this.addExtra(node, "trailingComma", this.state.lastTokStart);
|
|
16208
|
+
this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
|
|
16209
|
+
}
|
|
16210
|
+
|
|
15813
16211
|
maybeAsyncOrAccessorProp(prop) {
|
|
15814
16212
|
return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(51));
|
|
15815
16213
|
}
|
|
@@ -15819,7 +16217,9 @@
|
|
|
15819
16217
|
|
|
15820
16218
|
if (this.match(26)) {
|
|
15821
16219
|
if (this.hasPlugin("decorators")) {
|
|
15822
|
-
this.raise(
|
|
16220
|
+
this.raise(ErrorMessages.UnsupportedPropertyDecorator, {
|
|
16221
|
+
at: this.state.startLoc
|
|
16222
|
+
});
|
|
15823
16223
|
}
|
|
15824
16224
|
|
|
15825
16225
|
while (this.match(26)) {
|
|
@@ -15872,7 +16272,9 @@
|
|
|
15872
16272
|
|
|
15873
16273
|
if (this.match(51)) {
|
|
15874
16274
|
isGenerator = true;
|
|
15875
|
-
this.raise(
|
|
16275
|
+
this.raise(ErrorMessages.AccessorIsGenerator, {
|
|
16276
|
+
at: this.state.curPosition()
|
|
16277
|
+
}, keyName);
|
|
15876
16278
|
this.next();
|
|
15877
16279
|
}
|
|
15878
16280
|
|
|
@@ -15897,18 +16299,17 @@
|
|
|
15897
16299
|
|
|
15898
16300
|
var paramCount = this.getGetterSetterExpectedParamCount(method);
|
|
15899
16301
|
var params = this.getObjectOrClassMethodParams(method);
|
|
15900
|
-
var start = method.start;
|
|
15901
16302
|
|
|
15902
16303
|
if (params.length !== paramCount) {
|
|
15903
|
-
|
|
15904
|
-
|
|
15905
|
-
}
|
|
15906
|
-
this.raise(start, ErrorMessages.BadSetterArity);
|
|
15907
|
-
}
|
|
16304
|
+
this.raise(method.kind === "get" ? ErrorMessages.BadGetterArity : ErrorMessages.BadSetterArity, {
|
|
16305
|
+
node: method
|
|
16306
|
+
});
|
|
15908
16307
|
}
|
|
15909
16308
|
|
|
15910
16309
|
if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
|
|
15911
|
-
this.raise(
|
|
16310
|
+
this.raise(ErrorMessages.BadSetterRestParameter, {
|
|
16311
|
+
node: method
|
|
16312
|
+
});
|
|
15912
16313
|
}
|
|
15913
16314
|
}
|
|
15914
16315
|
|
|
@@ -15936,19 +16337,21 @@
|
|
|
15936
16337
|
}
|
|
15937
16338
|
|
|
15938
16339
|
if (!prop.computed && prop.key.type === "Identifier") {
|
|
15939
|
-
this.checkReservedWord(prop.key.name, prop.key.start, true, false);
|
|
16340
|
+
this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
|
|
15940
16341
|
|
|
15941
16342
|
if (isPattern) {
|
|
15942
16343
|
prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
|
|
15943
16344
|
} else if (this.match(29)) {
|
|
15944
|
-
var
|
|
16345
|
+
var shorthandAssignLoc = this.state.startLoc;
|
|
15945
16346
|
|
|
15946
16347
|
if (refExpressionErrors != null) {
|
|
15947
|
-
if (refExpressionErrors.
|
|
15948
|
-
refExpressionErrors.
|
|
16348
|
+
if (refExpressionErrors.shorthandAssignLoc === null) {
|
|
16349
|
+
refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
|
|
15949
16350
|
}
|
|
15950
16351
|
} else {
|
|
15951
|
-
this.raise(
|
|
16352
|
+
this.raise(ErrorMessages.InvalidCoverInitializedName, {
|
|
16353
|
+
at: shorthandAssignLoc
|
|
16354
|
+
});
|
|
15952
16355
|
}
|
|
15953
16356
|
|
|
15954
16357
|
prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
|
|
@@ -16001,8 +16404,9 @@
|
|
|
16001
16404
|
|
|
16002
16405
|
case 130:
|
|
16003
16406
|
{
|
|
16004
|
-
|
|
16005
|
-
|
|
16407
|
+
this.raise(ErrorMessages.UnexpectedPrivateField, {
|
|
16408
|
+
at: createPositionWithColumnOffset(this.state.startLoc, 1)
|
|
16409
|
+
});
|
|
16006
16410
|
key = this.parsePrivateName();
|
|
16007
16411
|
break;
|
|
16008
16412
|
}
|
|
@@ -16056,11 +16460,11 @@
|
|
|
16056
16460
|
return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
|
|
16057
16461
|
}
|
|
16058
16462
|
|
|
16059
|
-
parseArrowExpression(node, params, isAsync,
|
|
16463
|
+
parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
|
|
16060
16464
|
this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
|
|
16061
16465
|
var flags = functionFlags(isAsync, false);
|
|
16062
16466
|
|
|
16063
|
-
if (!this.match(
|
|
16467
|
+
if (!this.match(5) && this.prodParam.hasIn) {
|
|
16064
16468
|
flags |= PARAM_IN;
|
|
16065
16469
|
}
|
|
16066
16470
|
|
|
@@ -16070,7 +16474,7 @@
|
|
|
16070
16474
|
|
|
16071
16475
|
if (params) {
|
|
16072
16476
|
this.state.maybeInArrowParameters = true;
|
|
16073
|
-
this.setArrowFunctionParameters(node, params,
|
|
16477
|
+
this.setArrowFunctionParameters(node, params, trailingCommaLoc);
|
|
16074
16478
|
}
|
|
16075
16479
|
|
|
16076
16480
|
this.state.maybeInArrowParameters = false;
|
|
@@ -16081,8 +16485,8 @@
|
|
|
16081
16485
|
return this.finishNode(node, "ArrowFunctionExpression");
|
|
16082
16486
|
}
|
|
16083
16487
|
|
|
16084
|
-
setArrowFunctionParameters(node, params,
|
|
16085
|
-
node.params = this.toAssignableList(params,
|
|
16488
|
+
setArrowFunctionParameters(node, params, trailingCommaLoc) {
|
|
16489
|
+
node.params = this.toAssignableList(params, trailingCommaLoc, false);
|
|
16086
16490
|
}
|
|
16087
16491
|
|
|
16088
16492
|
parseFunctionBodyAndFinish(node, type) {
|
|
@@ -16108,8 +16512,12 @@
|
|
|
16108
16512
|
var nonSimple = !this.isSimpleParamList(node.params);
|
|
16109
16513
|
|
|
16110
16514
|
if (hasStrictModeDirective && nonSimple) {
|
|
16111
|
-
var
|
|
16112
|
-
|
|
16515
|
+
var errorOrigin = (node.kind === "method" || node.kind === "constructor") && !!node.key ? {
|
|
16516
|
+
at: node.key.loc.end
|
|
16517
|
+
} : {
|
|
16518
|
+
node
|
|
16519
|
+
};
|
|
16520
|
+
this.raise(ErrorMessages.IllegalLanguageModeDirective, errorOrigin);
|
|
16113
16521
|
}
|
|
16114
16522
|
|
|
16115
16523
|
var strictModeChanged = !oldStrict && this.state.strict;
|
|
@@ -16155,7 +16563,7 @@
|
|
|
16155
16563
|
|
|
16156
16564
|
if (this.match(close)) {
|
|
16157
16565
|
if (nodeForExtra) {
|
|
16158
|
-
this.
|
|
16566
|
+
this.addTrailingCommaExtraToNode(nodeForExtra);
|
|
16159
16567
|
}
|
|
16160
16568
|
|
|
16161
16569
|
this.next();
|
|
@@ -16174,7 +16582,9 @@
|
|
|
16174
16582
|
|
|
16175
16583
|
if (this.match(12)) {
|
|
16176
16584
|
if (!allowEmpty) {
|
|
16177
|
-
this.raise(
|
|
16585
|
+
this.raise(ErrorMessages.UnexpectedToken, {
|
|
16586
|
+
at: this.state.curPosition()
|
|
16587
|
+
}, ",");
|
|
16178
16588
|
}
|
|
16179
16589
|
|
|
16180
16590
|
elt = null;
|
|
@@ -16186,7 +16596,9 @@
|
|
|
16186
16596
|
this.expectPlugin("partialApplication");
|
|
16187
16597
|
|
|
16188
16598
|
if (!allowPlaceholder) {
|
|
16189
|
-
this.raise(
|
|
16599
|
+
this.raise(ErrorMessages.UnexpectedArgumentPlaceholder, {
|
|
16600
|
+
at: this.state.startLoc
|
|
16601
|
+
});
|
|
16190
16602
|
}
|
|
16191
16603
|
|
|
16192
16604
|
var node = this.startNode();
|
|
@@ -16214,7 +16626,7 @@
|
|
|
16214
16626
|
parseIdentifierName(pos, liberal) {
|
|
16215
16627
|
var name;
|
|
16216
16628
|
var {
|
|
16217
|
-
|
|
16629
|
+
startLoc,
|
|
16218
16630
|
type
|
|
16219
16631
|
} = this.state;
|
|
16220
16632
|
|
|
@@ -16231,7 +16643,7 @@
|
|
|
16231
16643
|
this.replaceToken(124);
|
|
16232
16644
|
}
|
|
16233
16645
|
} else {
|
|
16234
|
-
this.checkReservedWord(name,
|
|
16646
|
+
this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
|
|
16235
16647
|
}
|
|
16236
16648
|
|
|
16237
16649
|
this.next();
|
|
@@ -16249,35 +16661,49 @@
|
|
|
16249
16661
|
|
|
16250
16662
|
if (word === "yield") {
|
|
16251
16663
|
if (this.prodParam.hasYield) {
|
|
16252
|
-
this.raise(
|
|
16664
|
+
this.raise(ErrorMessages.YieldBindingIdentifier, {
|
|
16665
|
+
at: startLoc
|
|
16666
|
+
});
|
|
16253
16667
|
return;
|
|
16254
16668
|
}
|
|
16255
16669
|
} else if (word === "await") {
|
|
16256
16670
|
if (this.prodParam.hasAwait) {
|
|
16257
|
-
this.raise(
|
|
16671
|
+
this.raise(ErrorMessages.AwaitBindingIdentifier, {
|
|
16672
|
+
at: startLoc
|
|
16673
|
+
});
|
|
16258
16674
|
return;
|
|
16259
|
-
}
|
|
16260
|
-
|
|
16675
|
+
}
|
|
16676
|
+
|
|
16677
|
+
if (this.scope.inStaticBlock) {
|
|
16678
|
+
this.raise(ErrorMessages.AwaitBindingIdentifierInStaticBlock, {
|
|
16679
|
+
at: startLoc
|
|
16680
|
+
});
|
|
16261
16681
|
return;
|
|
16262
|
-
} else {
|
|
16263
|
-
this.expressionScope.recordAsyncArrowParametersError(startLoc, ErrorMessages.AwaitBindingIdentifier);
|
|
16264
16682
|
}
|
|
16683
|
+
|
|
16684
|
+
this.expressionScope.recordAsyncArrowParametersError(ErrorMessages.AwaitBindingIdentifier, startLoc);
|
|
16265
16685
|
} else if (word === "arguments") {
|
|
16266
16686
|
if (this.scope.inClassAndNotInNonArrowFunction) {
|
|
16267
|
-
this.raise(
|
|
16687
|
+
this.raise(ErrorMessages.ArgumentsInClass, {
|
|
16688
|
+
at: startLoc
|
|
16689
|
+
});
|
|
16268
16690
|
return;
|
|
16269
16691
|
}
|
|
16270
16692
|
}
|
|
16271
16693
|
|
|
16272
16694
|
if (checkKeywords && isKeyword(word)) {
|
|
16273
|
-
this.raise(
|
|
16695
|
+
this.raise(ErrorMessages.UnexpectedKeyword, {
|
|
16696
|
+
at: startLoc
|
|
16697
|
+
}, word);
|
|
16274
16698
|
return;
|
|
16275
16699
|
}
|
|
16276
16700
|
|
|
16277
16701
|
var reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
|
|
16278
16702
|
|
|
16279
16703
|
if (reservedTest(word, this.inModule)) {
|
|
16280
|
-
this.raise(
|
|
16704
|
+
this.raise(ErrorMessages.UnexpectedReservedWord, {
|
|
16705
|
+
at: startLoc
|
|
16706
|
+
}, word);
|
|
16281
16707
|
}
|
|
16282
16708
|
}
|
|
16283
16709
|
|
|
@@ -16293,10 +16719,12 @@
|
|
|
16293
16719
|
|
|
16294
16720
|
parseAwait(startPos, startLoc) {
|
|
16295
16721
|
var node = this.startNodeAt(startPos, startLoc);
|
|
16296
|
-
this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.AwaitExpressionFormalParameter);
|
|
16722
|
+
this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.AwaitExpressionFormalParameter);
|
|
16297
16723
|
|
|
16298
16724
|
if (this.eat(51)) {
|
|
16299
|
-
this.raise(
|
|
16725
|
+
this.raise(ErrorMessages.ObsoleteAwaitStar, {
|
|
16726
|
+
node
|
|
16727
|
+
});
|
|
16300
16728
|
}
|
|
16301
16729
|
|
|
16302
16730
|
if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
|
|
@@ -16324,7 +16752,7 @@
|
|
|
16324
16752
|
|
|
16325
16753
|
parseYield() {
|
|
16326
16754
|
var node = this.startNode();
|
|
16327
|
-
this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.YieldInParameter);
|
|
16755
|
+
this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.YieldInParameter);
|
|
16328
16756
|
this.next();
|
|
16329
16757
|
var delegating = false;
|
|
16330
16758
|
var argument = null;
|
|
@@ -16353,22 +16781,18 @@
|
|
|
16353
16781
|
return this.finishNode(node, "YieldExpression");
|
|
16354
16782
|
}
|
|
16355
16783
|
|
|
16356
|
-
checkPipelineAtInfixOperator(left,
|
|
16784
|
+
checkPipelineAtInfixOperator(left, leftStartLoc) {
|
|
16357
16785
|
if (this.hasPlugin(["pipelineOperator", {
|
|
16358
16786
|
proposal: "smart"
|
|
16359
16787
|
}])) {
|
|
16360
16788
|
if (left.type === "SequenceExpression") {
|
|
16361
|
-
this.raise(
|
|
16789
|
+
this.raise(ErrorMessages.PipelineHeadSequenceExpression, {
|
|
16790
|
+
at: leftStartLoc
|
|
16791
|
+
});
|
|
16362
16792
|
}
|
|
16363
16793
|
}
|
|
16364
16794
|
}
|
|
16365
16795
|
|
|
16366
|
-
checkHackPipeBodyEarlyErrors(startPos) {
|
|
16367
|
-
if (!this.topicReferenceWasUsedInCurrentContext()) {
|
|
16368
|
-
this.raise(startPos, ErrorMessages.PipeTopicUnused);
|
|
16369
|
-
}
|
|
16370
|
-
}
|
|
16371
|
-
|
|
16372
16796
|
parseSmartPipelineBodyInStyle(childExpr, startPos, startLoc) {
|
|
16373
16797
|
var bodyNode = this.startNodeAt(startPos, startLoc);
|
|
16374
16798
|
|
|
@@ -16376,7 +16800,7 @@
|
|
|
16376
16800
|
bodyNode.callee = childExpr;
|
|
16377
16801
|
return this.finishNode(bodyNode, "PipelineBareFunction");
|
|
16378
16802
|
} else {
|
|
16379
|
-
this.checkSmartPipeTopicBodyEarlyErrors(
|
|
16803
|
+
this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
|
|
16380
16804
|
bodyNode.expression = childExpr;
|
|
16381
16805
|
return this.finishNode(bodyNode, "PipelineTopicExpression");
|
|
16382
16806
|
}
|
|
@@ -16395,11 +16819,17 @@
|
|
|
16395
16819
|
}
|
|
16396
16820
|
}
|
|
16397
16821
|
|
|
16398
|
-
checkSmartPipeTopicBodyEarlyErrors(
|
|
16822
|
+
checkSmartPipeTopicBodyEarlyErrors(startLoc) {
|
|
16399
16823
|
if (this.match(19)) {
|
|
16400
|
-
throw this.raise(
|
|
16401
|
-
|
|
16402
|
-
|
|
16824
|
+
throw this.raise(ErrorMessages.PipelineBodyNoArrow, {
|
|
16825
|
+
at: this.state.startLoc
|
|
16826
|
+
});
|
|
16827
|
+
}
|
|
16828
|
+
|
|
16829
|
+
if (!this.topicReferenceWasUsedInCurrentContext()) {
|
|
16830
|
+
this.raise(ErrorMessages.PipelineTopicUnused, {
|
|
16831
|
+
at: startLoc
|
|
16832
|
+
});
|
|
16403
16833
|
}
|
|
16404
16834
|
}
|
|
16405
16835
|
|
|
@@ -16679,9 +17109,10 @@
|
|
|
16679
17109
|
this.parseBlockBody(program, true, true, end);
|
|
16680
17110
|
|
|
16681
17111
|
if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
|
|
16682
|
-
for (var [name] of Array.from(this.scope.undefinedExports)) {
|
|
16683
|
-
|
|
16684
|
-
|
|
17112
|
+
for (var [name, loc] of Array.from(this.scope.undefinedExports)) {
|
|
17113
|
+
this.raise(ErrorMessages.ModuleExportUndefined, {
|
|
17114
|
+
at: loc
|
|
17115
|
+
}, name);
|
|
16685
17116
|
}
|
|
16686
17117
|
}
|
|
16687
17118
|
|
|
@@ -16790,9 +17221,13 @@
|
|
|
16790
17221
|
|
|
16791
17222
|
if (context) {
|
|
16792
17223
|
if (this.state.strict) {
|
|
16793
|
-
this.raise(
|
|
17224
|
+
this.raise(ErrorMessages.StrictFunction, {
|
|
17225
|
+
at: this.state.startLoc
|
|
17226
|
+
});
|
|
16794
17227
|
} else if (context !== "if" && context !== "label") {
|
|
16795
|
-
this.raise(
|
|
17228
|
+
this.raise(ErrorMessages.SloppyFunction, {
|
|
17229
|
+
at: this.state.startLoc
|
|
17230
|
+
});
|
|
16796
17231
|
}
|
|
16797
17232
|
}
|
|
16798
17233
|
|
|
@@ -16822,7 +17257,9 @@
|
|
|
16822
17257
|
kind = kind || this.state.value;
|
|
16823
17258
|
|
|
16824
17259
|
if (context && kind !== "var") {
|
|
16825
|
-
this.raise(
|
|
17260
|
+
this.raise(ErrorMessages.UnexpectedLexicalDeclaration, {
|
|
17261
|
+
at: this.state.startLoc
|
|
17262
|
+
});
|
|
16826
17263
|
}
|
|
16827
17264
|
|
|
16828
17265
|
return this.parseVarStatement(node, kind);
|
|
@@ -16851,7 +17288,9 @@
|
|
|
16851
17288
|
case 78:
|
|
16852
17289
|
{
|
|
16853
17290
|
if (!this.options.allowImportExportEverywhere && !topLevel) {
|
|
16854
|
-
this.raise(
|
|
17291
|
+
this.raise(ErrorMessages.UnexpectedImportExport, {
|
|
17292
|
+
at: this.state.startLoc
|
|
17293
|
+
});
|
|
16855
17294
|
}
|
|
16856
17295
|
|
|
16857
17296
|
this.next();
|
|
@@ -16879,7 +17318,9 @@
|
|
|
16879
17318
|
{
|
|
16880
17319
|
if (this.isAsyncFunction()) {
|
|
16881
17320
|
if (context) {
|
|
16882
|
-
this.raise(
|
|
17321
|
+
this.raise(ErrorMessages.AsyncFunctionInSingleStatementContext, {
|
|
17322
|
+
at: this.state.startLoc
|
|
17323
|
+
});
|
|
16883
17324
|
}
|
|
16884
17325
|
|
|
16885
17326
|
this.next();
|
|
@@ -16900,7 +17341,9 @@
|
|
|
16900
17341
|
|
|
16901
17342
|
assertModuleNodeAllowed(node) {
|
|
16902
17343
|
if (!this.options.allowImportExportEverywhere && !this.inModule) {
|
|
16903
|
-
this.raise(
|
|
17344
|
+
this.raise(SourceTypeModuleErrorMessages.ImportOutsideModule, {
|
|
17345
|
+
node
|
|
17346
|
+
});
|
|
16904
17347
|
}
|
|
16905
17348
|
}
|
|
16906
17349
|
|
|
@@ -16932,10 +17375,14 @@
|
|
|
16932
17375
|
}
|
|
16933
17376
|
|
|
16934
17377
|
if (this.hasPlugin("decorators") && !this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
|
16935
|
-
this.raise(
|
|
17378
|
+
this.raise(ErrorMessages.DecoratorExportClass, {
|
|
17379
|
+
at: this.state.startLoc
|
|
17380
|
+
});
|
|
16936
17381
|
}
|
|
16937
17382
|
} else if (!this.canHaveLeadingDecorator()) {
|
|
16938
|
-
throw this.raise(
|
|
17383
|
+
throw this.raise(ErrorMessages.UnexpectedLeadingDecorator, {
|
|
17384
|
+
at: this.state.startLoc
|
|
17385
|
+
});
|
|
16939
17386
|
}
|
|
16940
17387
|
}
|
|
16941
17388
|
|
|
@@ -17014,7 +17461,9 @@
|
|
|
17014
17461
|
}
|
|
17015
17462
|
|
|
17016
17463
|
if (i === this.state.labels.length) {
|
|
17017
|
-
this.raise(
|
|
17464
|
+
this.raise(ErrorMessages.IllegalBreakContinue, {
|
|
17465
|
+
node
|
|
17466
|
+
}, isBreak ? "break" : "continue");
|
|
17018
17467
|
}
|
|
17019
17468
|
}
|
|
17020
17469
|
|
|
@@ -17045,17 +17494,17 @@
|
|
|
17045
17494
|
parseForStatement(node) {
|
|
17046
17495
|
this.next();
|
|
17047
17496
|
this.state.labels.push(loopLabel);
|
|
17048
|
-
var awaitAt =
|
|
17497
|
+
var awaitAt = null;
|
|
17049
17498
|
|
|
17050
17499
|
if (this.isAwaitAllowed() && this.eatContextual(92)) {
|
|
17051
|
-
awaitAt = this.state.
|
|
17500
|
+
awaitAt = this.state.lastTokStartLoc;
|
|
17052
17501
|
}
|
|
17053
17502
|
|
|
17054
17503
|
this.scope.enter(SCOPE_OTHER);
|
|
17055
17504
|
this.expect(10);
|
|
17056
17505
|
|
|
17057
17506
|
if (this.match(13)) {
|
|
17058
|
-
if (awaitAt
|
|
17507
|
+
if (awaitAt !== null) {
|
|
17059
17508
|
this.unexpected(awaitAt);
|
|
17060
17509
|
}
|
|
17061
17510
|
|
|
@@ -17077,7 +17526,7 @@
|
|
|
17077
17526
|
return this.parseForIn(node, _init, awaitAt);
|
|
17078
17527
|
}
|
|
17079
17528
|
|
|
17080
|
-
if (awaitAt
|
|
17529
|
+
if (awaitAt !== null) {
|
|
17081
17530
|
this.unexpected(awaitAt);
|
|
17082
17531
|
}
|
|
17083
17532
|
|
|
@@ -17091,9 +17540,15 @@
|
|
|
17091
17540
|
|
|
17092
17541
|
if (isForOf) {
|
|
17093
17542
|
if (startsWithLet) {
|
|
17094
|
-
this.raise(
|
|
17095
|
-
|
|
17096
|
-
|
|
17543
|
+
this.raise(ErrorMessages.ForOfLet, {
|
|
17544
|
+
node: init
|
|
17545
|
+
});
|
|
17546
|
+
}
|
|
17547
|
+
|
|
17548
|
+
if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
|
|
17549
|
+
this.raise(ErrorMessages.ForOfAsync, {
|
|
17550
|
+
node: init
|
|
17551
|
+
});
|
|
17097
17552
|
}
|
|
17098
17553
|
}
|
|
17099
17554
|
|
|
@@ -17106,7 +17561,7 @@
|
|
|
17106
17561
|
this.checkExpressionErrors(refExpressionErrors, true);
|
|
17107
17562
|
}
|
|
17108
17563
|
|
|
17109
|
-
if (awaitAt
|
|
17564
|
+
if (awaitAt !== null) {
|
|
17110
17565
|
this.unexpected(awaitAt);
|
|
17111
17566
|
}
|
|
17112
17567
|
|
|
@@ -17128,7 +17583,9 @@
|
|
|
17128
17583
|
|
|
17129
17584
|
parseReturnStatement(node) {
|
|
17130
17585
|
if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
|
|
17131
|
-
this.raise(
|
|
17586
|
+
this.raise(ErrorMessages.IllegalReturn, {
|
|
17587
|
+
at: this.state.startLoc
|
|
17588
|
+
});
|
|
17132
17589
|
}
|
|
17133
17590
|
|
|
17134
17591
|
this.next();
|
|
@@ -17164,7 +17621,9 @@
|
|
|
17164
17621
|
cur.test = this.parseExpression();
|
|
17165
17622
|
} else {
|
|
17166
17623
|
if (sawDefault) {
|
|
17167
|
-
this.raise(
|
|
17624
|
+
this.raise(ErrorMessages.MultipleDefaultsInSwitch, {
|
|
17625
|
+
at: this.state.lastTokStartLoc
|
|
17626
|
+
});
|
|
17168
17627
|
}
|
|
17169
17628
|
|
|
17170
17629
|
sawDefault = true;
|
|
@@ -17192,7 +17651,9 @@
|
|
|
17192
17651
|
this.next();
|
|
17193
17652
|
|
|
17194
17653
|
if (this.hasPrecedingLineBreak()) {
|
|
17195
|
-
this.raise(
|
|
17654
|
+
this.raise(ErrorMessages.NewlineAfterThrow, {
|
|
17655
|
+
at: this.state.lastTokEndLoc
|
|
17656
|
+
});
|
|
17196
17657
|
}
|
|
17197
17658
|
|
|
17198
17659
|
node.argument = this.parseExpression();
|
|
@@ -17234,7 +17695,9 @@
|
|
|
17234
17695
|
node.finalizer = this.eat(63) ? this.parseBlock() : null;
|
|
17235
17696
|
|
|
17236
17697
|
if (!node.handler && !node.finalizer) {
|
|
17237
|
-
this.raise(
|
|
17698
|
+
this.raise(ErrorMessages.NoCatchOrFinally, {
|
|
17699
|
+
node
|
|
17700
|
+
});
|
|
17238
17701
|
}
|
|
17239
17702
|
|
|
17240
17703
|
return this.finishNode(node, "TryStatement");
|
|
@@ -17258,7 +17721,9 @@
|
|
|
17258
17721
|
|
|
17259
17722
|
parseWithStatement(node) {
|
|
17260
17723
|
if (this.state.strict) {
|
|
17261
|
-
this.raise(
|
|
17724
|
+
this.raise(ErrorMessages.StrictWith, {
|
|
17725
|
+
at: this.state.startLoc
|
|
17726
|
+
});
|
|
17262
17727
|
}
|
|
17263
17728
|
|
|
17264
17729
|
this.next();
|
|
@@ -17275,7 +17740,9 @@
|
|
|
17275
17740
|
parseLabeledStatement(node, maybeName, expr, context) {
|
|
17276
17741
|
for (var label of this.state.labels) {
|
|
17277
17742
|
if (label.name === maybeName) {
|
|
17278
|
-
this.raise(
|
|
17743
|
+
this.raise(ErrorMessages.LabelRedeclaration, {
|
|
17744
|
+
node: expr
|
|
17745
|
+
}, maybeName);
|
|
17279
17746
|
}
|
|
17280
17747
|
}
|
|
17281
17748
|
|
|
@@ -17401,15 +17868,21 @@
|
|
|
17401
17868
|
this.next();
|
|
17402
17869
|
|
|
17403
17870
|
if (isForIn) {
|
|
17404
|
-
if (awaitAt
|
|
17871
|
+
if (awaitAt !== null) this.unexpected(awaitAt);
|
|
17405
17872
|
} else {
|
|
17406
|
-
node.await = awaitAt
|
|
17873
|
+
node.await = awaitAt !== null;
|
|
17407
17874
|
}
|
|
17408
17875
|
|
|
17409
17876
|
if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
|
|
17410
|
-
this.raise(
|
|
17411
|
-
|
|
17412
|
-
|
|
17877
|
+
this.raise(ErrorMessages.ForInOfLoopInitializer, {
|
|
17878
|
+
node: init
|
|
17879
|
+
}, isForIn ? "for-in" : "for-of");
|
|
17880
|
+
}
|
|
17881
|
+
|
|
17882
|
+
if (init.type === "AssignmentPattern") {
|
|
17883
|
+
this.raise(ErrorMessages.InvalidLhs, {
|
|
17884
|
+
node: init
|
|
17885
|
+
}, "for-loop");
|
|
17413
17886
|
}
|
|
17414
17887
|
|
|
17415
17888
|
node.left = init;
|
|
@@ -17435,10 +17908,14 @@
|
|
|
17435
17908
|
} else {
|
|
17436
17909
|
if (kind === "const" && !(this.match(54) || this.isContextual(97))) {
|
|
17437
17910
|
if (!isTypescript) {
|
|
17438
|
-
this.raise(
|
|
17911
|
+
this.raise(ErrorMessages.DeclarationMissingInitializer, {
|
|
17912
|
+
at: this.state.lastTokEndLoc
|
|
17913
|
+
}, "Const declarations");
|
|
17439
17914
|
}
|
|
17440
17915
|
} else if (decl.id.type !== "Identifier" && !(isFor && (this.match(54) || this.isContextual(97)))) {
|
|
17441
|
-
this.raise(
|
|
17916
|
+
this.raise(ErrorMessages.DeclarationMissingInitializer, {
|
|
17917
|
+
at: this.state.lastTokEndLoc
|
|
17918
|
+
}, "Complex binding patterns");
|
|
17442
17919
|
}
|
|
17443
17920
|
|
|
17444
17921
|
decl.init = null;
|
|
@@ -17465,7 +17942,9 @@
|
|
|
17465
17942
|
this.initFunction(node, isAsync);
|
|
17466
17943
|
|
|
17467
17944
|
if (this.match(51) && isHangingStatement) {
|
|
17468
|
-
this.raise(
|
|
17945
|
+
this.raise(ErrorMessages.GeneratorInSingleStatementContext, {
|
|
17946
|
+
at: this.state.startLoc
|
|
17947
|
+
});
|
|
17469
17948
|
}
|
|
17470
17949
|
|
|
17471
17950
|
node.generator = this.eat(51);
|
|
@@ -17511,7 +17990,7 @@
|
|
|
17511
17990
|
|
|
17512
17991
|
registerFunctionStatementId(node) {
|
|
17513
17992
|
if (!node.id) return;
|
|
17514
|
-
this.scope.declareName(node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, node.id.start);
|
|
17993
|
+
this.scope.declareName(node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, node.id.loc.start);
|
|
17515
17994
|
}
|
|
17516
17995
|
|
|
17517
17996
|
parseClass(node, isStatement, optionalId) {
|
|
@@ -17551,7 +18030,9 @@
|
|
|
17551
18030
|
while (!this.match(8)) {
|
|
17552
18031
|
if (this.eat(13)) {
|
|
17553
18032
|
if (decorators.length > 0) {
|
|
17554
|
-
throw this.raise(
|
|
18033
|
+
throw this.raise(ErrorMessages.DecoratorSemicolon, {
|
|
18034
|
+
at: this.state.lastTokEndLoc
|
|
18035
|
+
});
|
|
17555
18036
|
}
|
|
17556
18037
|
|
|
17557
18038
|
continue;
|
|
@@ -17573,7 +18054,9 @@
|
|
|
17573
18054
|
this.parseClassMember(classBody, member, state);
|
|
17574
18055
|
|
|
17575
18056
|
if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
|
|
17576
|
-
this.raise(
|
|
18057
|
+
this.raise(ErrorMessages.DecoratorConstructor, {
|
|
18058
|
+
node: member
|
|
18059
|
+
});
|
|
17577
18060
|
}
|
|
17578
18061
|
}
|
|
17579
18062
|
});
|
|
@@ -17581,7 +18064,9 @@
|
|
|
17581
18064
|
this.next();
|
|
17582
18065
|
|
|
17583
18066
|
if (decorators.length) {
|
|
17584
|
-
throw this.raise(
|
|
18067
|
+
throw this.raise(ErrorMessages.TrailingDecorator, {
|
|
18068
|
+
at: this.state.startLoc
|
|
18069
|
+
});
|
|
17585
18070
|
}
|
|
17586
18071
|
|
|
17587
18072
|
this.classScope.exit();
|
|
@@ -17650,7 +18135,9 @@
|
|
|
17650
18135
|
}
|
|
17651
18136
|
|
|
17652
18137
|
if (this.isNonstaticConstructor(publicMethod)) {
|
|
17653
|
-
this.raise(
|
|
18138
|
+
this.raise(ErrorMessages.ConstructorIsGenerator, {
|
|
18139
|
+
node: publicMethod.key
|
|
18140
|
+
});
|
|
17654
18141
|
}
|
|
17655
18142
|
|
|
17656
18143
|
this.pushClassMethod(classBody, publicMethod, true, false, false, false);
|
|
@@ -17660,7 +18147,7 @@
|
|
|
17660
18147
|
var isContextual = tokenIsIdentifier(this.state.type) && !this.state.containsEsc;
|
|
17661
18148
|
var isPrivate = this.match(130);
|
|
17662
18149
|
var key = this.parseClassElementName(member);
|
|
17663
|
-
var
|
|
18150
|
+
var maybeQuestionTokenStartLoc = this.state.startLoc;
|
|
17664
18151
|
this.parsePostMemberNameModifiers(publicMember);
|
|
17665
18152
|
|
|
17666
18153
|
if (this.isClassMethod()) {
|
|
@@ -17678,11 +18165,15 @@
|
|
|
17678
18165
|
publicMethod.kind = "constructor";
|
|
17679
18166
|
|
|
17680
18167
|
if (state.hadConstructor && !this.hasPlugin("typescript")) {
|
|
17681
|
-
this.raise(
|
|
18168
|
+
this.raise(ErrorMessages.DuplicateConstructor, {
|
|
18169
|
+
node: key
|
|
18170
|
+
});
|
|
17682
18171
|
}
|
|
17683
18172
|
|
|
17684
18173
|
if (isConstructor && this.hasPlugin("typescript") && member.override) {
|
|
17685
|
-
this.raise(
|
|
18174
|
+
this.raise(ErrorMessages.OverrideOnConstructor, {
|
|
18175
|
+
node: key
|
|
18176
|
+
});
|
|
17686
18177
|
}
|
|
17687
18178
|
|
|
17688
18179
|
state.hadConstructor = true;
|
|
@@ -17701,7 +18192,7 @@
|
|
|
17701
18192
|
var isGenerator = this.eat(51);
|
|
17702
18193
|
|
|
17703
18194
|
if (publicMember.optional) {
|
|
17704
|
-
this.unexpected(
|
|
18195
|
+
this.unexpected(maybeQuestionTokenStartLoc);
|
|
17705
18196
|
}
|
|
17706
18197
|
|
|
17707
18198
|
method.kind = "method";
|
|
@@ -17715,7 +18206,9 @@
|
|
|
17715
18206
|
this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
|
|
17716
18207
|
} else {
|
|
17717
18208
|
if (this.isNonstaticConstructor(publicMethod)) {
|
|
17718
|
-
this.raise(
|
|
18209
|
+
this.raise(ErrorMessages.ConstructorIsAsync, {
|
|
18210
|
+
node: publicMethod.key
|
|
18211
|
+
});
|
|
17719
18212
|
}
|
|
17720
18213
|
|
|
17721
18214
|
this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
|
|
@@ -17732,7 +18225,9 @@
|
|
|
17732
18225
|
this.pushClassPrivateMethod(classBody, privateMethod, false, false);
|
|
17733
18226
|
} else {
|
|
17734
18227
|
if (this.isNonstaticConstructor(publicMethod)) {
|
|
17735
|
-
this.raise(
|
|
18228
|
+
this.raise(ErrorMessages.ConstructorIsAccessor, {
|
|
18229
|
+
node: publicMethod.key
|
|
18230
|
+
});
|
|
17736
18231
|
}
|
|
17737
18232
|
|
|
17738
18233
|
this.pushClassMethod(classBody, publicMethod, false, false, false, false);
|
|
@@ -17753,17 +18248,20 @@
|
|
|
17753
18248
|
parseClassElementName(member) {
|
|
17754
18249
|
var {
|
|
17755
18250
|
type,
|
|
17756
|
-
value
|
|
17757
|
-
start
|
|
18251
|
+
value
|
|
17758
18252
|
} = this.state;
|
|
17759
18253
|
|
|
17760
18254
|
if ((type === 124 || type === 125) && member.static && value === "prototype") {
|
|
17761
|
-
this.raise(
|
|
18255
|
+
this.raise(ErrorMessages.StaticPrototype, {
|
|
18256
|
+
at: this.state.startLoc
|
|
18257
|
+
});
|
|
17762
18258
|
}
|
|
17763
18259
|
|
|
17764
18260
|
if (type === 130) {
|
|
17765
18261
|
if (value === "constructor") {
|
|
17766
|
-
this.raise(
|
|
18262
|
+
this.raise(ErrorMessages.ConstructorClassPrivateField, {
|
|
18263
|
+
at: this.state.startLoc
|
|
18264
|
+
});
|
|
17767
18265
|
}
|
|
17768
18266
|
|
|
17769
18267
|
var key = this.parsePrivateName();
|
|
@@ -17789,13 +18287,17 @@
|
|
|
17789
18287
|
classBody.body.push(this.finishNode(member, "StaticBlock"));
|
|
17790
18288
|
|
|
17791
18289
|
if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
|
|
17792
|
-
this.raise(
|
|
18290
|
+
this.raise(ErrorMessages.DecoratorStaticBlock, {
|
|
18291
|
+
node: member
|
|
18292
|
+
});
|
|
17793
18293
|
}
|
|
17794
18294
|
}
|
|
17795
18295
|
|
|
17796
18296
|
pushClassProperty(classBody, prop) {
|
|
17797
18297
|
if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) {
|
|
17798
|
-
this.raise(
|
|
18298
|
+
this.raise(ErrorMessages.ConstructorClassField, {
|
|
18299
|
+
node: prop.key
|
|
18300
|
+
});
|
|
17799
18301
|
}
|
|
17800
18302
|
|
|
17801
18303
|
classBody.body.push(this.parseClassProperty(prop));
|
|
@@ -17804,7 +18306,7 @@
|
|
|
17804
18306
|
pushClassPrivateProperty(classBody, prop) {
|
|
17805
18307
|
var node = this.parseClassPrivateProperty(prop);
|
|
17806
18308
|
classBody.body.push(node);
|
|
17807
|
-
this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.start);
|
|
18309
|
+
this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.loc.start);
|
|
17808
18310
|
}
|
|
17809
18311
|
|
|
17810
18312
|
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
|
@@ -17819,7 +18321,7 @@
|
|
|
17819
18321
|
}
|
|
17820
18322
|
|
|
17821
18323
|
declareClassPrivateMethodInScope(node, kind) {
|
|
17822
|
-
this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.start);
|
|
18324
|
+
this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
|
|
17823
18325
|
}
|
|
17824
18326
|
|
|
17825
18327
|
parsePostMemberNameModifiers(methodOrProp) {}
|
|
@@ -17859,7 +18361,9 @@
|
|
|
17859
18361
|
if (optionalId || !isStatement) {
|
|
17860
18362
|
node.id = null;
|
|
17861
18363
|
} else {
|
|
17862
|
-
this.
|
|
18364
|
+
throw this.raise(ErrorMessages.MissingClassName, {
|
|
18365
|
+
at: this.state.startLoc
|
|
18366
|
+
});
|
|
17863
18367
|
}
|
|
17864
18368
|
}
|
|
17865
18369
|
}
|
|
@@ -17992,22 +18496,32 @@
|
|
|
17992
18496
|
}
|
|
17993
18497
|
|
|
17994
18498
|
return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync);
|
|
17995
|
-
}
|
|
18499
|
+
}
|
|
18500
|
+
|
|
18501
|
+
if (this.match(76)) {
|
|
17996
18502
|
return this.parseClass(expr, true, true);
|
|
17997
|
-
}
|
|
18503
|
+
}
|
|
18504
|
+
|
|
18505
|
+
if (this.match(26)) {
|
|
17998
18506
|
if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
|
17999
|
-
this.raise(
|
|
18507
|
+
this.raise(ErrorMessages.DecoratorBeforeExport, {
|
|
18508
|
+
at: this.state.startLoc
|
|
18509
|
+
});
|
|
18000
18510
|
}
|
|
18001
18511
|
|
|
18002
18512
|
this.parseDecorators(false);
|
|
18003
18513
|
return this.parseClass(expr, true, true);
|
|
18004
|
-
} else if (this.match(71) || this.match(70) || this.isLet()) {
|
|
18005
|
-
throw this.raise(this.state.start, ErrorMessages.UnsupportedDefaultExport);
|
|
18006
|
-
} else {
|
|
18007
|
-
var res = this.parseMaybeAssignAllowIn();
|
|
18008
|
-
this.semicolon();
|
|
18009
|
-
return res;
|
|
18010
18514
|
}
|
|
18515
|
+
|
|
18516
|
+
if (this.match(71) || this.match(70) || this.isLet()) {
|
|
18517
|
+
throw this.raise(ErrorMessages.UnsupportedDefaultExport, {
|
|
18518
|
+
at: this.state.startLoc
|
|
18519
|
+
});
|
|
18520
|
+
}
|
|
18521
|
+
|
|
18522
|
+
var res = this.parseMaybeAssignAllowIn();
|
|
18523
|
+
this.semicolon();
|
|
18524
|
+
return res;
|
|
18011
18525
|
}
|
|
18012
18526
|
|
|
18013
18527
|
parseExportDeclaration(node) {
|
|
@@ -18079,10 +18593,12 @@
|
|
|
18079
18593
|
|
|
18080
18594
|
if (this.hasPlugin("decorators")) {
|
|
18081
18595
|
if (this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
|
18082
|
-
this.
|
|
18083
|
-
|
|
18084
|
-
|
|
18596
|
+
throw this.raise(ErrorMessages.DecoratorBeforeExport, {
|
|
18597
|
+
at: this.state.startLoc
|
|
18598
|
+
});
|
|
18085
18599
|
}
|
|
18600
|
+
|
|
18601
|
+
return true;
|
|
18086
18602
|
}
|
|
18087
18603
|
}
|
|
18088
18604
|
|
|
@@ -18100,7 +18616,9 @@
|
|
|
18100
18616
|
var declaration = node.declaration;
|
|
18101
18617
|
|
|
18102
18618
|
if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
|
|
18103
|
-
this.raise(
|
|
18619
|
+
this.raise(ErrorMessages.ExportDefaultFromAsIdentifier, {
|
|
18620
|
+
node: declaration
|
|
18621
|
+
});
|
|
18104
18622
|
}
|
|
18105
18623
|
}
|
|
18106
18624
|
} else if (node.specifiers && node.specifiers.length) {
|
|
@@ -18117,9 +18635,11 @@
|
|
|
18117
18635
|
} = specifier;
|
|
18118
18636
|
|
|
18119
18637
|
if (local.type !== "Identifier") {
|
|
18120
|
-
this.raise(
|
|
18638
|
+
this.raise(ErrorMessages.ExportBindingIsString, {
|
|
18639
|
+
node: specifier
|
|
18640
|
+
}, local.value, exportedName);
|
|
18121
18641
|
} else {
|
|
18122
|
-
this.checkReservedWord(local.name, local.start, true, false);
|
|
18642
|
+
this.checkReservedWord(local.name, local.loc.start, true, false);
|
|
18123
18643
|
this.scope.checkLocalExport(local);
|
|
18124
18644
|
}
|
|
18125
18645
|
}
|
|
@@ -18140,7 +18660,9 @@
|
|
|
18140
18660
|
var currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
|
|
18141
18661
|
|
|
18142
18662
|
if (currentContextDecorators.length) {
|
|
18143
|
-
throw this.raise(
|
|
18663
|
+
throw this.raise(ErrorMessages.UnsupportedDecoratorExport, {
|
|
18664
|
+
node
|
|
18665
|
+
});
|
|
18144
18666
|
}
|
|
18145
18667
|
}
|
|
18146
18668
|
|
|
@@ -18168,7 +18690,9 @@
|
|
|
18168
18690
|
|
|
18169
18691
|
checkDuplicateExports(node, name) {
|
|
18170
18692
|
if (this.exportedIdentifiers.has(name)) {
|
|
18171
|
-
this.raise(
|
|
18693
|
+
this.raise(name === "default" ? ErrorMessages.DuplicateDefaultExport : ErrorMessages.DuplicateExport, {
|
|
18694
|
+
node
|
|
18695
|
+
}, name);
|
|
18172
18696
|
}
|
|
18173
18697
|
|
|
18174
18698
|
this.exportedIdentifiers.add(name);
|
|
@@ -18215,7 +18739,9 @@
|
|
|
18215
18739
|
var surrogate = result.value.match(loneSurrogate);
|
|
18216
18740
|
|
|
18217
18741
|
if (surrogate) {
|
|
18218
|
-
this.raise(
|
|
18742
|
+
this.raise(ErrorMessages.ModuleExportNameHasLoneSurrogate, {
|
|
18743
|
+
node: result
|
|
18744
|
+
}, surrogate[0].charCodeAt(0).toString(16));
|
|
18219
18745
|
}
|
|
18220
18746
|
|
|
18221
18747
|
return result;
|
|
@@ -18280,7 +18806,9 @@
|
|
|
18280
18806
|
var keyName = this.state.value;
|
|
18281
18807
|
|
|
18282
18808
|
if (attrNames.has(keyName)) {
|
|
18283
|
-
this.raise(
|
|
18809
|
+
this.raise(ErrorMessages.ModuleAttributesWithDuplicateKeys, {
|
|
18810
|
+
at: this.state.startLoc
|
|
18811
|
+
}, keyName);
|
|
18284
18812
|
}
|
|
18285
18813
|
|
|
18286
18814
|
attrNames.add(keyName);
|
|
@@ -18294,7 +18822,9 @@
|
|
|
18294
18822
|
this.expect(14);
|
|
18295
18823
|
|
|
18296
18824
|
if (!this.match(125)) {
|
|
18297
|
-
throw this.
|
|
18825
|
+
throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, {
|
|
18826
|
+
at: this.state.startLoc
|
|
18827
|
+
});
|
|
18298
18828
|
}
|
|
18299
18829
|
|
|
18300
18830
|
node.value = this.parseStringLiteral(this.state.value);
|
|
@@ -18322,18 +18852,24 @@
|
|
|
18322
18852
|
node.key = this.parseIdentifier(true);
|
|
18323
18853
|
|
|
18324
18854
|
if (node.key.name !== "type") {
|
|
18325
|
-
this.raise(
|
|
18855
|
+
this.raise(ErrorMessages.ModuleAttributeDifferentFromType, {
|
|
18856
|
+
node: node.key
|
|
18857
|
+
}, node.key.name);
|
|
18326
18858
|
}
|
|
18327
18859
|
|
|
18328
18860
|
if (attributes.has(node.key.name)) {
|
|
18329
|
-
this.raise(
|
|
18861
|
+
this.raise(ErrorMessages.ModuleAttributesWithDuplicateKeys, {
|
|
18862
|
+
node: node.key
|
|
18863
|
+
}, node.key.name);
|
|
18330
18864
|
}
|
|
18331
18865
|
|
|
18332
18866
|
attributes.add(node.key.name);
|
|
18333
18867
|
this.expect(14);
|
|
18334
18868
|
|
|
18335
18869
|
if (!this.match(125)) {
|
|
18336
|
-
throw this.
|
|
18870
|
+
throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, {
|
|
18871
|
+
at: this.state.startLoc
|
|
18872
|
+
});
|
|
18337
18873
|
}
|
|
18338
18874
|
|
|
18339
18875
|
node.value = this.parseStringLiteral(this.state.value);
|
|
@@ -18389,7 +18925,9 @@
|
|
|
18389
18925
|
first = false;
|
|
18390
18926
|
} else {
|
|
18391
18927
|
if (this.eat(14)) {
|
|
18392
|
-
throw this.raise(
|
|
18928
|
+
throw this.raise(ErrorMessages.DestructureNamedImport, {
|
|
18929
|
+
at: this.state.startLoc
|
|
18930
|
+
});
|
|
18393
18931
|
}
|
|
18394
18932
|
|
|
18395
18933
|
this.expect(12);
|
|
@@ -18414,10 +18952,12 @@
|
|
|
18414
18952
|
} = specifier;
|
|
18415
18953
|
|
|
18416
18954
|
if (importedIsString) {
|
|
18417
|
-
throw this.raise(
|
|
18955
|
+
throw this.raise(ErrorMessages.ImportBindingIsString, {
|
|
18956
|
+
node: specifier
|
|
18957
|
+
}, imported.value);
|
|
18418
18958
|
}
|
|
18419
18959
|
|
|
18420
|
-
this.checkReservedWord(imported.name, specifier.start, true, true);
|
|
18960
|
+
this.checkReservedWord(imported.name, specifier.loc.start, true, true);
|
|
18421
18961
|
|
|
18422
18962
|
if (!specifier.local) {
|
|
18423
18963
|
specifier.local = cloneIdentifier(imported);
|
|
@@ -21237,7 +21777,7 @@
|
|
|
21237
21777
|
}
|
|
21238
21778
|
|
|
21239
21779
|
var fieldsToKeepInMenu = ["menuId", "title", "icon", "titleDataSource", "defaultCollapsed", "defaultCollapsedBreakpoint", "link", "type", "injectMenuGroupId", "dynamicItems", "itemsResolve"];
|
|
21240
|
-
var fieldsToKeepInMenuItem = ["text", "to", "target", "icon", "exact", "key", "activeIncludes", "activeExcludes", "activeMatchSearch", "type", "sort", "defaultExpanded", "if", "groupId"];
|
|
21780
|
+
var fieldsToKeepInMenuItem = ["text", "to", "href", "target", "icon", "exact", "key", "activeIncludes", "activeExcludes", "activeMatchSearch", "type", "sort", "defaultExpanded", "if", "groupId"];
|
|
21241
21781
|
function normalizeMenu(node) {
|
|
21242
21782
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, keep(node, fieldsToKeepInMenu)), {}, {
|
|
21243
21783
|
items: keepItems(node.items, fieldsToKeepInMenuItem)
|