@next-core/brick-utils 2.33.0 → 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 +9 -49
- package/dist/index.bundle.js +1317 -789
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +1317 -789
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/index.bundle.js
CHANGED
|
@@ -3062,62 +3062,15 @@
|
|
|
3062
3062
|
Object.defineProperty(lib, '__esModule', {
|
|
3063
3063
|
value: true
|
|
3064
3064
|
});
|
|
3065
|
-
var lineBreak = /\r\n?|[\n\u2028\u2029]/;
|
|
3066
|
-
var lineBreakG = new RegExp(lineBreak.source, "g");
|
|
3067
|
-
|
|
3068
|
-
function isNewLine(code) {
|
|
3069
|
-
switch (code) {
|
|
3070
|
-
case 10:
|
|
3071
|
-
case 13:
|
|
3072
|
-
case 8232:
|
|
3073
|
-
case 8233:
|
|
3074
|
-
return true;
|
|
3075
|
-
|
|
3076
|
-
default:
|
|
3077
|
-
return false;
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
|
|
3081
|
-
var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
|
|
3082
|
-
var skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
|
|
3083
|
-
var skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
|
|
3084
|
-
|
|
3085
|
-
function isWhitespace(code) {
|
|
3086
|
-
switch (code) {
|
|
3087
|
-
case 0x0009:
|
|
3088
|
-
case 0x000b:
|
|
3089
|
-
case 0x000c:
|
|
3090
|
-
case 32:
|
|
3091
|
-
case 160:
|
|
3092
|
-
case 5760:
|
|
3093
|
-
case 0x2000:
|
|
3094
|
-
case 0x2001:
|
|
3095
|
-
case 0x2002:
|
|
3096
|
-
case 0x2003:
|
|
3097
|
-
case 0x2004:
|
|
3098
|
-
case 0x2005:
|
|
3099
|
-
case 0x2006:
|
|
3100
|
-
case 0x2007:
|
|
3101
|
-
case 0x2008:
|
|
3102
|
-
case 0x2009:
|
|
3103
|
-
case 0x200a:
|
|
3104
|
-
case 0x202f:
|
|
3105
|
-
case 0x205f:
|
|
3106
|
-
case 0x3000:
|
|
3107
|
-
case 0xfeff:
|
|
3108
|
-
return true;
|
|
3109
|
-
|
|
3110
|
-
default:
|
|
3111
|
-
return false;
|
|
3112
|
-
}
|
|
3113
|
-
}
|
|
3114
3065
|
|
|
3115
3066
|
class Position {
|
|
3116
|
-
constructor(line, col) {
|
|
3067
|
+
constructor(line, col, index) {
|
|
3117
3068
|
this.line = void 0;
|
|
3118
3069
|
this.column = void 0;
|
|
3070
|
+
this.index = void 0;
|
|
3119
3071
|
this.line = line;
|
|
3120
3072
|
this.column = col;
|
|
3073
|
+
indexes.set(this, index);
|
|
3121
3074
|
}
|
|
3122
3075
|
|
|
3123
3076
|
}
|
|
@@ -3134,26 +3087,14 @@
|
|
|
3134
3087
|
|
|
3135
3088
|
}
|
|
3136
3089
|
|
|
3137
|
-
|
|
3138
|
-
var line = 1;
|
|
3139
|
-
var lineStart = 0;
|
|
3140
|
-
var match;
|
|
3141
|
-
lineBreakG.lastIndex = 0;
|
|
3142
|
-
|
|
3143
|
-
while ((match = lineBreakG.exec(input)) && match.index < offset) {
|
|
3144
|
-
line++;
|
|
3145
|
-
lineStart = lineBreakG.lastIndex;
|
|
3146
|
-
}
|
|
3147
|
-
|
|
3148
|
-
return new Position(line, offset - lineStart);
|
|
3149
|
-
}
|
|
3090
|
+
var indexes = new WeakMap();
|
|
3150
3091
|
|
|
3151
3092
|
function createPositionWithColumnOffset(position, columnOffset) {
|
|
3152
3093
|
var {
|
|
3153
3094
|
line,
|
|
3154
3095
|
column
|
|
3155
3096
|
} = position;
|
|
3156
|
-
return new Position(line, column + columnOffset);
|
|
3097
|
+
return new Position(line, column + columnOffset, indexes.get(position) + columnOffset);
|
|
3157
3098
|
}
|
|
3158
3099
|
|
|
3159
3100
|
class BaseParser {
|
|
@@ -3575,13 +3516,7 @@
|
|
|
3575
3516
|
}
|
|
3576
3517
|
|
|
3577
3518
|
class ParserError extends CommentsParser {
|
|
3578
|
-
|
|
3579
|
-
var loc;
|
|
3580
|
-
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);
|
|
3581
|
-
return loc;
|
|
3582
|
-
}
|
|
3583
|
-
|
|
3584
|
-
raise(pos, _ref) {
|
|
3519
|
+
raise(_ref, origin) {
|
|
3585
3520
|
var {
|
|
3586
3521
|
code,
|
|
3587
3522
|
reasonCode,
|
|
@@ -3592,13 +3527,13 @@
|
|
|
3592
3527
|
params[_key - 2] = arguments[_key];
|
|
3593
3528
|
}
|
|
3594
3529
|
|
|
3595
|
-
return this.raiseWithData(
|
|
3530
|
+
return this.raiseWithData(origin.node ? origin.node.loc.start : origin.at, {
|
|
3596
3531
|
code,
|
|
3597
3532
|
reasonCode
|
|
3598
3533
|
}, template, ...params);
|
|
3599
3534
|
}
|
|
3600
3535
|
|
|
3601
|
-
raiseOverwrite(
|
|
3536
|
+
raiseOverwrite(loc, _ref2) {
|
|
3602
3537
|
var {
|
|
3603
3538
|
code,
|
|
3604
3539
|
template
|
|
@@ -3608,7 +3543,7 @@
|
|
|
3608
3543
|
params[_key2 - 2] = arguments[_key2];
|
|
3609
3544
|
}
|
|
3610
3545
|
|
|
3611
|
-
var
|
|
3546
|
+
var pos = indexes.get(loc);
|
|
3612
3547
|
var message = template.replace(/%(\d+)/g, (_, i) => params[i]) + " (".concat(loc.line, ":").concat(loc.column, ")");
|
|
3613
3548
|
|
|
3614
3549
|
if (this.options.errorRecovery) {
|
|
@@ -3634,12 +3569,12 @@
|
|
|
3634
3569
|
}, message);
|
|
3635
3570
|
}
|
|
3636
3571
|
|
|
3637
|
-
raiseWithData(
|
|
3572
|
+
raiseWithData(loc, data, errorTemplate) {
|
|
3638
3573
|
for (var _len3 = arguments.length, params = new Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) {
|
|
3639
3574
|
params[_key3 - 3] = arguments[_key3];
|
|
3640
3575
|
}
|
|
3641
3576
|
|
|
3642
|
-
var
|
|
3577
|
+
var pos = indexes.get(loc);
|
|
3643
3578
|
var message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + " (".concat(loc.line, ":").concat(loc.column, ")");
|
|
3644
3579
|
return this._raise(Object.assign({
|
|
3645
3580
|
loc,
|
|
@@ -3728,9 +3663,9 @@
|
|
|
3728
3663
|
var expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start);
|
|
3729
3664
|
expression.value = directiveLiteral.extra.expressionValue;
|
|
3730
3665
|
expression.raw = directiveLiteral.extra.raw;
|
|
3731
|
-
stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.
|
|
3666
|
+
stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.loc.end);
|
|
3732
3667
|
stmt.directive = directiveLiteral.extra.raw.slice(1, -1);
|
|
3733
|
-
return this.finishNodeAt(stmt, "ExpressionStatement", directive.
|
|
3668
|
+
return this.finishNodeAt(stmt, "ExpressionStatement", directive.loc.end);
|
|
3734
3669
|
}
|
|
3735
3670
|
|
|
3736
3671
|
initFunction(node, isAsync) {
|
|
@@ -3912,9 +3847,13 @@
|
|
|
3912
3847
|
|
|
3913
3848
|
toAssignableObjectExpressionProp(prop) {
|
|
3914
3849
|
if (prop.kind === "get" || prop.kind === "set") {
|
|
3915
|
-
this.raise(
|
|
3850
|
+
this.raise(ErrorMessages.PatternHasAccessor, {
|
|
3851
|
+
node: prop.key
|
|
3852
|
+
});
|
|
3916
3853
|
} else if (prop.method) {
|
|
3917
|
-
this.raise(
|
|
3854
|
+
this.raise(ErrorMessages.PatternHasMethod, {
|
|
3855
|
+
node: prop.key
|
|
3856
|
+
});
|
|
3918
3857
|
} else {
|
|
3919
3858
|
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
3920
3859
|
args[_key5 - 1] = arguments[_key5];
|
|
@@ -4585,10 +4524,6 @@
|
|
|
4585
4524
|
return tokenTypes[token];
|
|
4586
4525
|
}
|
|
4587
4526
|
|
|
4588
|
-
function isTokenType(obj) {
|
|
4589
|
-
return typeof obj === "number";
|
|
4590
|
-
}
|
|
4591
|
-
|
|
4592
4527
|
{
|
|
4593
4528
|
tokenTypes[8].updateContext = context => {
|
|
4594
4529
|
context.pop();
|
|
@@ -4757,7 +4692,6 @@
|
|
|
4757
4692
|
constructor(raise, inModule) {
|
|
4758
4693
|
this.scopeStack = [];
|
|
4759
4694
|
this.undefinedExports = new Map();
|
|
4760
|
-
this.undefinedPrivateNames = new Map();
|
|
4761
4695
|
this.raise = raise;
|
|
4762
4696
|
this.inModule = inModule;
|
|
4763
4697
|
}
|
|
@@ -4823,11 +4757,11 @@
|
|
|
4823
4757
|
return !!(scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_PROGRAM);
|
|
4824
4758
|
}
|
|
4825
4759
|
|
|
4826
|
-
declareName(name, bindingType,
|
|
4760
|
+
declareName(name, bindingType, loc) {
|
|
4827
4761
|
var scope = this.currentScope();
|
|
4828
4762
|
|
|
4829
4763
|
if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
|
|
4830
|
-
this.checkRedeclarationInScope(scope, name, bindingType,
|
|
4764
|
+
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
|
4831
4765
|
|
|
4832
4766
|
if (bindingType & BIND_SCOPE_FUNCTION) {
|
|
4833
4767
|
scope.functions.add(name);
|
|
@@ -4841,7 +4775,7 @@
|
|
|
4841
4775
|
} else if (bindingType & BIND_SCOPE_VAR) {
|
|
4842
4776
|
for (var i = this.scopeStack.length - 1; i >= 0; --i) {
|
|
4843
4777
|
scope = this.scopeStack[i];
|
|
4844
|
-
this.checkRedeclarationInScope(scope, name, bindingType,
|
|
4778
|
+
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
|
4845
4779
|
scope.var.add(name);
|
|
4846
4780
|
this.maybeExportDefined(scope, name);
|
|
4847
4781
|
if (scope.flags & SCOPE_VAR) break;
|
|
@@ -4859,9 +4793,11 @@
|
|
|
4859
4793
|
}
|
|
4860
4794
|
}
|
|
4861
4795
|
|
|
4862
|
-
checkRedeclarationInScope(scope, name, bindingType,
|
|
4796
|
+
checkRedeclarationInScope(scope, name, bindingType, loc) {
|
|
4863
4797
|
if (this.isRedeclaredInScope(scope, name, bindingType)) {
|
|
4864
|
-
this.raise(
|
|
4798
|
+
this.raise(ErrorMessages.VarRedeclaration, {
|
|
4799
|
+
at: loc
|
|
4800
|
+
}, name);
|
|
4865
4801
|
}
|
|
4866
4802
|
}
|
|
4867
4803
|
|
|
@@ -4886,7 +4822,7 @@
|
|
|
4886
4822
|
var topLevelScope = this.scopeStack[0];
|
|
4887
4823
|
|
|
4888
4824
|
if (!topLevelScope.lexical.has(name) && !topLevelScope.var.has(name) && !topLevelScope.functions.has(name)) {
|
|
4889
|
-
this.undefinedExports.set(name, id.start);
|
|
4825
|
+
this.undefinedExports.set(name, id.loc.start);
|
|
4890
4826
|
}
|
|
4891
4827
|
}
|
|
4892
4828
|
|
|
@@ -4933,11 +4869,11 @@
|
|
|
4933
4869
|
return new FlowScope(flags);
|
|
4934
4870
|
}
|
|
4935
4871
|
|
|
4936
|
-
declareName(name, bindingType,
|
|
4872
|
+
declareName(name, bindingType, loc) {
|
|
4937
4873
|
var scope = this.currentScope();
|
|
4938
4874
|
|
|
4939
4875
|
if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {
|
|
4940
|
-
this.checkRedeclarationInScope(scope, name, bindingType,
|
|
4876
|
+
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
|
4941
4877
|
this.maybeExportDefined(scope, name);
|
|
4942
4878
|
scope.declareFunctions.add(name);
|
|
4943
4879
|
return;
|
|
@@ -4964,6 +4900,56 @@
|
|
|
4964
4900
|
|
|
4965
4901
|
}
|
|
4966
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
|
+
|
|
4967
4953
|
class State {
|
|
4968
4954
|
constructor() {
|
|
4969
4955
|
this.strict = void 0;
|
|
@@ -4999,7 +4985,6 @@
|
|
|
4999
4985
|
this.lastTokEndLoc = null;
|
|
5000
4986
|
this.lastTokStartLoc = null;
|
|
5001
4987
|
this.lastTokStart = 0;
|
|
5002
|
-
this.lastTokEnd = 0;
|
|
5003
4988
|
this.context = [types.brace];
|
|
5004
4989
|
this.canStartJSXElement = true;
|
|
5005
4990
|
this.containsEsc = false;
|
|
@@ -5017,11 +5002,11 @@
|
|
|
5017
5002
|
this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
|
|
5018
5003
|
this.curLine = startLine;
|
|
5019
5004
|
this.lineStart = -startColumn;
|
|
5020
|
-
this.startLoc = this.endLoc = new Position(startLine, startColumn);
|
|
5005
|
+
this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
|
|
5021
5006
|
}
|
|
5022
5007
|
|
|
5023
5008
|
curPosition() {
|
|
5024
|
-
return new Position(this.curLine, this.pos - this.lineStart);
|
|
5009
|
+
return new Position(this.curLine, this.pos - this.lineStart, this.pos);
|
|
5025
5010
|
}
|
|
5026
5011
|
|
|
5027
5012
|
clone(skipArrays) {
|
|
@@ -5095,7 +5080,6 @@
|
|
|
5095
5080
|
this.pushToken(new Token(this.state));
|
|
5096
5081
|
}
|
|
5097
5082
|
|
|
5098
|
-
this.state.lastTokEnd = this.state.end;
|
|
5099
5083
|
this.state.lastTokStart = this.state.start;
|
|
5100
5084
|
this.state.lastTokEndLoc = this.state.endLoc;
|
|
5101
5085
|
this.state.lastTokStartLoc = this.state.startLoc;
|
|
@@ -5122,9 +5106,13 @@
|
|
|
5122
5106
|
type: state.type,
|
|
5123
5107
|
start: state.start,
|
|
5124
5108
|
end: state.end,
|
|
5125
|
-
lastTokEnd: state.end,
|
|
5126
5109
|
context: [this.curContext()],
|
|
5127
|
-
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
|
|
5128
5116
|
};
|
|
5129
5117
|
}
|
|
5130
5118
|
|
|
@@ -5170,7 +5158,15 @@
|
|
|
5170
5158
|
this.state.strict = strict;
|
|
5171
5159
|
|
|
5172
5160
|
if (strict) {
|
|
5173
|
-
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
|
+
});
|
|
5174
5170
|
this.state.strictErrors.clear();
|
|
5175
5171
|
}
|
|
5176
5172
|
}
|
|
@@ -5197,7 +5193,13 @@
|
|
|
5197
5193
|
if (!this.isLookahead) startLoc = this.state.curPosition();
|
|
5198
5194
|
var start = this.state.pos;
|
|
5199
5195
|
var end = this.input.indexOf("*/", start + 2);
|
|
5200
|
-
|
|
5196
|
+
|
|
5197
|
+
if (end === -1) {
|
|
5198
|
+
throw this.raise(ErrorMessages.UnterminatedComment, {
|
|
5199
|
+
at: this.state.curPosition()
|
|
5200
|
+
});
|
|
5201
|
+
}
|
|
5202
|
+
|
|
5201
5203
|
this.state.pos = end + 2;
|
|
5202
5204
|
lineBreakG.lastIndex = start + 2;
|
|
5203
5205
|
|
|
@@ -5355,12 +5357,12 @@
|
|
|
5355
5357
|
|
|
5356
5358
|
finishToken(type, val) {
|
|
5357
5359
|
this.state.end = this.state.pos;
|
|
5360
|
+
this.state.endLoc = this.state.curPosition();
|
|
5358
5361
|
var prevType = this.state.type;
|
|
5359
5362
|
this.state.type = type;
|
|
5360
5363
|
this.state.value = val;
|
|
5361
5364
|
|
|
5362
5365
|
if (!this.isLookahead) {
|
|
5363
|
-
this.state.endLoc = this.state.curPosition();
|
|
5364
5366
|
this.updateContext(prevType);
|
|
5365
5367
|
}
|
|
5366
5368
|
}
|
|
@@ -5379,14 +5381,18 @@
|
|
|
5379
5381
|
var next = this.codePointAtPos(nextPos);
|
|
5380
5382
|
|
|
5381
5383
|
if (next >= 48 && next <= 57) {
|
|
5382
|
-
throw this.raise(
|
|
5384
|
+
throw this.raise(ErrorMessages.UnexpectedDigitAfterHash, {
|
|
5385
|
+
at: this.state.curPosition()
|
|
5386
|
+
});
|
|
5383
5387
|
}
|
|
5384
5388
|
|
|
5385
5389
|
if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
|
|
5386
5390
|
this.expectPlugin("recordAndTuple");
|
|
5387
5391
|
|
|
5388
5392
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") {
|
|
5389
|
-
throw this.raise(
|
|
5393
|
+
throw this.raise(next === 123 ? ErrorMessages.RecordExpressionHashIncorrectStartSyntaxType : ErrorMessages.TupleExpressionHashIncorrectStartSyntaxType, {
|
|
5394
|
+
at: this.state.curPosition()
|
|
5395
|
+
});
|
|
5390
5396
|
}
|
|
5391
5397
|
|
|
5392
5398
|
this.state.pos += 2;
|
|
@@ -5490,7 +5496,9 @@
|
|
|
5490
5496
|
|
|
5491
5497
|
if (this.hasPlugin("recordAndTuple") && next === 125) {
|
|
5492
5498
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
|
5493
|
-
throw this.raise(
|
|
5499
|
+
throw this.raise(ErrorMessages.RecordExpressionBarIncorrectEndSyntaxType, {
|
|
5500
|
+
at: this.state.curPosition()
|
|
5501
|
+
});
|
|
5494
5502
|
}
|
|
5495
5503
|
|
|
5496
5504
|
this.state.pos += 2;
|
|
@@ -5500,7 +5508,9 @@
|
|
|
5500
5508
|
|
|
5501
5509
|
if (this.hasPlugin("recordAndTuple") && next === 93) {
|
|
5502
5510
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
|
5503
|
-
throw this.raise(
|
|
5511
|
+
throw this.raise(ErrorMessages.TupleExpressionBarIncorrectEndSyntaxType, {
|
|
5512
|
+
at: this.state.curPosition()
|
|
5513
|
+
});
|
|
5504
5514
|
}
|
|
5505
5515
|
|
|
5506
5516
|
this.state.pos += 2;
|
|
@@ -5657,7 +5667,9 @@
|
|
|
5657
5667
|
case 91:
|
|
5658
5668
|
if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
|
|
5659
5669
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
|
5660
|
-
throw this.raise(
|
|
5670
|
+
throw this.raise(ErrorMessages.TupleExpressionBarIncorrectStartSyntaxType, {
|
|
5671
|
+
at: this.state.curPosition()
|
|
5672
|
+
});
|
|
5661
5673
|
}
|
|
5662
5674
|
|
|
5663
5675
|
this.state.pos += 2;
|
|
@@ -5677,7 +5689,9 @@
|
|
|
5677
5689
|
case 123:
|
|
5678
5690
|
if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
|
|
5679
5691
|
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
|
5680
|
-
throw this.raise(
|
|
5692
|
+
throw this.raise(ErrorMessages.RecordExpressionBarIncorrectStartSyntaxType, {
|
|
5693
|
+
at: this.state.curPosition()
|
|
5694
|
+
});
|
|
5681
5695
|
}
|
|
5682
5696
|
|
|
5683
5697
|
this.state.pos += 2;
|
|
@@ -5810,7 +5824,9 @@
|
|
|
5810
5824
|
|
|
5811
5825
|
}
|
|
5812
5826
|
|
|
5813
|
-
throw this.raise(
|
|
5827
|
+
throw this.raise(ErrorMessages.InvalidOrUnexpectedToken, {
|
|
5828
|
+
at: this.state.curPosition()
|
|
5829
|
+
}, String.fromCodePoint(code));
|
|
5814
5830
|
}
|
|
5815
5831
|
|
|
5816
5832
|
finishOp(type, size) {
|
|
@@ -5820,6 +5836,7 @@
|
|
|
5820
5836
|
}
|
|
5821
5837
|
|
|
5822
5838
|
readRegexp() {
|
|
5839
|
+
var startLoc = this.state.startLoc;
|
|
5823
5840
|
var start = this.state.start + 1;
|
|
5824
5841
|
var escaped, inClass;
|
|
5825
5842
|
var {
|
|
@@ -5828,13 +5845,17 @@
|
|
|
5828
5845
|
|
|
5829
5846
|
for (;; ++pos) {
|
|
5830
5847
|
if (pos >= this.length) {
|
|
5831
|
-
throw this.raise(
|
|
5848
|
+
throw this.raise(ErrorMessages.UnterminatedRegExp, {
|
|
5849
|
+
at: createPositionWithColumnOffset(startLoc, 1)
|
|
5850
|
+
});
|
|
5832
5851
|
}
|
|
5833
5852
|
|
|
5834
5853
|
var ch = this.input.charCodeAt(pos);
|
|
5835
5854
|
|
|
5836
5855
|
if (isNewLine(ch)) {
|
|
5837
|
-
throw this.raise(
|
|
5856
|
+
throw this.raise(ErrorMessages.UnterminatedRegExp, {
|
|
5857
|
+
at: createPositionWithColumnOffset(startLoc, 1)
|
|
5858
|
+
});
|
|
5838
5859
|
}
|
|
5839
5860
|
|
|
5840
5861
|
if (escaped) {
|
|
@@ -5862,10 +5883,14 @@
|
|
|
5862
5883
|
|
|
5863
5884
|
if (VALID_REGEX_FLAGS.has(cp)) {
|
|
5864
5885
|
if (mods.includes(char)) {
|
|
5865
|
-
this.raise(
|
|
5886
|
+
this.raise(ErrorMessages.DuplicateRegExpFlags, {
|
|
5887
|
+
at: createPositionWithColumnOffset(startLoc, pos + 2 - start)
|
|
5888
|
+
});
|
|
5866
5889
|
}
|
|
5867
5890
|
} else if (isIdentifierChar(cp) || cp === 92) {
|
|
5868
|
-
this.raise(
|
|
5891
|
+
this.raise(ErrorMessages.MalformedRegExpFlags, {
|
|
5892
|
+
at: createPositionWithColumnOffset(startLoc, pos + 2 - start)
|
|
5893
|
+
});
|
|
5869
5894
|
} else {
|
|
5870
5895
|
break;
|
|
5871
5896
|
}
|
|
@@ -5898,13 +5923,19 @@
|
|
|
5898
5923
|
var next = this.input.charCodeAt(this.state.pos + 1);
|
|
5899
5924
|
|
|
5900
5925
|
if (allowedSiblings.indexOf(next) === -1) {
|
|
5901
|
-
this.raise(
|
|
5926
|
+
this.raise(ErrorMessages.UnexpectedNumericSeparator, {
|
|
5927
|
+
at: this.state.curPosition()
|
|
5928
|
+
});
|
|
5902
5929
|
} else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
|
|
5903
|
-
this.raise(
|
|
5930
|
+
this.raise(ErrorMessages.UnexpectedNumericSeparator, {
|
|
5931
|
+
at: this.state.curPosition()
|
|
5932
|
+
});
|
|
5904
5933
|
}
|
|
5905
5934
|
|
|
5906
5935
|
if (!allowNumSeparator) {
|
|
5907
|
-
this.raise(
|
|
5936
|
+
this.raise(ErrorMessages.NumericSeparatorInEscapeSequence, {
|
|
5937
|
+
at: this.state.curPosition()
|
|
5938
|
+
});
|
|
5908
5939
|
}
|
|
5909
5940
|
|
|
5910
5941
|
++this.state.pos;
|
|
@@ -5924,7 +5955,9 @@
|
|
|
5924
5955
|
if (val >= radix) {
|
|
5925
5956
|
if (this.options.errorRecovery && val <= 9) {
|
|
5926
5957
|
val = 0;
|
|
5927
|
-
this.raise(
|
|
5958
|
+
this.raise(ErrorMessages.InvalidDigit, {
|
|
5959
|
+
at: this.state.curPosition()
|
|
5960
|
+
}, radix);
|
|
5928
5961
|
} else if (forceLen) {
|
|
5929
5962
|
val = 0;
|
|
5930
5963
|
invalid = true;
|
|
@@ -5945,13 +5978,15 @@
|
|
|
5945
5978
|
}
|
|
5946
5979
|
|
|
5947
5980
|
readRadixNumber(radix) {
|
|
5948
|
-
var
|
|
5981
|
+
var startLoc = this.state.curPosition();
|
|
5949
5982
|
var isBigInt = false;
|
|
5950
5983
|
this.state.pos += 2;
|
|
5951
5984
|
var val = this.readInt(radix);
|
|
5952
5985
|
|
|
5953
5986
|
if (val == null) {
|
|
5954
|
-
this.raise(
|
|
5987
|
+
this.raise(ErrorMessages.InvalidDigit, {
|
|
5988
|
+
at: createPositionWithColumnOffset(startLoc, 2)
|
|
5989
|
+
}, radix);
|
|
5955
5990
|
}
|
|
5956
5991
|
|
|
5957
5992
|
var next = this.input.charCodeAt(this.state.pos);
|
|
@@ -5960,15 +5995,19 @@
|
|
|
5960
5995
|
++this.state.pos;
|
|
5961
5996
|
isBigInt = true;
|
|
5962
5997
|
} else if (next === 109) {
|
|
5963
|
-
throw this.raise(
|
|
5998
|
+
throw this.raise(ErrorMessages.InvalidDecimal, {
|
|
5999
|
+
at: startLoc
|
|
6000
|
+
});
|
|
5964
6001
|
}
|
|
5965
6002
|
|
|
5966
6003
|
if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
|
|
5967
|
-
throw this.raise(
|
|
6004
|
+
throw this.raise(ErrorMessages.NumberIdentifier, {
|
|
6005
|
+
at: this.state.curPosition()
|
|
6006
|
+
});
|
|
5968
6007
|
}
|
|
5969
6008
|
|
|
5970
6009
|
if (isBigInt) {
|
|
5971
|
-
var str = this.input.slice(
|
|
6010
|
+
var str = this.input.slice(indexes.get(startLoc), this.state.pos).replace(/[_n]/g, "");
|
|
5972
6011
|
this.finishToken(127, str);
|
|
5973
6012
|
return;
|
|
5974
6013
|
}
|
|
@@ -5978,6 +6017,7 @@
|
|
|
5978
6017
|
|
|
5979
6018
|
readNumber(startsWithDot) {
|
|
5980
6019
|
var start = this.state.pos;
|
|
6020
|
+
var startLoc = this.state.curPosition();
|
|
5981
6021
|
var isFloat = false;
|
|
5982
6022
|
var isBigInt = false;
|
|
5983
6023
|
var isDecimal = false;
|
|
@@ -5985,20 +6025,24 @@
|
|
|
5985
6025
|
var isOctal = false;
|
|
5986
6026
|
|
|
5987
6027
|
if (!startsWithDot && this.readInt(10) === null) {
|
|
5988
|
-
this.raise(
|
|
6028
|
+
this.raise(ErrorMessages.InvalidNumber, {
|
|
6029
|
+
at: this.state.curPosition()
|
|
6030
|
+
});
|
|
5989
6031
|
}
|
|
5990
6032
|
|
|
5991
6033
|
var hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
|
5992
6034
|
|
|
5993
6035
|
if (hasLeadingZero) {
|
|
5994
6036
|
var integer = this.input.slice(start, this.state.pos);
|
|
5995
|
-
this.recordStrictModeErrors(
|
|
6037
|
+
this.recordStrictModeErrors(ErrorMessages.StrictOctalLiteral, startLoc);
|
|
5996
6038
|
|
|
5997
6039
|
if (!this.state.strict) {
|
|
5998
6040
|
var underscorePos = integer.indexOf("_");
|
|
5999
6041
|
|
|
6000
6042
|
if (underscorePos > 0) {
|
|
6001
|
-
this.raise(
|
|
6043
|
+
this.raise(ErrorMessages.ZeroDigitNumericSeparator, {
|
|
6044
|
+
at: createPositionWithColumnOffset(startLoc, underscorePos)
|
|
6045
|
+
});
|
|
6002
6046
|
}
|
|
6003
6047
|
}
|
|
6004
6048
|
|
|
@@ -6022,7 +6066,9 @@
|
|
|
6022
6066
|
}
|
|
6023
6067
|
|
|
6024
6068
|
if (this.readInt(10) === null) {
|
|
6025
|
-
this.raise(
|
|
6069
|
+
this.raise(ErrorMessages.InvalidOrMissingExponent, {
|
|
6070
|
+
at: startLoc
|
|
6071
|
+
});
|
|
6026
6072
|
}
|
|
6027
6073
|
|
|
6028
6074
|
isFloat = true;
|
|
@@ -6032,7 +6078,9 @@
|
|
|
6032
6078
|
|
|
6033
6079
|
if (next === 110) {
|
|
6034
6080
|
if (isFloat || hasLeadingZero) {
|
|
6035
|
-
this.raise(
|
|
6081
|
+
this.raise(ErrorMessages.InvalidBigIntLiteral, {
|
|
6082
|
+
at: startLoc
|
|
6083
|
+
});
|
|
6036
6084
|
}
|
|
6037
6085
|
|
|
6038
6086
|
++this.state.pos;
|
|
@@ -6040,10 +6088,12 @@
|
|
|
6040
6088
|
}
|
|
6041
6089
|
|
|
6042
6090
|
if (next === 109) {
|
|
6043
|
-
this.expectPlugin("decimal", this.state.
|
|
6091
|
+
this.expectPlugin("decimal", this.state.curPosition());
|
|
6044
6092
|
|
|
6045
6093
|
if (hasExponent || hasLeadingZero) {
|
|
6046
|
-
this.raise(
|
|
6094
|
+
this.raise(ErrorMessages.InvalidDecimal, {
|
|
6095
|
+
at: startLoc
|
|
6096
|
+
});
|
|
6047
6097
|
}
|
|
6048
6098
|
|
|
6049
6099
|
++this.state.pos;
|
|
@@ -6051,7 +6101,9 @@
|
|
|
6051
6101
|
}
|
|
6052
6102
|
|
|
6053
6103
|
if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
|
|
6054
|
-
throw this.raise(
|
|
6104
|
+
throw this.raise(ErrorMessages.NumberIdentifier, {
|
|
6105
|
+
at: this.state.curPosition()
|
|
6106
|
+
});
|
|
6055
6107
|
}
|
|
6056
6108
|
|
|
6057
6109
|
var str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
|
|
@@ -6075,13 +6127,15 @@
|
|
|
6075
6127
|
var code;
|
|
6076
6128
|
|
|
6077
6129
|
if (ch === 123) {
|
|
6078
|
-
|
|
6130
|
+
++this.state.pos;
|
|
6079
6131
|
code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, true, throwOnInvalid);
|
|
6080
6132
|
++this.state.pos;
|
|
6081
6133
|
|
|
6082
6134
|
if (code !== null && code > 0x10ffff) {
|
|
6083
6135
|
if (throwOnInvalid) {
|
|
6084
|
-
this.raise(
|
|
6136
|
+
this.raise(ErrorMessages.InvalidCodePoint, {
|
|
6137
|
+
at: this.state.curPosition()
|
|
6138
|
+
});
|
|
6085
6139
|
} else {
|
|
6086
6140
|
return null;
|
|
6087
6141
|
}
|
|
@@ -6099,7 +6153,9 @@
|
|
|
6099
6153
|
|
|
6100
6154
|
for (;;) {
|
|
6101
6155
|
if (this.state.pos >= this.length) {
|
|
6102
|
-
throw this.raise(
|
|
6156
|
+
throw this.raise(ErrorMessages.UnterminatedString, {
|
|
6157
|
+
at: this.state.startLoc
|
|
6158
|
+
});
|
|
6103
6159
|
}
|
|
6104
6160
|
|
|
6105
6161
|
var ch = this.input.charCodeAt(this.state.pos);
|
|
@@ -6114,7 +6170,9 @@
|
|
|
6114
6170
|
++this.state.curLine;
|
|
6115
6171
|
this.state.lineStart = this.state.pos;
|
|
6116
6172
|
} else if (isNewLine(ch)) {
|
|
6117
|
-
throw this.raise(
|
|
6173
|
+
throw this.raise(ErrorMessages.UnterminatedString, {
|
|
6174
|
+
at: this.state.startLoc
|
|
6175
|
+
});
|
|
6118
6176
|
} else {
|
|
6119
6177
|
++this.state.pos;
|
|
6120
6178
|
}
|
|
@@ -6126,7 +6184,7 @@
|
|
|
6126
6184
|
|
|
6127
6185
|
readTemplateContinuation() {
|
|
6128
6186
|
if (!this.match(8)) {
|
|
6129
|
-
this.unexpected(
|
|
6187
|
+
this.unexpected(null, 8);
|
|
6130
6188
|
}
|
|
6131
6189
|
|
|
6132
6190
|
this.state.pos--;
|
|
@@ -6141,7 +6199,9 @@
|
|
|
6141
6199
|
|
|
6142
6200
|
for (;;) {
|
|
6143
6201
|
if (this.state.pos >= this.length) {
|
|
6144
|
-
throw this.raise(
|
|
6202
|
+
throw this.raise(ErrorMessages.UnterminatedTemplate, {
|
|
6203
|
+
at: createPositionWithColumnOffset(this.state.startLoc, 1)
|
|
6204
|
+
});
|
|
6145
6205
|
}
|
|
6146
6206
|
|
|
6147
6207
|
var ch = this.input.charCodeAt(this.state.pos);
|
|
@@ -6199,11 +6259,18 @@
|
|
|
6199
6259
|
}
|
|
6200
6260
|
}
|
|
6201
6261
|
|
|
6202
|
-
recordStrictModeErrors(
|
|
6203
|
-
|
|
6204
|
-
|
|
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
|
+
});
|
|
6205
6269
|
} else {
|
|
6206
|
-
this.state.strictErrors.set(
|
|
6270
|
+
this.state.strictErrors.set(index, {
|
|
6271
|
+
loc,
|
|
6272
|
+
message
|
|
6273
|
+
});
|
|
6207
6274
|
}
|
|
6208
6275
|
}
|
|
6209
6276
|
|
|
@@ -6262,12 +6329,12 @@
|
|
|
6262
6329
|
if (inTemplate) {
|
|
6263
6330
|
return null;
|
|
6264
6331
|
} else {
|
|
6265
|
-
this.recordStrictModeErrors(this.state.
|
|
6332
|
+
this.recordStrictModeErrors(ErrorMessages.StrictNumericEscape, createPositionWithColumnOffset(this.state.curPosition(), -1));
|
|
6266
6333
|
}
|
|
6267
6334
|
|
|
6268
6335
|
default:
|
|
6269
6336
|
if (ch >= 48 && ch <= 55) {
|
|
6270
|
-
var codePos = this.state.
|
|
6337
|
+
var codePos = createPositionWithColumnOffset(this.state.curPosition(), -1);
|
|
6271
6338
|
var match = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/);
|
|
6272
6339
|
var octalStr = match[0];
|
|
6273
6340
|
var octal = parseInt(octalStr, 8);
|
|
@@ -6284,7 +6351,7 @@
|
|
|
6284
6351
|
if (inTemplate) {
|
|
6285
6352
|
return null;
|
|
6286
6353
|
} else {
|
|
6287
|
-
this.recordStrictModeErrors(
|
|
6354
|
+
this.recordStrictModeErrors(ErrorMessages.StrictNumericEscape, codePos);
|
|
6288
6355
|
}
|
|
6289
6356
|
}
|
|
6290
6357
|
|
|
@@ -6296,14 +6363,16 @@
|
|
|
6296
6363
|
}
|
|
6297
6364
|
|
|
6298
6365
|
readHexChar(len, forceLen, throwOnInvalid) {
|
|
6299
|
-
var
|
|
6366
|
+
var codeLoc = this.state.curPosition();
|
|
6300
6367
|
var n = this.readInt(16, len, forceLen, false);
|
|
6301
6368
|
|
|
6302
6369
|
if (n === null) {
|
|
6303
6370
|
if (throwOnInvalid) {
|
|
6304
|
-
this.raise(
|
|
6371
|
+
this.raise(ErrorMessages.InvalidEscapeSequence, {
|
|
6372
|
+
at: codeLoc
|
|
6373
|
+
});
|
|
6305
6374
|
} else {
|
|
6306
|
-
this.state.pos =
|
|
6375
|
+
this.state.pos = indexes.get(codeLoc) - 1;
|
|
6307
6376
|
}
|
|
6308
6377
|
}
|
|
6309
6378
|
|
|
@@ -6328,11 +6397,13 @@
|
|
|
6328
6397
|
} else if (ch === 92) {
|
|
6329
6398
|
this.state.containsEsc = true;
|
|
6330
6399
|
word += this.input.slice(chunkStart, this.state.pos);
|
|
6331
|
-
var escStart = this.state.
|
|
6400
|
+
var escStart = this.state.curPosition();
|
|
6332
6401
|
var identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
|
|
6333
6402
|
|
|
6334
6403
|
if (this.input.charCodeAt(++this.state.pos) !== 117) {
|
|
6335
|
-
this.raise(
|
|
6404
|
+
this.raise(ErrorMessages.MissingUnicodeEscape, {
|
|
6405
|
+
at: this.state.curPosition()
|
|
6406
|
+
});
|
|
6336
6407
|
chunkStart = this.state.pos - 1;
|
|
6337
6408
|
continue;
|
|
6338
6409
|
}
|
|
@@ -6342,7 +6413,9 @@
|
|
|
6342
6413
|
|
|
6343
6414
|
if (esc !== null) {
|
|
6344
6415
|
if (!identifierCheck(esc)) {
|
|
6345
|
-
this.raise(
|
|
6416
|
+
this.raise(ErrorMessages.EscapedCharNotAnIdentifier, {
|
|
6417
|
+
at: escStart
|
|
6418
|
+
});
|
|
6346
6419
|
}
|
|
6347
6420
|
|
|
6348
6421
|
word += String.fromCodePoint(esc);
|
|
@@ -6374,7 +6447,9 @@
|
|
|
6374
6447
|
} = this.state;
|
|
6375
6448
|
|
|
6376
6449
|
if (tokenIsKeyword(type) && this.state.containsEsc) {
|
|
6377
|
-
this.raise(
|
|
6450
|
+
this.raise(ErrorMessages.InvalidEscapedReservedWord, {
|
|
6451
|
+
at: this.state.startLoc
|
|
6452
|
+
}, tokenLabelName(type));
|
|
6378
6453
|
}
|
|
6379
6454
|
}
|
|
6380
6455
|
|
|
@@ -6410,18 +6485,20 @@
|
|
|
6410
6485
|
var oldClassScope = this.stack.pop();
|
|
6411
6486
|
var current = this.current();
|
|
6412
6487
|
|
|
6413
|
-
for (var [name,
|
|
6488
|
+
for (var [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
|
|
6414
6489
|
if (current) {
|
|
6415
6490
|
if (!current.undefinedPrivateNames.has(name)) {
|
|
6416
|
-
current.undefinedPrivateNames.set(name,
|
|
6491
|
+
current.undefinedPrivateNames.set(name, loc);
|
|
6417
6492
|
}
|
|
6418
6493
|
} else {
|
|
6419
|
-
this.raise(
|
|
6494
|
+
this.raise(ErrorMessages.InvalidPrivateFieldResolution, {
|
|
6495
|
+
at: loc
|
|
6496
|
+
}, name);
|
|
6420
6497
|
}
|
|
6421
6498
|
}
|
|
6422
6499
|
}
|
|
6423
6500
|
|
|
6424
|
-
declarePrivateName(name, elementType,
|
|
6501
|
+
declarePrivateName(name, elementType, loc) {
|
|
6425
6502
|
var {
|
|
6426
6503
|
privateNames,
|
|
6427
6504
|
loneAccessors,
|
|
@@ -6445,14 +6522,16 @@
|
|
|
6445
6522
|
}
|
|
6446
6523
|
|
|
6447
6524
|
if (redefined) {
|
|
6448
|
-
this.raise(
|
|
6525
|
+
this.raise(ErrorMessages.PrivateNameRedeclaration, {
|
|
6526
|
+
at: loc
|
|
6527
|
+
}, name);
|
|
6449
6528
|
}
|
|
6450
6529
|
|
|
6451
6530
|
privateNames.add(name);
|
|
6452
6531
|
undefinedPrivateNames.delete(name);
|
|
6453
6532
|
}
|
|
6454
6533
|
|
|
6455
|
-
usePrivateName(name,
|
|
6534
|
+
usePrivateName(name, loc) {
|
|
6456
6535
|
var classScope;
|
|
6457
6536
|
|
|
6458
6537
|
for (classScope of this.stack) {
|
|
@@ -6460,9 +6539,11 @@
|
|
|
6460
6539
|
}
|
|
6461
6540
|
|
|
6462
6541
|
if (classScope) {
|
|
6463
|
-
classScope.undefinedPrivateNames.set(name,
|
|
6542
|
+
classScope.undefinedPrivateNames.set(name, loc);
|
|
6464
6543
|
} else {
|
|
6465
|
-
this.raise(
|
|
6544
|
+
this.raise(ErrorMessages.InvalidPrivateFieldResolution, {
|
|
6545
|
+
at: loc
|
|
6546
|
+
}, name);
|
|
6466
6547
|
}
|
|
6467
6548
|
}
|
|
6468
6549
|
|
|
@@ -6496,12 +6577,15 @@
|
|
|
6496
6577
|
this.errors = new Map();
|
|
6497
6578
|
}
|
|
6498
6579
|
|
|
6499
|
-
recordDeclarationError(
|
|
6500
|
-
this.errors.set(
|
|
6580
|
+
recordDeclarationError(message, loc) {
|
|
6581
|
+
this.errors.set(indexes.get(loc), {
|
|
6582
|
+
message,
|
|
6583
|
+
loc
|
|
6584
|
+
});
|
|
6501
6585
|
}
|
|
6502
6586
|
|
|
6503
|
-
clearDeclarationError(
|
|
6504
|
-
this.errors.delete(
|
|
6587
|
+
clearDeclarationError(loc) {
|
|
6588
|
+
this.errors.delete(indexes.get(loc));
|
|
6505
6589
|
}
|
|
6506
6590
|
|
|
6507
6591
|
iterateErrors(iterator) {
|
|
@@ -6524,7 +6608,7 @@
|
|
|
6524
6608
|
this.stack.pop();
|
|
6525
6609
|
}
|
|
6526
6610
|
|
|
6527
|
-
recordParameterInitializerError(
|
|
6611
|
+
recordParameterInitializerError(loc, template) {
|
|
6528
6612
|
var {
|
|
6529
6613
|
stack
|
|
6530
6614
|
} = this;
|
|
@@ -6533,7 +6617,7 @@
|
|
|
6533
6617
|
|
|
6534
6618
|
while (!scope.isCertainlyParameterDeclaration()) {
|
|
6535
6619
|
if (scope.canBeArrowParameterDeclaration()) {
|
|
6536
|
-
scope.recordDeclarationError(
|
|
6620
|
+
scope.recordDeclarationError(template, loc);
|
|
6537
6621
|
} else {
|
|
6538
6622
|
return;
|
|
6539
6623
|
}
|
|
@@ -6541,25 +6625,29 @@
|
|
|
6541
6625
|
scope = stack[--i];
|
|
6542
6626
|
}
|
|
6543
6627
|
|
|
6544
|
-
this.raise(
|
|
6628
|
+
this.raise(template, {
|
|
6629
|
+
at: loc
|
|
6630
|
+
});
|
|
6545
6631
|
}
|
|
6546
6632
|
|
|
6547
|
-
recordParenthesizedIdentifierError(
|
|
6633
|
+
recordParenthesizedIdentifierError(template, loc) {
|
|
6548
6634
|
var {
|
|
6549
6635
|
stack
|
|
6550
6636
|
} = this;
|
|
6551
6637
|
var scope = stack[stack.length - 1];
|
|
6552
6638
|
|
|
6553
6639
|
if (scope.isCertainlyParameterDeclaration()) {
|
|
6554
|
-
this.raise(
|
|
6640
|
+
this.raise(template, {
|
|
6641
|
+
at: loc
|
|
6642
|
+
});
|
|
6555
6643
|
} else if (scope.canBeArrowParameterDeclaration()) {
|
|
6556
|
-
scope.recordDeclarationError(
|
|
6644
|
+
scope.recordDeclarationError(template, loc);
|
|
6557
6645
|
} else {
|
|
6558
6646
|
return;
|
|
6559
6647
|
}
|
|
6560
6648
|
}
|
|
6561
6649
|
|
|
6562
|
-
recordAsyncArrowParametersError(
|
|
6650
|
+
recordAsyncArrowParametersError(template, loc) {
|
|
6563
6651
|
var {
|
|
6564
6652
|
stack
|
|
6565
6653
|
} = this;
|
|
@@ -6568,7 +6656,7 @@
|
|
|
6568
6656
|
|
|
6569
6657
|
while (scope.canBeArrowParameterDeclaration()) {
|
|
6570
6658
|
if (scope.type === kMaybeAsyncArrowParameterDeclaration) {
|
|
6571
|
-
scope.recordDeclarationError(
|
|
6659
|
+
scope.recordDeclarationError(template, loc);
|
|
6572
6660
|
}
|
|
6573
6661
|
|
|
6574
6662
|
scope = stack[--i];
|
|
@@ -6581,13 +6669,19 @@
|
|
|
6581
6669
|
} = this;
|
|
6582
6670
|
var currentScope = stack[stack.length - 1];
|
|
6583
6671
|
if (!currentScope.canBeArrowParameterDeclaration()) return;
|
|
6584
|
-
currentScope.iterateErrors(
|
|
6585
|
-
|
|
6672
|
+
currentScope.iterateErrors(_ref6 => {
|
|
6673
|
+
var {
|
|
6674
|
+
message,
|
|
6675
|
+
loc
|
|
6676
|
+
} = _ref6;
|
|
6677
|
+
this.raise(message, {
|
|
6678
|
+
at: loc
|
|
6679
|
+
});
|
|
6586
6680
|
var i = stack.length - 2;
|
|
6587
6681
|
var scope = stack[i];
|
|
6588
6682
|
|
|
6589
6683
|
while (scope.canBeArrowParameterDeclaration()) {
|
|
6590
|
-
scope.clearDeclarationError(
|
|
6684
|
+
scope.clearDeclarationError(loc);
|
|
6591
6685
|
scope = stack[--i];
|
|
6592
6686
|
}
|
|
6593
6687
|
});
|
|
@@ -6657,10 +6751,19 @@
|
|
|
6657
6751
|
}
|
|
6658
6752
|
|
|
6659
6753
|
class UtilParser extends Tokenizer {
|
|
6660
|
-
addExtra(node, key,
|
|
6754
|
+
addExtra(node, key, value) {
|
|
6755
|
+
var enumerable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
6661
6756
|
if (!node) return;
|
|
6662
6757
|
var extra = node.extra = node.extra || {};
|
|
6663
|
-
|
|
6758
|
+
|
|
6759
|
+
if (enumerable) {
|
|
6760
|
+
extra[key] = value;
|
|
6761
|
+
} else {
|
|
6762
|
+
Object.defineProperty(extra, key, {
|
|
6763
|
+
enumerable,
|
|
6764
|
+
value
|
|
6765
|
+
});
|
|
6766
|
+
}
|
|
6664
6767
|
}
|
|
6665
6768
|
|
|
6666
6769
|
isContextual(token) {
|
|
@@ -6693,7 +6796,15 @@
|
|
|
6693
6796
|
}
|
|
6694
6797
|
|
|
6695
6798
|
expectContextual(token, template) {
|
|
6696
|
-
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
|
+
}
|
|
6697
6808
|
}
|
|
6698
6809
|
|
|
6699
6810
|
canInsertSemicolon() {
|
|
@@ -6701,7 +6812,7 @@
|
|
|
6701
6812
|
}
|
|
6702
6813
|
|
|
6703
6814
|
hasPrecedingLineBreak() {
|
|
6704
|
-
return lineBreak.test(this.input.slice(this.state.
|
|
6815
|
+
return lineBreak.test(this.input.slice(indexes.get(this.state.lastTokEndLoc), this.state.start));
|
|
6705
6816
|
}
|
|
6706
6817
|
|
|
6707
6818
|
hasFollowingLineBreak() {
|
|
@@ -6716,41 +6827,37 @@
|
|
|
6716
6827
|
semicolon() {
|
|
6717
6828
|
var allowAsi = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
6718
6829
|
if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
|
|
6719
|
-
this.raise(
|
|
6830
|
+
this.raise(ErrorMessages.MissingSemicolon, {
|
|
6831
|
+
at: this.state.lastTokEndLoc
|
|
6832
|
+
});
|
|
6720
6833
|
}
|
|
6721
6834
|
|
|
6722
|
-
expect(type,
|
|
6723
|
-
this.eat(type) || this.unexpected(
|
|
6835
|
+
expect(type, loc) {
|
|
6836
|
+
this.eat(type) || this.unexpected(loc, type);
|
|
6724
6837
|
}
|
|
6725
6838
|
|
|
6726
6839
|
assertNoSpace() {
|
|
6727
6840
|
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Unexpected space.";
|
|
6728
6841
|
|
|
6729
|
-
if (this.state.start > this.state.
|
|
6730
|
-
this.raise(
|
|
6842
|
+
if (this.state.start > indexes.get(this.state.lastTokEndLoc)) {
|
|
6843
|
+
this.raise({
|
|
6731
6844
|
code: ErrorCodes.SyntaxError,
|
|
6732
6845
|
reasonCode: "UnexpectedSpace",
|
|
6733
6846
|
template: message
|
|
6847
|
+
}, {
|
|
6848
|
+
at: this.state.lastTokEndLoc
|
|
6734
6849
|
});
|
|
6735
6850
|
}
|
|
6736
6851
|
}
|
|
6737
6852
|
|
|
6738
|
-
unexpected(
|
|
6739
|
-
|
|
6853
|
+
unexpected(loc, type) {
|
|
6854
|
+
throw this.raise({
|
|
6740
6855
|
code: ErrorCodes.SyntaxError,
|
|
6741
6856
|
reasonCode: "UnexpectedToken",
|
|
6742
|
-
template: "Unexpected token"
|
|
6743
|
-
}
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
messageOrType = {
|
|
6747
|
-
code: ErrorCodes.SyntaxError,
|
|
6748
|
-
reasonCode: "UnexpectedToken",
|
|
6749
|
-
template: "Unexpected token, expected \"".concat(tokenLabelName(messageOrType), "\"")
|
|
6750
|
-
};
|
|
6751
|
-
}
|
|
6752
|
-
|
|
6753
|
-
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
|
+
});
|
|
6754
6861
|
}
|
|
6755
6862
|
|
|
6756
6863
|
getPluginNamesFromConfigs(pluginConfigs) {
|
|
@@ -6763,9 +6870,9 @@
|
|
|
6763
6870
|
});
|
|
6764
6871
|
}
|
|
6765
6872
|
|
|
6766
|
-
expectPlugin(pluginConfig,
|
|
6873
|
+
expectPlugin(pluginConfig, loc) {
|
|
6767
6874
|
if (!this.hasPlugin(pluginConfig)) {
|
|
6768
|
-
throw this.raiseWithData(
|
|
6875
|
+
throw this.raiseWithData(loc != null ? loc : this.state.startLoc, {
|
|
6769
6876
|
missingPlugin: this.getPluginNamesFromConfigs([pluginConfig])
|
|
6770
6877
|
}, "This experimental syntax requires enabling the parser plugin: ".concat(JSON.stringify(pluginConfig), "."));
|
|
6771
6878
|
}
|
|
@@ -6773,9 +6880,9 @@
|
|
|
6773
6880
|
return true;
|
|
6774
6881
|
}
|
|
6775
6882
|
|
|
6776
|
-
expectOnePlugin(pluginConfigs
|
|
6883
|
+
expectOnePlugin(pluginConfigs) {
|
|
6777
6884
|
if (!pluginConfigs.some(c => this.hasPlugin(c))) {
|
|
6778
|
-
throw this.raiseWithData(
|
|
6885
|
+
throw this.raiseWithData(this.state.startLoc, {
|
|
6779
6886
|
missingPlugin: this.getPluginNamesFromConfigs(pluginConfigs)
|
|
6780
6887
|
}, "This experimental syntax requires enabling one of the following parser plugin(s): ".concat(pluginConfigs.map(c => JSON.stringify(c)).join(", "), "."));
|
|
6781
6888
|
}
|
|
@@ -6845,26 +6952,30 @@
|
|
|
6845
6952
|
checkExpressionErrors(refExpressionErrors, andThrow) {
|
|
6846
6953
|
if (!refExpressionErrors) return false;
|
|
6847
6954
|
var {
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6955
|
+
shorthandAssignLoc,
|
|
6956
|
+
doubleProtoLoc,
|
|
6957
|
+
optionalParametersLoc
|
|
6851
6958
|
} = refExpressionErrors;
|
|
6852
|
-
var hasErrors =
|
|
6959
|
+
var hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc;
|
|
6853
6960
|
|
|
6854
6961
|
if (!andThrow) {
|
|
6855
6962
|
return hasErrors;
|
|
6856
|
-
}
|
|
6857
|
-
if (shorthandAssign >= 0) {
|
|
6858
|
-
this.raise(shorthandAssign, ErrorMessages.InvalidCoverInitializedName);
|
|
6859
|
-
}
|
|
6963
|
+
}
|
|
6860
6964
|
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6965
|
+
if (shorthandAssignLoc != null) {
|
|
6966
|
+
this.raise(ErrorMessages.InvalidCoverInitializedName, {
|
|
6967
|
+
at: shorthandAssignLoc
|
|
6968
|
+
});
|
|
6969
|
+
}
|
|
6864
6970
|
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6971
|
+
if (doubleProtoLoc != null) {
|
|
6972
|
+
this.raise(ErrorMessages.DuplicateProto, {
|
|
6973
|
+
at: doubleProtoLoc
|
|
6974
|
+
});
|
|
6975
|
+
}
|
|
6976
|
+
|
|
6977
|
+
if (optionalParametersLoc != null) {
|
|
6978
|
+
this.unexpected(optionalParametersLoc);
|
|
6868
6979
|
}
|
|
6869
6980
|
}
|
|
6870
6981
|
|
|
@@ -6939,9 +7050,9 @@
|
|
|
6939
7050
|
|
|
6940
7051
|
class ExpressionErrors {
|
|
6941
7052
|
constructor() {
|
|
6942
|
-
this.
|
|
6943
|
-
this.
|
|
6944
|
-
this.
|
|
7053
|
+
this.shorthandAssignLoc = null;
|
|
7054
|
+
this.doubleProtoLoc = null;
|
|
7055
|
+
this.optionalParametersLoc = null;
|
|
6945
7056
|
}
|
|
6946
7057
|
|
|
6947
7058
|
}
|
|
@@ -7051,14 +7162,14 @@
|
|
|
7051
7162
|
}
|
|
7052
7163
|
|
|
7053
7164
|
finishNode(node, type) {
|
|
7054
|
-
return this.finishNodeAt(node, type, this.state.
|
|
7165
|
+
return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
|
|
7055
7166
|
}
|
|
7056
7167
|
|
|
7057
|
-
finishNodeAt(node, type,
|
|
7168
|
+
finishNodeAt(node, type, endLoc) {
|
|
7058
7169
|
node.type = type;
|
|
7059
|
-
node.end =
|
|
7060
|
-
node.loc.end =
|
|
7061
|
-
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;
|
|
7062
7173
|
if (this.options.attachComment) this.processComment(node);
|
|
7063
7174
|
return node;
|
|
7064
7175
|
}
|
|
@@ -7070,11 +7181,10 @@
|
|
|
7070
7181
|
}
|
|
7071
7182
|
|
|
7072
7183
|
resetEndLocation(node) {
|
|
7073
|
-
var
|
|
7074
|
-
|
|
7075
|
-
node.end = end;
|
|
7184
|
+
var endLoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEndLoc;
|
|
7185
|
+
node.end = indexes.get(endLoc);
|
|
7076
7186
|
node.loc.end = endLoc;
|
|
7077
|
-
if (this.options.ranges) node.range[1] = end;
|
|
7187
|
+
if (this.options.ranges) node.range[1] = node.end;
|
|
7078
7188
|
}
|
|
7079
7189
|
|
|
7080
7190
|
resetStartLocationFromNode(node, locationNode) {
|
|
@@ -7220,12 +7330,14 @@
|
|
|
7220
7330
|
|
|
7221
7331
|
flowParsePredicate() {
|
|
7222
7332
|
var node = this.startNode();
|
|
7223
|
-
var
|
|
7333
|
+
var moduloLoc = this.state.startLoc;
|
|
7224
7334
|
this.next();
|
|
7225
7335
|
this.expectContextual(103);
|
|
7226
7336
|
|
|
7227
|
-
if (this.state.lastTokStart >
|
|
7228
|
-
this.raise(
|
|
7337
|
+
if (this.state.lastTokStart > indexes.get(moduloLoc) + 1) {
|
|
7338
|
+
this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, {
|
|
7339
|
+
at: moduloLoc
|
|
7340
|
+
});
|
|
7229
7341
|
}
|
|
7230
7342
|
|
|
7231
7343
|
if (this.eat(10)) {
|
|
@@ -7288,7 +7400,7 @@
|
|
|
7288
7400
|
id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
|
|
7289
7401
|
this.resetEndLocation(id);
|
|
7290
7402
|
this.semicolon();
|
|
7291
|
-
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);
|
|
7292
7404
|
return this.finishNode(node, "DeclareFunction");
|
|
7293
7405
|
}
|
|
7294
7406
|
|
|
@@ -7304,7 +7416,9 @@
|
|
|
7304
7416
|
return this.flowParseDeclareModuleExports(node);
|
|
7305
7417
|
} else {
|
|
7306
7418
|
if (insideModule) {
|
|
7307
|
-
this.raise(
|
|
7419
|
+
this.raise(FlowErrors.NestedDeclareModule, {
|
|
7420
|
+
at: this.state.lastTokStartLoc
|
|
7421
|
+
});
|
|
7308
7422
|
}
|
|
7309
7423
|
|
|
7310
7424
|
return this.flowParseDeclareModule(node);
|
|
@@ -7325,7 +7439,7 @@
|
|
|
7325
7439
|
flowParseDeclareVariable(node) {
|
|
7326
7440
|
this.next();
|
|
7327
7441
|
node.id = this.flowParseTypeAnnotatableIdentifier(true);
|
|
7328
|
-
this.scope.declareName(node.id.name, BIND_VAR, node.id.start);
|
|
7442
|
+
this.scope.declareName(node.id.name, BIND_VAR, node.id.loc.start);
|
|
7329
7443
|
this.semicolon();
|
|
7330
7444
|
return this.finishNode(node, "DeclareVariable");
|
|
7331
7445
|
}
|
|
@@ -7350,7 +7464,9 @@
|
|
|
7350
7464
|
this.next();
|
|
7351
7465
|
|
|
7352
7466
|
if (!this.isContextual(122) && !this.match(83)) {
|
|
7353
|
-
this.raise(
|
|
7467
|
+
this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, {
|
|
7468
|
+
at: this.state.lastTokStartLoc
|
|
7469
|
+
});
|
|
7354
7470
|
}
|
|
7355
7471
|
|
|
7356
7472
|
this.parseImport(_bodyNode);
|
|
@@ -7370,17 +7486,23 @@
|
|
|
7370
7486
|
body.forEach(bodyElement => {
|
|
7371
7487
|
if (isEsModuleType(bodyElement)) {
|
|
7372
7488
|
if (kind === "CommonJS") {
|
|
7373
|
-
this.raise(
|
|
7489
|
+
this.raise(FlowErrors.AmbiguousDeclareModuleKind, {
|
|
7490
|
+
node: bodyElement
|
|
7491
|
+
});
|
|
7374
7492
|
}
|
|
7375
7493
|
|
|
7376
7494
|
kind = "ES";
|
|
7377
7495
|
} else if (bodyElement.type === "DeclareModuleExports") {
|
|
7378
7496
|
if (hasModuleExport) {
|
|
7379
|
-
this.raise(
|
|
7497
|
+
this.raise(FlowErrors.DuplicateDeclareModuleExports, {
|
|
7498
|
+
node: bodyElement
|
|
7499
|
+
});
|
|
7380
7500
|
}
|
|
7381
7501
|
|
|
7382
7502
|
if (kind === "ES") {
|
|
7383
|
-
this.raise(
|
|
7503
|
+
this.raise(FlowErrors.AmbiguousDeclareModuleKind, {
|
|
7504
|
+
node: bodyElement
|
|
7505
|
+
});
|
|
7384
7506
|
}
|
|
7385
7507
|
|
|
7386
7508
|
kind = "CommonJS";
|
|
@@ -7408,7 +7530,9 @@
|
|
|
7408
7530
|
if (this.match(71) || this.isLet() || (this.isContextual(122) || this.isContextual(121)) && !insideModule) {
|
|
7409
7531
|
var label = this.state.value;
|
|
7410
7532
|
var suggestion = exportSuggestions[label];
|
|
7411
|
-
throw this.raise(
|
|
7533
|
+
throw this.raise(FlowErrors.UnsupportedDeclareExportKind, {
|
|
7534
|
+
at: this.state.startLoc
|
|
7535
|
+
}, label, suggestion);
|
|
7412
7536
|
}
|
|
7413
7537
|
|
|
7414
7538
|
if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(123)) {
|
|
@@ -7463,7 +7587,7 @@
|
|
|
7463
7587
|
flowParseInterfaceish(node) {
|
|
7464
7588
|
var isClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
7465
7589
|
node.id = this.flowParseRestrictedIdentifier(!isClass, true);
|
|
7466
|
-
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);
|
|
7467
7591
|
|
|
7468
7592
|
if (this.match(45)) {
|
|
7469
7593
|
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
|
@@ -7526,23 +7650,27 @@
|
|
|
7526
7650
|
|
|
7527
7651
|
checkNotUnderscore(word) {
|
|
7528
7652
|
if (word === "_") {
|
|
7529
|
-
this.raise(
|
|
7653
|
+
this.raise(FlowErrors.UnexpectedReservedUnderscore, {
|
|
7654
|
+
at: this.state.startLoc
|
|
7655
|
+
});
|
|
7530
7656
|
}
|
|
7531
7657
|
}
|
|
7532
7658
|
|
|
7533
7659
|
checkReservedType(word, startLoc, declaration) {
|
|
7534
7660
|
if (!reservedTypes.has(word)) return;
|
|
7535
|
-
this.raise(
|
|
7661
|
+
this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, {
|
|
7662
|
+
at: startLoc
|
|
7663
|
+
}, word);
|
|
7536
7664
|
}
|
|
7537
7665
|
|
|
7538
7666
|
flowParseRestrictedIdentifier(liberal, declaration) {
|
|
7539
|
-
this.checkReservedType(this.state.value, this.state.
|
|
7667
|
+
this.checkReservedType(this.state.value, this.state.startLoc, declaration);
|
|
7540
7668
|
return this.parseIdentifier(liberal);
|
|
7541
7669
|
}
|
|
7542
7670
|
|
|
7543
7671
|
flowParseTypeAlias(node) {
|
|
7544
7672
|
node.id = this.flowParseRestrictedIdentifier(false, true);
|
|
7545
|
-
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
|
|
7673
|
+
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start);
|
|
7546
7674
|
|
|
7547
7675
|
if (this.match(45)) {
|
|
7548
7676
|
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
|
@@ -7558,7 +7686,7 @@
|
|
|
7558
7686
|
flowParseOpaqueType(node, declare) {
|
|
7559
7687
|
this.expectContextual(122);
|
|
7560
7688
|
node.id = this.flowParseRestrictedIdentifier(true, true);
|
|
7561
|
-
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
|
|
7689
|
+
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start);
|
|
7562
7690
|
|
|
7563
7691
|
if (this.match(45)) {
|
|
7564
7692
|
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
|
@@ -7584,7 +7712,7 @@
|
|
|
7584
7712
|
|
|
7585
7713
|
flowParseTypeParameter() {
|
|
7586
7714
|
var requireDefault = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
7587
|
-
var
|
|
7715
|
+
var nodeStartLoc = this.state.startLoc;
|
|
7588
7716
|
var node = this.startNode();
|
|
7589
7717
|
var variance = this.flowParseVariance();
|
|
7590
7718
|
var ident = this.flowParseTypeAnnotatableIdentifier();
|
|
@@ -7597,7 +7725,9 @@
|
|
|
7597
7725
|
node.default = this.flowParseType();
|
|
7598
7726
|
} else {
|
|
7599
7727
|
if (requireDefault) {
|
|
7600
|
-
this.raise(
|
|
7728
|
+
this.raise(FlowErrors.MissingTypeParamDefault, {
|
|
7729
|
+
at: nodeStartLoc
|
|
7730
|
+
});
|
|
7601
7731
|
}
|
|
7602
7732
|
}
|
|
7603
7733
|
|
|
@@ -7789,14 +7919,14 @@
|
|
|
7789
7919
|
return this.finishNode(node, "ObjectTypeCallProperty");
|
|
7790
7920
|
}
|
|
7791
7921
|
|
|
7792
|
-
flowParseObjectType(
|
|
7922
|
+
flowParseObjectType(_ref7) {
|
|
7793
7923
|
var {
|
|
7794
7924
|
allowStatic,
|
|
7795
7925
|
allowExact,
|
|
7796
7926
|
allowSpread,
|
|
7797
7927
|
allowProto,
|
|
7798
7928
|
allowInexact
|
|
7799
|
-
} =
|
|
7929
|
+
} = _ref7;
|
|
7800
7930
|
var oldInType = this.state.inType;
|
|
7801
7931
|
this.state.inType = true;
|
|
7802
7932
|
var nodeStart = this.startNode();
|
|
@@ -7822,8 +7952,8 @@
|
|
|
7822
7952
|
|
|
7823
7953
|
while (!this.match(endDelim)) {
|
|
7824
7954
|
var isStatic = false;
|
|
7825
|
-
var
|
|
7826
|
-
var
|
|
7955
|
+
var protoStartLoc = null;
|
|
7956
|
+
var inexactStartLoc = null;
|
|
7827
7957
|
var node = this.startNode();
|
|
7828
7958
|
|
|
7829
7959
|
if (allowProto && this.isContextual(111)) {
|
|
@@ -7831,7 +7961,7 @@
|
|
|
7831
7961
|
|
|
7832
7962
|
if (lookahead.type !== 14 && lookahead.type !== 17) {
|
|
7833
7963
|
this.next();
|
|
7834
|
-
|
|
7964
|
+
protoStartLoc = this.state.startLoc;
|
|
7835
7965
|
allowStatic = false;
|
|
7836
7966
|
}
|
|
7837
7967
|
}
|
|
@@ -7848,13 +7978,13 @@
|
|
|
7848
7978
|
var variance = this.flowParseVariance();
|
|
7849
7979
|
|
|
7850
7980
|
if (this.eat(0)) {
|
|
7851
|
-
if (
|
|
7852
|
-
this.unexpected(
|
|
7981
|
+
if (protoStartLoc != null) {
|
|
7982
|
+
this.unexpected(protoStartLoc);
|
|
7853
7983
|
}
|
|
7854
7984
|
|
|
7855
7985
|
if (this.eat(0)) {
|
|
7856
7986
|
if (variance) {
|
|
7857
|
-
this.unexpected(variance.start);
|
|
7987
|
+
this.unexpected(variance.loc.start);
|
|
7858
7988
|
}
|
|
7859
7989
|
|
|
7860
7990
|
nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
|
|
@@ -7862,12 +7992,12 @@
|
|
|
7862
7992
|
nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
|
|
7863
7993
|
}
|
|
7864
7994
|
} else if (this.match(10) || this.match(45)) {
|
|
7865
|
-
if (
|
|
7866
|
-
this.unexpected(
|
|
7995
|
+
if (protoStartLoc != null) {
|
|
7996
|
+
this.unexpected(protoStartLoc);
|
|
7867
7997
|
}
|
|
7868
7998
|
|
|
7869
7999
|
if (variance) {
|
|
7870
|
-
this.unexpected(variance.start);
|
|
8000
|
+
this.unexpected(variance.loc.start);
|
|
7871
8001
|
}
|
|
7872
8002
|
|
|
7873
8003
|
nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
|
|
@@ -7883,11 +8013,11 @@
|
|
|
7883
8013
|
}
|
|
7884
8014
|
}
|
|
7885
8015
|
|
|
7886
|
-
var propOrInexact = this.flowParseObjectTypeProperty(node, isStatic,
|
|
8016
|
+
var propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
|
|
7887
8017
|
|
|
7888
8018
|
if (propOrInexact === null) {
|
|
7889
8019
|
inexact = true;
|
|
7890
|
-
|
|
8020
|
+
inexactStartLoc = this.state.lastTokStartLoc;
|
|
7891
8021
|
} else {
|
|
7892
8022
|
nodeStart.properties.push(propOrInexact);
|
|
7893
8023
|
}
|
|
@@ -7895,8 +8025,10 @@
|
|
|
7895
8025
|
|
|
7896
8026
|
this.flowObjectTypeSemicolon();
|
|
7897
8027
|
|
|
7898
|
-
if (
|
|
7899
|
-
this.raise(
|
|
8028
|
+
if (inexactStartLoc && !this.match(8) && !this.match(9)) {
|
|
8029
|
+
this.raise(FlowErrors.UnexpectedExplicitInexactInObject, {
|
|
8030
|
+
at: inexactStartLoc
|
|
8031
|
+
});
|
|
7900
8032
|
}
|
|
7901
8033
|
}
|
|
7902
8034
|
|
|
@@ -7911,34 +8043,44 @@
|
|
|
7911
8043
|
return out;
|
|
7912
8044
|
}
|
|
7913
8045
|
|
|
7914
|
-
flowParseObjectTypeProperty(node, isStatic,
|
|
8046
|
+
flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
|
|
7915
8047
|
if (this.eat(21)) {
|
|
7916
8048
|
var isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
|
|
7917
8049
|
|
|
7918
8050
|
if (isInexactToken) {
|
|
7919
8051
|
if (!allowSpread) {
|
|
7920
|
-
this.raise(
|
|
8052
|
+
this.raise(FlowErrors.InexactInsideNonObject, {
|
|
8053
|
+
at: this.state.lastTokStartLoc
|
|
8054
|
+
});
|
|
7921
8055
|
} else if (!allowInexact) {
|
|
7922
|
-
this.raise(
|
|
8056
|
+
this.raise(FlowErrors.InexactInsideExact, {
|
|
8057
|
+
at: this.state.lastTokStartLoc
|
|
8058
|
+
});
|
|
7923
8059
|
}
|
|
7924
8060
|
|
|
7925
8061
|
if (variance) {
|
|
7926
|
-
this.raise(
|
|
8062
|
+
this.raise(FlowErrors.InexactVariance, {
|
|
8063
|
+
node: variance
|
|
8064
|
+
});
|
|
7927
8065
|
}
|
|
7928
8066
|
|
|
7929
8067
|
return null;
|
|
7930
8068
|
}
|
|
7931
8069
|
|
|
7932
8070
|
if (!allowSpread) {
|
|
7933
|
-
this.raise(
|
|
8071
|
+
this.raise(FlowErrors.UnexpectedSpreadType, {
|
|
8072
|
+
at: this.state.lastTokStartLoc
|
|
8073
|
+
});
|
|
7934
8074
|
}
|
|
7935
8075
|
|
|
7936
|
-
if (
|
|
7937
|
-
this.unexpected(
|
|
8076
|
+
if (protoStartLoc != null) {
|
|
8077
|
+
this.unexpected(protoStartLoc);
|
|
7938
8078
|
}
|
|
7939
8079
|
|
|
7940
8080
|
if (variance) {
|
|
7941
|
-
this.raise(
|
|
8081
|
+
this.raise(FlowErrors.SpreadVariance, {
|
|
8082
|
+
node: variance
|
|
8083
|
+
});
|
|
7942
8084
|
}
|
|
7943
8085
|
|
|
7944
8086
|
node.argument = this.flowParseType();
|
|
@@ -7946,19 +8088,19 @@
|
|
|
7946
8088
|
} else {
|
|
7947
8089
|
node.key = this.flowParseObjectPropertyKey();
|
|
7948
8090
|
node.static = isStatic;
|
|
7949
|
-
node.proto =
|
|
8091
|
+
node.proto = protoStartLoc != null;
|
|
7950
8092
|
node.kind = kind;
|
|
7951
8093
|
var optional = false;
|
|
7952
8094
|
|
|
7953
8095
|
if (this.match(45) || this.match(10)) {
|
|
7954
8096
|
node.method = true;
|
|
7955
8097
|
|
|
7956
|
-
if (
|
|
7957
|
-
this.unexpected(
|
|
8098
|
+
if (protoStartLoc != null) {
|
|
8099
|
+
this.unexpected(protoStartLoc);
|
|
7958
8100
|
}
|
|
7959
8101
|
|
|
7960
8102
|
if (variance) {
|
|
7961
|
-
this.unexpected(variance.start);
|
|
8103
|
+
this.unexpected(variance.loc.start);
|
|
7962
8104
|
}
|
|
7963
8105
|
|
|
7964
8106
|
node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
|
|
@@ -7968,7 +8110,9 @@
|
|
|
7968
8110
|
}
|
|
7969
8111
|
|
|
7970
8112
|
if (!allowSpread && node.key.name === "constructor" && node.value.this) {
|
|
7971
|
-
this.raise(
|
|
8113
|
+
this.raise(FlowErrors.ThisParamBannedInConstructor, {
|
|
8114
|
+
node: node.value.this
|
|
8115
|
+
});
|
|
7972
8116
|
}
|
|
7973
8117
|
} else {
|
|
7974
8118
|
if (kind !== "init") this.unexpected();
|
|
@@ -7989,23 +8133,24 @@
|
|
|
7989
8133
|
|
|
7990
8134
|
flowCheckGetterSetterParams(property) {
|
|
7991
8135
|
var paramCount = property.kind === "get" ? 0 : 1;
|
|
7992
|
-
var start = property.start;
|
|
7993
8136
|
var length = property.value.params.length + (property.value.rest ? 1 : 0);
|
|
7994
8137
|
|
|
7995
8138
|
if (property.value.this) {
|
|
7996
|
-
this.raise(property.
|
|
8139
|
+
this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, {
|
|
8140
|
+
node: property.value.this
|
|
8141
|
+
});
|
|
7997
8142
|
}
|
|
7998
8143
|
|
|
7999
8144
|
if (length !== paramCount) {
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
}
|
|
8003
|
-
this.raise(start, ErrorMessages.BadSetterArity);
|
|
8004
|
-
}
|
|
8145
|
+
this.raise(property.kind === "get" ? ErrorMessages.BadGetterArity : ErrorMessages.BadSetterArity, {
|
|
8146
|
+
node: property
|
|
8147
|
+
});
|
|
8005
8148
|
}
|
|
8006
8149
|
|
|
8007
8150
|
if (property.kind === "set" && property.value.rest) {
|
|
8008
|
-
this.raise(
|
|
8151
|
+
this.raise(ErrorMessages.BadSetterRestParameter, {
|
|
8152
|
+
node: property
|
|
8153
|
+
});
|
|
8009
8154
|
}
|
|
8010
8155
|
}
|
|
8011
8156
|
|
|
@@ -8074,7 +8219,9 @@
|
|
|
8074
8219
|
|
|
8075
8220
|
if (lh.type === 14 || lh.type === 17) {
|
|
8076
8221
|
if (isThis && !first) {
|
|
8077
|
-
this.raise(
|
|
8222
|
+
this.raise(FlowErrors.ThisParamMustBeFirst, {
|
|
8223
|
+
node
|
|
8224
|
+
});
|
|
8078
8225
|
}
|
|
8079
8226
|
|
|
8080
8227
|
name = this.parseIdentifier(isThis);
|
|
@@ -8083,7 +8230,9 @@
|
|
|
8083
8230
|
optional = true;
|
|
8084
8231
|
|
|
8085
8232
|
if (isThis) {
|
|
8086
|
-
this.raise(
|
|
8233
|
+
this.raise(FlowErrors.ThisParamMayNotBeOptional, {
|
|
8234
|
+
node
|
|
8235
|
+
});
|
|
8087
8236
|
}
|
|
8088
8237
|
}
|
|
8089
8238
|
|
|
@@ -8276,7 +8425,9 @@
|
|
|
8276
8425
|
return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
|
|
8277
8426
|
}
|
|
8278
8427
|
|
|
8279
|
-
throw this.raise(
|
|
8428
|
+
throw this.raise(FlowErrors.UnexpectedSubtractionOperand, {
|
|
8429
|
+
at: this.state.startLoc
|
|
8430
|
+
});
|
|
8280
8431
|
}
|
|
8281
8432
|
|
|
8282
8433
|
throw this.unexpected();
|
|
@@ -8448,7 +8599,7 @@
|
|
|
8448
8599
|
|
|
8449
8600
|
typeCastToParameter(node) {
|
|
8450
8601
|
node.expression.typeAnnotation = node.typeAnnotation;
|
|
8451
|
-
this.resetEndLocation(node.expression, node.typeAnnotation.
|
|
8602
|
+
this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
|
|
8452
8603
|
return node.expression;
|
|
8453
8604
|
}
|
|
8454
8605
|
|
|
@@ -8613,7 +8764,9 @@
|
|
|
8613
8764
|
}
|
|
8614
8765
|
|
|
8615
8766
|
if (failed && valid.length > 1) {
|
|
8616
|
-
this.raise(
|
|
8767
|
+
this.raise(FlowErrors.AmbiguousConditionalArrow, {
|
|
8768
|
+
at: state.startLoc
|
|
8769
|
+
});
|
|
8617
8770
|
}
|
|
8618
8771
|
|
|
8619
8772
|
if (failed && valid.length === 1) {
|
|
@@ -8679,7 +8832,7 @@
|
|
|
8679
8832
|
finishArrowValidation(node) {
|
|
8680
8833
|
var _node$extra;
|
|
8681
8834
|
|
|
8682
|
-
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);
|
|
8683
8836
|
this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
|
|
8684
8837
|
super.checkParams(node, false, true);
|
|
8685
8838
|
this.scope.exit();
|
|
@@ -8788,11 +8941,13 @@
|
|
|
8788
8941
|
}
|
|
8789
8942
|
|
|
8790
8943
|
maybeParseExportNamespaceSpecifier(node) {
|
|
8791
|
-
var
|
|
8944
|
+
var {
|
|
8945
|
+
startLoc
|
|
8946
|
+
} = this.state;
|
|
8792
8947
|
var hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
|
|
8793
8948
|
|
|
8794
8949
|
if (hasNamespace && node.exportKind === "type") {
|
|
8795
|
-
this.unexpected(
|
|
8950
|
+
this.unexpected(startLoc);
|
|
8796
8951
|
}
|
|
8797
8952
|
|
|
8798
8953
|
return hasNamespace;
|
|
@@ -8807,7 +8962,9 @@
|
|
|
8807
8962
|
}
|
|
8808
8963
|
|
|
8809
8964
|
parseClassMember(classBody, member, state) {
|
|
8810
|
-
var
|
|
8965
|
+
var {
|
|
8966
|
+
startLoc
|
|
8967
|
+
} = this.state;
|
|
8811
8968
|
|
|
8812
8969
|
if (this.isContextual(117)) {
|
|
8813
8970
|
if (this.parseClassMemberFromModifier(classBody, member)) {
|
|
@@ -8821,9 +8978,13 @@
|
|
|
8821
8978
|
|
|
8822
8979
|
if (member.declare) {
|
|
8823
8980
|
if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
|
|
8824
|
-
this.raise(
|
|
8981
|
+
this.raise(FlowErrors.DeclareClassElement, {
|
|
8982
|
+
at: startLoc
|
|
8983
|
+
});
|
|
8825
8984
|
} else if (member.value) {
|
|
8826
|
-
this.raise(
|
|
8985
|
+
this.raise(FlowErrors.DeclareClassFieldInitializer, {
|
|
8986
|
+
node: member.value
|
|
8987
|
+
});
|
|
8827
8988
|
}
|
|
8828
8989
|
}
|
|
8829
8990
|
}
|
|
@@ -8837,7 +8998,9 @@
|
|
|
8837
8998
|
var fullWord = "@@" + word;
|
|
8838
8999
|
|
|
8839
9000
|
if (!this.isIterator(word) || !this.state.inType) {
|
|
8840
|
-
this.raise(
|
|
9001
|
+
this.raise(ErrorMessages.InvalidIdentifier, {
|
|
9002
|
+
at: this.state.curPosition()
|
|
9003
|
+
}, fullWord);
|
|
8841
9004
|
}
|
|
8842
9005
|
|
|
8843
9006
|
this.finishToken(124, fullWord);
|
|
@@ -8882,7 +9045,7 @@
|
|
|
8882
9045
|
}
|
|
8883
9046
|
}
|
|
8884
9047
|
|
|
8885
|
-
toAssignableList(exprList,
|
|
9048
|
+
toAssignableList(exprList, trailingCommaLoc, isLHS) {
|
|
8886
9049
|
for (var i = 0; i < exprList.length; i++) {
|
|
8887
9050
|
var expr = exprList[i];
|
|
8888
9051
|
|
|
@@ -8891,7 +9054,7 @@
|
|
|
8891
9054
|
}
|
|
8892
9055
|
}
|
|
8893
9056
|
|
|
8894
|
-
return super.toAssignableList(exprList,
|
|
9057
|
+
return super.toAssignableList(exprList, trailingCommaLoc, isLHS);
|
|
8895
9058
|
}
|
|
8896
9059
|
|
|
8897
9060
|
toReferencedList(exprList, isParenthesizedExpr) {
|
|
@@ -8901,7 +9064,9 @@
|
|
|
8901
9064
|
var expr = exprList[i];
|
|
8902
9065
|
|
|
8903
9066
|
if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
|
|
8904
|
-
this.raise(
|
|
9067
|
+
this.raise(FlowErrors.TypeCastInPattern, {
|
|
9068
|
+
node: expr.typeAnnotation
|
|
9069
|
+
});
|
|
8905
9070
|
}
|
|
8906
9071
|
}
|
|
8907
9072
|
|
|
@@ -8958,7 +9123,7 @@
|
|
|
8958
9123
|
|
|
8959
9124
|
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
|
8960
9125
|
if (method.variance) {
|
|
8961
|
-
this.unexpected(method.variance.start);
|
|
9126
|
+
this.unexpected(method.variance.loc.start);
|
|
8962
9127
|
}
|
|
8963
9128
|
|
|
8964
9129
|
delete method.variance;
|
|
@@ -8973,20 +9138,24 @@
|
|
|
8973
9138
|
var params = method.params;
|
|
8974
9139
|
|
|
8975
9140
|
if (params.length > 0 && this.isThisParam(params[0])) {
|
|
8976
|
-
this.raise(
|
|
9141
|
+
this.raise(FlowErrors.ThisParamBannedInConstructor, {
|
|
9142
|
+
node: method
|
|
9143
|
+
});
|
|
8977
9144
|
}
|
|
8978
9145
|
} else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
|
|
8979
9146
|
var _params2 = method.value.params;
|
|
8980
9147
|
|
|
8981
9148
|
if (_params2.length > 0 && this.isThisParam(_params2[0])) {
|
|
8982
|
-
this.raise(
|
|
9149
|
+
this.raise(FlowErrors.ThisParamBannedInConstructor, {
|
|
9150
|
+
node: method
|
|
9151
|
+
});
|
|
8983
9152
|
}
|
|
8984
9153
|
}
|
|
8985
9154
|
}
|
|
8986
9155
|
|
|
8987
9156
|
pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
|
|
8988
9157
|
if (method.variance) {
|
|
8989
|
-
this.unexpected(method.variance.start);
|
|
9158
|
+
this.unexpected(method.variance.loc.start);
|
|
8990
9159
|
}
|
|
8991
9160
|
|
|
8992
9161
|
delete method.variance;
|
|
@@ -9033,9 +9202,13 @@
|
|
|
9033
9202
|
var param = params[0];
|
|
9034
9203
|
|
|
9035
9204
|
if (this.isThisParam(param) && method.kind === "get") {
|
|
9036
|
-
this.raise(
|
|
9205
|
+
this.raise(FlowErrors.GetterMayNotHaveThisParam, {
|
|
9206
|
+
node: param
|
|
9207
|
+
});
|
|
9037
9208
|
} else if (this.isThisParam(param)) {
|
|
9038
|
-
this.raise(
|
|
9209
|
+
this.raise(FlowErrors.SetterMayNotHaveThisParam, {
|
|
9210
|
+
node: param
|
|
9211
|
+
});
|
|
9039
9212
|
}
|
|
9040
9213
|
}
|
|
9041
9214
|
}
|
|
@@ -9046,7 +9219,7 @@
|
|
|
9046
9219
|
|
|
9047
9220
|
parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
|
|
9048
9221
|
if (prop.variance) {
|
|
9049
|
-
this.unexpected(prop.variance.start);
|
|
9222
|
+
this.unexpected(prop.variance.loc.start);
|
|
9050
9223
|
}
|
|
9051
9224
|
|
|
9052
9225
|
delete prop.variance;
|
|
@@ -9067,11 +9240,15 @@
|
|
|
9067
9240
|
parseAssignableListItemTypes(param) {
|
|
9068
9241
|
if (this.eat(17)) {
|
|
9069
9242
|
if (param.type !== "Identifier") {
|
|
9070
|
-
this.raise(
|
|
9243
|
+
this.raise(FlowErrors.PatternIsOptional, {
|
|
9244
|
+
node: param
|
|
9245
|
+
});
|
|
9071
9246
|
}
|
|
9072
9247
|
|
|
9073
9248
|
if (this.isThisParam(param)) {
|
|
9074
|
-
this.raise(
|
|
9249
|
+
this.raise(FlowErrors.ThisParamMayNotBeOptional, {
|
|
9250
|
+
node: param
|
|
9251
|
+
});
|
|
9075
9252
|
}
|
|
9076
9253
|
|
|
9077
9254
|
param.optional = true;
|
|
@@ -9080,11 +9257,15 @@
|
|
|
9080
9257
|
if (this.match(14)) {
|
|
9081
9258
|
param.typeAnnotation = this.flowParseTypeAnnotation();
|
|
9082
9259
|
} else if (this.isThisParam(param)) {
|
|
9083
|
-
this.raise(
|
|
9260
|
+
this.raise(FlowErrors.ThisParamAnnotationRequired, {
|
|
9261
|
+
node: param
|
|
9262
|
+
});
|
|
9084
9263
|
}
|
|
9085
9264
|
|
|
9086
9265
|
if (this.match(29) && this.isThisParam(param)) {
|
|
9087
|
-
this.raise(
|
|
9266
|
+
this.raise(FlowErrors.ThisParamNoDefault, {
|
|
9267
|
+
node: param
|
|
9268
|
+
});
|
|
9088
9269
|
}
|
|
9089
9270
|
|
|
9090
9271
|
this.resetEndLocation(param);
|
|
@@ -9095,7 +9276,9 @@
|
|
|
9095
9276
|
var node = super.parseMaybeDefault(startPos, startLoc, left);
|
|
9096
9277
|
|
|
9097
9278
|
if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
|
|
9098
|
-
this.raise(
|
|
9279
|
+
this.raise(FlowErrors.TypeBeforeInitializer, {
|
|
9280
|
+
node: node.typeAnnotation
|
|
9281
|
+
});
|
|
9099
9282
|
}
|
|
9100
9283
|
|
|
9101
9284
|
return node;
|
|
@@ -9132,7 +9315,7 @@
|
|
|
9132
9315
|
} = lh;
|
|
9133
9316
|
|
|
9134
9317
|
if (kind === "type" && type === 51) {
|
|
9135
|
-
this.unexpected(lh.
|
|
9318
|
+
this.unexpected(null, lh.type);
|
|
9136
9319
|
}
|
|
9137
9320
|
|
|
9138
9321
|
if (isMaybeDefaultImport(type) || type === 5 || type === 51) {
|
|
@@ -9176,7 +9359,9 @@
|
|
|
9176
9359
|
specifier.importKind = specifierTypeKind;
|
|
9177
9360
|
} else {
|
|
9178
9361
|
if (importedIsString) {
|
|
9179
|
-
throw this.raise(
|
|
9362
|
+
throw this.raise(ErrorMessages.ImportBindingIsString, {
|
|
9363
|
+
node: specifier
|
|
9364
|
+
}, firstIdent.value);
|
|
9180
9365
|
}
|
|
9181
9366
|
|
|
9182
9367
|
specifier.imported = firstIdent;
|
|
@@ -9194,15 +9379,17 @@
|
|
|
9194
9379
|
var specifierIsTypeImport = hasTypeImportKind(specifier);
|
|
9195
9380
|
|
|
9196
9381
|
if (isInTypeOnlyImport && specifierIsTypeImport) {
|
|
9197
|
-
this.raise(
|
|
9382
|
+
this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, {
|
|
9383
|
+
node: specifier
|
|
9384
|
+
});
|
|
9198
9385
|
}
|
|
9199
9386
|
|
|
9200
9387
|
if (isInTypeOnlyImport || specifierIsTypeImport) {
|
|
9201
|
-
this.checkReservedType(specifier.local.name, specifier.local.start, true);
|
|
9388
|
+
this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
|
|
9202
9389
|
}
|
|
9203
9390
|
|
|
9204
9391
|
if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
|
|
9205
|
-
this.checkReservedWord(specifier.local.name, specifier.start, true, true);
|
|
9392
|
+
this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
|
|
9206
9393
|
}
|
|
9207
9394
|
|
|
9208
9395
|
this.checkLVal(specifier.local, "import specifier", BIND_LEXICAL);
|
|
@@ -9299,7 +9486,9 @@
|
|
|
9299
9486
|
if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
|
|
9300
9487
|
if (!arrow.error && !arrow.aborted) {
|
|
9301
9488
|
if (arrow.node.async) {
|
|
9302
|
-
this.raise(
|
|
9489
|
+
this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, {
|
|
9490
|
+
node: typeParameters
|
|
9491
|
+
});
|
|
9303
9492
|
}
|
|
9304
9493
|
|
|
9305
9494
|
return arrow.node;
|
|
@@ -9320,7 +9509,9 @@
|
|
|
9320
9509
|
|
|
9321
9510
|
if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
|
|
9322
9511
|
if (arrow.thrown) throw arrow.error;
|
|
9323
|
-
throw this.raise(
|
|
9512
|
+
throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, {
|
|
9513
|
+
node: typeParameters
|
|
9514
|
+
});
|
|
9324
9515
|
}
|
|
9325
9516
|
|
|
9326
9517
|
return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
|
|
@@ -9365,7 +9556,9 @@
|
|
|
9365
9556
|
|
|
9366
9557
|
for (var i = 0; i < node.params.length; i++) {
|
|
9367
9558
|
if (this.isThisParam(node.params[i]) && i > 0) {
|
|
9368
|
-
this.raise(
|
|
9559
|
+
this.raise(FlowErrors.ThisParamMustBeFirst, {
|
|
9560
|
+
node: node.params[i]
|
|
9561
|
+
});
|
|
9369
9562
|
}
|
|
9370
9563
|
}
|
|
9371
9564
|
|
|
@@ -9490,7 +9683,9 @@
|
|
|
9490
9683
|
var fileNode = super.parseTopLevel(file, program);
|
|
9491
9684
|
|
|
9492
9685
|
if (this.state.hasFlowComment) {
|
|
9493
|
-
this.raise(
|
|
9686
|
+
this.raise(FlowErrors.UnterminatedFlowComment, {
|
|
9687
|
+
at: this.state.curPosition()
|
|
9688
|
+
});
|
|
9494
9689
|
}
|
|
9495
9690
|
|
|
9496
9691
|
return fileNode;
|
|
@@ -9499,7 +9694,9 @@
|
|
|
9499
9694
|
skipBlockComment() {
|
|
9500
9695
|
if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
|
|
9501
9696
|
if (this.state.hasFlowComment) {
|
|
9502
|
-
this.
|
|
9697
|
+
throw this.raise(FlowErrors.NestedFlowComment, {
|
|
9698
|
+
at: this.state.startLoc
|
|
9699
|
+
});
|
|
9503
9700
|
}
|
|
9504
9701
|
|
|
9505
9702
|
this.hasFlowCommentCompletion();
|
|
@@ -9509,13 +9706,15 @@
|
|
|
9509
9706
|
}
|
|
9510
9707
|
|
|
9511
9708
|
if (this.state.hasFlowComment) {
|
|
9512
|
-
var end = this.input.indexOf("*-/", this.state.pos
|
|
9709
|
+
var end = this.input.indexOf("*-/", this.state.pos + 2);
|
|
9513
9710
|
|
|
9514
9711
|
if (end === -1) {
|
|
9515
|
-
throw this.raise(
|
|
9712
|
+
throw this.raise(ErrorMessages.UnterminatedComment, {
|
|
9713
|
+
at: this.state.curPosition()
|
|
9714
|
+
});
|
|
9516
9715
|
}
|
|
9517
9716
|
|
|
9518
|
-
this.state.pos = end + 3;
|
|
9717
|
+
this.state.pos = end + 2 + 3;
|
|
9519
9718
|
return;
|
|
9520
9719
|
}
|
|
9521
9720
|
|
|
@@ -9554,93 +9753,64 @@
|
|
|
9554
9753
|
var end = this.input.indexOf("*/", this.state.pos);
|
|
9555
9754
|
|
|
9556
9755
|
if (end === -1) {
|
|
9557
|
-
throw this.raise(
|
|
9756
|
+
throw this.raise(ErrorMessages.UnterminatedComment, {
|
|
9757
|
+
at: this.state.curPosition()
|
|
9758
|
+
});
|
|
9558
9759
|
}
|
|
9559
9760
|
}
|
|
9560
9761
|
|
|
9561
|
-
flowEnumErrorBooleanMemberNotInitialized(
|
|
9562
|
-
var {
|
|
9563
|
-
enumName,
|
|
9564
|
-
memberName
|
|
9565
|
-
} = _ref6;
|
|
9566
|
-
this.raise(pos, FlowErrors.EnumBooleanMemberNotInitialized, memberName, enumName);
|
|
9567
|
-
}
|
|
9568
|
-
|
|
9569
|
-
flowEnumErrorInvalidMemberName(pos, _ref7) {
|
|
9570
|
-
var {
|
|
9571
|
-
enumName,
|
|
9572
|
-
memberName
|
|
9573
|
-
} = _ref7;
|
|
9574
|
-
var suggestion = memberName[0].toUpperCase() + memberName.slice(1);
|
|
9575
|
-
this.raise(pos, FlowErrors.EnumInvalidMemberName, memberName, suggestion, enumName);
|
|
9576
|
-
}
|
|
9577
|
-
|
|
9578
|
-
flowEnumErrorDuplicateMemberName(pos, _ref8) {
|
|
9762
|
+
flowEnumErrorBooleanMemberNotInitialized(loc, _ref8) {
|
|
9579
9763
|
var {
|
|
9580
9764
|
enumName,
|
|
9581
9765
|
memberName
|
|
9582
9766
|
} = _ref8;
|
|
9583
|
-
this.raise(
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
flowEnumErrorInconsistentMemberValues(pos, _ref9) {
|
|
9587
|
-
var {
|
|
9588
|
-
enumName
|
|
9589
|
-
} = _ref9;
|
|
9590
|
-
this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName);
|
|
9767
|
+
this.raise(FlowErrors.EnumBooleanMemberNotInitialized, {
|
|
9768
|
+
at: loc
|
|
9769
|
+
}, memberName, enumName);
|
|
9591
9770
|
}
|
|
9592
9771
|
|
|
9593
|
-
flowEnumErrorInvalidExplicitType(
|
|
9772
|
+
flowEnumErrorInvalidExplicitType(loc, _ref9) {
|
|
9594
9773
|
var {
|
|
9595
9774
|
enumName,
|
|
9596
9775
|
suppliedType
|
|
9597
|
-
} =
|
|
9598
|
-
return this.raise(
|
|
9776
|
+
} = _ref9;
|
|
9777
|
+
return this.raise(suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, {
|
|
9778
|
+
at: loc
|
|
9779
|
+
}, enumName, suppliedType);
|
|
9599
9780
|
}
|
|
9600
9781
|
|
|
9601
|
-
flowEnumErrorInvalidMemberInitializer(
|
|
9782
|
+
flowEnumErrorInvalidMemberInitializer(loc, _ref10) {
|
|
9602
9783
|
var {
|
|
9603
9784
|
enumName,
|
|
9604
9785
|
explicitType,
|
|
9605
9786
|
memberName
|
|
9606
|
-
} =
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
case "boolean":
|
|
9611
|
-
case "number":
|
|
9612
|
-
case "string":
|
|
9613
|
-
message = FlowErrors.EnumInvalidMemberInitializerPrimaryType;
|
|
9614
|
-
break;
|
|
9615
|
-
|
|
9616
|
-
case "symbol":
|
|
9617
|
-
message = FlowErrors.EnumInvalidMemberInitializerSymbolType;
|
|
9618
|
-
break;
|
|
9619
|
-
|
|
9620
|
-
default:
|
|
9621
|
-
message = FlowErrors.EnumInvalidMemberInitializerUnknownType;
|
|
9622
|
-
}
|
|
9623
|
-
|
|
9624
|
-
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);
|
|
9625
9791
|
}
|
|
9626
9792
|
|
|
9627
|
-
flowEnumErrorNumberMemberNotInitialized(
|
|
9793
|
+
flowEnumErrorNumberMemberNotInitialized(loc, _ref11) {
|
|
9628
9794
|
var {
|
|
9629
9795
|
enumName,
|
|
9630
9796
|
memberName
|
|
9631
|
-
} =
|
|
9632
|
-
this.raise(
|
|
9797
|
+
} = _ref11;
|
|
9798
|
+
this.raise(FlowErrors.EnumNumberMemberNotInitialized, {
|
|
9799
|
+
at: loc
|
|
9800
|
+
}, enumName, memberName);
|
|
9633
9801
|
}
|
|
9634
9802
|
|
|
9635
|
-
flowEnumErrorStringMemberInconsistentlyInitailized(
|
|
9803
|
+
flowEnumErrorStringMemberInconsistentlyInitailized(node, _ref12) {
|
|
9636
9804
|
var {
|
|
9637
9805
|
enumName
|
|
9638
|
-
} =
|
|
9639
|
-
this.raise(
|
|
9806
|
+
} = _ref12;
|
|
9807
|
+
this.raise(FlowErrors.EnumStringMemberInconsistentlyInitailized, {
|
|
9808
|
+
node
|
|
9809
|
+
}, enumName);
|
|
9640
9810
|
}
|
|
9641
9811
|
|
|
9642
9812
|
flowEnumMemberInit() {
|
|
9643
|
-
var
|
|
9813
|
+
var startLoc = this.state.startLoc;
|
|
9644
9814
|
|
|
9645
9815
|
var endOfInit = () => this.match(12) || this.match(8);
|
|
9646
9816
|
|
|
@@ -9652,14 +9822,14 @@
|
|
|
9652
9822
|
if (endOfInit()) {
|
|
9653
9823
|
return {
|
|
9654
9824
|
type: "number",
|
|
9655
|
-
|
|
9825
|
+
loc: literal.loc.start,
|
|
9656
9826
|
value: literal
|
|
9657
9827
|
};
|
|
9658
9828
|
}
|
|
9659
9829
|
|
|
9660
9830
|
return {
|
|
9661
9831
|
type: "invalid",
|
|
9662
|
-
|
|
9832
|
+
loc: startLoc
|
|
9663
9833
|
};
|
|
9664
9834
|
}
|
|
9665
9835
|
|
|
@@ -9670,14 +9840,14 @@
|
|
|
9670
9840
|
if (endOfInit()) {
|
|
9671
9841
|
return {
|
|
9672
9842
|
type: "string",
|
|
9673
|
-
|
|
9843
|
+
loc: _literal.loc.start,
|
|
9674
9844
|
value: _literal
|
|
9675
9845
|
};
|
|
9676
9846
|
}
|
|
9677
9847
|
|
|
9678
9848
|
return {
|
|
9679
9849
|
type: "invalid",
|
|
9680
|
-
|
|
9850
|
+
loc: startLoc
|
|
9681
9851
|
};
|
|
9682
9852
|
}
|
|
9683
9853
|
|
|
@@ -9689,31 +9859,31 @@
|
|
|
9689
9859
|
if (endOfInit()) {
|
|
9690
9860
|
return {
|
|
9691
9861
|
type: "boolean",
|
|
9692
|
-
|
|
9862
|
+
loc: _literal2.loc.start,
|
|
9693
9863
|
value: _literal2
|
|
9694
9864
|
};
|
|
9695
9865
|
}
|
|
9696
9866
|
|
|
9697
9867
|
return {
|
|
9698
9868
|
type: "invalid",
|
|
9699
|
-
|
|
9869
|
+
loc: startLoc
|
|
9700
9870
|
};
|
|
9701
9871
|
}
|
|
9702
9872
|
|
|
9703
9873
|
default:
|
|
9704
9874
|
return {
|
|
9705
9875
|
type: "invalid",
|
|
9706
|
-
|
|
9876
|
+
loc: startLoc
|
|
9707
9877
|
};
|
|
9708
9878
|
}
|
|
9709
9879
|
}
|
|
9710
9880
|
|
|
9711
9881
|
flowEnumMemberRaw() {
|
|
9712
|
-
var
|
|
9882
|
+
var loc = this.state.startLoc;
|
|
9713
9883
|
var id = this.parseIdentifier(true);
|
|
9714
9884
|
var init = this.eat(29) ? this.flowEnumMemberInit() : {
|
|
9715
9885
|
type: "none",
|
|
9716
|
-
|
|
9886
|
+
loc
|
|
9717
9887
|
};
|
|
9718
9888
|
return {
|
|
9719
9889
|
id,
|
|
@@ -9721,7 +9891,7 @@
|
|
|
9721
9891
|
};
|
|
9722
9892
|
}
|
|
9723
9893
|
|
|
9724
|
-
flowEnumCheckExplicitTypeMismatch(
|
|
9894
|
+
flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
|
|
9725
9895
|
var {
|
|
9726
9896
|
explicitType
|
|
9727
9897
|
} = context;
|
|
@@ -9731,15 +9901,15 @@
|
|
|
9731
9901
|
}
|
|
9732
9902
|
|
|
9733
9903
|
if (explicitType !== expectedType) {
|
|
9734
|
-
this.flowEnumErrorInvalidMemberInitializer(
|
|
9904
|
+
this.flowEnumErrorInvalidMemberInitializer(loc, context);
|
|
9735
9905
|
}
|
|
9736
9906
|
}
|
|
9737
9907
|
|
|
9738
|
-
flowEnumMembers(
|
|
9908
|
+
flowEnumMembers(_ref13) {
|
|
9739
9909
|
var {
|
|
9740
9910
|
enumName,
|
|
9741
9911
|
explicitType
|
|
9742
|
-
} =
|
|
9912
|
+
} = _ref13;
|
|
9743
9913
|
var seenNames = new Set();
|
|
9744
9914
|
var members = {
|
|
9745
9915
|
booleanMembers: [],
|
|
@@ -9767,17 +9937,15 @@
|
|
|
9767
9937
|
}
|
|
9768
9938
|
|
|
9769
9939
|
if (/^[a-z]/.test(memberName)) {
|
|
9770
|
-
this.
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
});
|
|
9940
|
+
this.raise(FlowErrors.EnumInvalidMemberName, {
|
|
9941
|
+
node: id
|
|
9942
|
+
}, memberName, memberName[0].toUpperCase() + memberName.slice(1), enumName);
|
|
9774
9943
|
}
|
|
9775
9944
|
|
|
9776
9945
|
if (seenNames.has(memberName)) {
|
|
9777
|
-
this.
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
});
|
|
9946
|
+
this.raise(FlowErrors.EnumDuplicateMemberName, {
|
|
9947
|
+
node: id
|
|
9948
|
+
}, memberName, enumName);
|
|
9781
9949
|
}
|
|
9782
9950
|
|
|
9783
9951
|
seenNames.add(memberName);
|
|
@@ -9791,7 +9959,7 @@
|
|
|
9791
9959
|
switch (init.type) {
|
|
9792
9960
|
case "boolean":
|
|
9793
9961
|
{
|
|
9794
|
-
this.flowEnumCheckExplicitTypeMismatch(init.
|
|
9962
|
+
this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
|
|
9795
9963
|
memberNode.init = init.value;
|
|
9796
9964
|
members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
|
|
9797
9965
|
break;
|
|
@@ -9799,7 +9967,7 @@
|
|
|
9799
9967
|
|
|
9800
9968
|
case "number":
|
|
9801
9969
|
{
|
|
9802
|
-
this.flowEnumCheckExplicitTypeMismatch(init.
|
|
9970
|
+
this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
|
|
9803
9971
|
memberNode.init = init.value;
|
|
9804
9972
|
members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
|
|
9805
9973
|
break;
|
|
@@ -9807,7 +9975,7 @@
|
|
|
9807
9975
|
|
|
9808
9976
|
case "string":
|
|
9809
9977
|
{
|
|
9810
|
-
this.flowEnumCheckExplicitTypeMismatch(init.
|
|
9978
|
+
this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
|
|
9811
9979
|
memberNode.init = init.value;
|
|
9812
9980
|
members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
|
|
9813
9981
|
break;
|
|
@@ -9815,18 +9983,18 @@
|
|
|
9815
9983
|
|
|
9816
9984
|
case "invalid":
|
|
9817
9985
|
{
|
|
9818
|
-
throw this.flowEnumErrorInvalidMemberInitializer(init.
|
|
9986
|
+
throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
|
|
9819
9987
|
}
|
|
9820
9988
|
|
|
9821
9989
|
case "none":
|
|
9822
9990
|
{
|
|
9823
9991
|
switch (explicitType) {
|
|
9824
9992
|
case "boolean":
|
|
9825
|
-
this.flowEnumErrorBooleanMemberNotInitialized(init.
|
|
9993
|
+
this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
|
|
9826
9994
|
break;
|
|
9827
9995
|
|
|
9828
9996
|
case "number":
|
|
9829
|
-
this.flowEnumErrorNumberMemberNotInitialized(init.
|
|
9997
|
+
this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
|
|
9830
9998
|
break;
|
|
9831
9999
|
|
|
9832
10000
|
default:
|
|
@@ -9846,10 +10014,10 @@
|
|
|
9846
10014
|
};
|
|
9847
10015
|
}
|
|
9848
10016
|
|
|
9849
|
-
flowEnumStringMembers(initializedMembers, defaultedMembers,
|
|
10017
|
+
flowEnumStringMembers(initializedMembers, defaultedMembers, _ref14) {
|
|
9850
10018
|
var {
|
|
9851
10019
|
enumName
|
|
9852
|
-
} =
|
|
10020
|
+
} = _ref14;
|
|
9853
10021
|
|
|
9854
10022
|
if (initializedMembers.length === 0) {
|
|
9855
10023
|
return defaultedMembers;
|
|
@@ -9857,7 +10025,7 @@
|
|
|
9857
10025
|
return initializedMembers;
|
|
9858
10026
|
} else if (defaultedMembers.length > initializedMembers.length) {
|
|
9859
10027
|
for (var member of initializedMembers) {
|
|
9860
|
-
this.flowEnumErrorStringMemberInconsistentlyInitailized(member
|
|
10028
|
+
this.flowEnumErrorStringMemberInconsistentlyInitailized(member, {
|
|
9861
10029
|
enumName
|
|
9862
10030
|
});
|
|
9863
10031
|
}
|
|
@@ -9865,7 +10033,7 @@
|
|
|
9865
10033
|
return defaultedMembers;
|
|
9866
10034
|
} else {
|
|
9867
10035
|
for (var _member of defaultedMembers) {
|
|
9868
|
-
this.flowEnumErrorStringMemberInconsistentlyInitailized(_member
|
|
10036
|
+
this.flowEnumErrorStringMemberInconsistentlyInitailized(_member, {
|
|
9869
10037
|
enumName
|
|
9870
10038
|
});
|
|
9871
10039
|
}
|
|
@@ -9874,14 +10042,14 @@
|
|
|
9874
10042
|
}
|
|
9875
10043
|
}
|
|
9876
10044
|
|
|
9877
|
-
flowEnumParseExplicitType(
|
|
10045
|
+
flowEnumParseExplicitType(_ref15) {
|
|
9878
10046
|
var {
|
|
9879
10047
|
enumName
|
|
9880
|
-
} =
|
|
10048
|
+
} = _ref15;
|
|
9881
10049
|
|
|
9882
10050
|
if (this.eatContextual(97)) {
|
|
9883
10051
|
if (!tokenIsIdentifier(this.state.type)) {
|
|
9884
|
-
throw this.flowEnumErrorInvalidExplicitType(this.state.
|
|
10052
|
+
throw this.flowEnumErrorInvalidExplicitType(this.state.startLoc, {
|
|
9885
10053
|
enumName,
|
|
9886
10054
|
suppliedType: null
|
|
9887
10055
|
});
|
|
@@ -9893,7 +10061,7 @@
|
|
|
9893
10061
|
this.next();
|
|
9894
10062
|
|
|
9895
10063
|
if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
|
|
9896
|
-
this.flowEnumErrorInvalidExplicitType(this.state.
|
|
10064
|
+
this.flowEnumErrorInvalidExplicitType(this.state.startLoc, {
|
|
9897
10065
|
enumName,
|
|
9898
10066
|
suppliedType: value
|
|
9899
10067
|
});
|
|
@@ -9905,11 +10073,9 @@
|
|
|
9905
10073
|
return null;
|
|
9906
10074
|
}
|
|
9907
10075
|
|
|
9908
|
-
flowEnumBody(node,
|
|
9909
|
-
var
|
|
9910
|
-
|
|
9911
|
-
nameLoc
|
|
9912
|
-
} = _ref17;
|
|
10076
|
+
flowEnumBody(node, id) {
|
|
10077
|
+
var enumName = id.name;
|
|
10078
|
+
var nameLoc = id.loc.start;
|
|
9913
10079
|
var explicitType = this.flowEnumParseExplicitType({
|
|
9914
10080
|
enumName
|
|
9915
10081
|
});
|
|
@@ -9973,7 +10139,7 @@
|
|
|
9973
10139
|
return this.finishNode(node, "EnumStringBody");
|
|
9974
10140
|
} else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
|
|
9975
10141
|
for (var member of members.defaultedMembers) {
|
|
9976
|
-
this.flowEnumErrorBooleanMemberNotInitialized(member.start, {
|
|
10142
|
+
this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
|
|
9977
10143
|
enumName,
|
|
9978
10144
|
memberName: member.id.name
|
|
9979
10145
|
});
|
|
@@ -9984,7 +10150,7 @@
|
|
|
9984
10150
|
return this.finishNode(node, "EnumBooleanBody");
|
|
9985
10151
|
} else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
|
|
9986
10152
|
for (var _member2 of members.defaultedMembers) {
|
|
9987
|
-
this.flowEnumErrorNumberMemberNotInitialized(_member2.start, {
|
|
10153
|
+
this.flowEnumErrorNumberMemberNotInitialized(_member2.loc.start, {
|
|
9988
10154
|
enumName,
|
|
9989
10155
|
memberName: _member2.id.name
|
|
9990
10156
|
});
|
|
@@ -9994,9 +10160,9 @@
|
|
|
9994
10160
|
this.expect(8);
|
|
9995
10161
|
return this.finishNode(node, "EnumNumberBody");
|
|
9996
10162
|
} else {
|
|
9997
|
-
this.
|
|
9998
|
-
|
|
9999
|
-
});
|
|
10163
|
+
this.raise(FlowErrors.EnumInconsistentMemberValues, {
|
|
10164
|
+
at: nameLoc
|
|
10165
|
+
}, enumName);
|
|
10000
10166
|
return empty();
|
|
10001
10167
|
}
|
|
10002
10168
|
}
|
|
@@ -10006,10 +10172,7 @@
|
|
|
10006
10172
|
flowParseEnumDeclaration(node) {
|
|
10007
10173
|
var id = this.parseIdentifier();
|
|
10008
10174
|
node.id = id;
|
|
10009
|
-
node.body = this.flowEnumBody(this.startNode(),
|
|
10010
|
-
enumName: id.name,
|
|
10011
|
-
nameLoc: id.start
|
|
10012
|
-
});
|
|
10175
|
+
node.body = this.flowEnumBody(this.startNode(), id);
|
|
10013
10176
|
return this.finishNode(node, "EnumDeclaration");
|
|
10014
10177
|
}
|
|
10015
10178
|
|
|
@@ -10324,7 +10487,9 @@
|
|
|
10324
10487
|
|
|
10325
10488
|
for (;;) {
|
|
10326
10489
|
if (this.state.pos >= this.length) {
|
|
10327
|
-
throw this.raise(
|
|
10490
|
+
throw this.raise(JsxErrors.UnterminatedJsxContent, {
|
|
10491
|
+
at: this.state.startLoc
|
|
10492
|
+
});
|
|
10328
10493
|
}
|
|
10329
10494
|
|
|
10330
10495
|
var ch = this.input.charCodeAt(this.state.pos);
|
|
@@ -10388,7 +10553,9 @@
|
|
|
10388
10553
|
|
|
10389
10554
|
for (;;) {
|
|
10390
10555
|
if (this.state.pos >= this.length) {
|
|
10391
|
-
throw this.raise(
|
|
10556
|
+
throw this.raise(ErrorMessages.UnterminatedString, {
|
|
10557
|
+
at: this.state.startLoc
|
|
10558
|
+
});
|
|
10392
10559
|
}
|
|
10393
10560
|
|
|
10394
10561
|
var ch = this.input.charCodeAt(this.state.pos);
|
|
@@ -10521,7 +10688,9 @@
|
|
|
10521
10688
|
node = this.jsxParseExpressionContainer(node, types.j_oTag);
|
|
10522
10689
|
|
|
10523
10690
|
if (node.expression.type === "JSXEmptyExpression") {
|
|
10524
|
-
this.raise(
|
|
10691
|
+
this.raise(JsxErrors.AttributeIsEmpty, {
|
|
10692
|
+
node
|
|
10693
|
+
});
|
|
10525
10694
|
}
|
|
10526
10695
|
|
|
10527
10696
|
return node;
|
|
@@ -10531,13 +10700,15 @@
|
|
|
10531
10700
|
return this.parseExprAtom();
|
|
10532
10701
|
|
|
10533
10702
|
default:
|
|
10534
|
-
throw this.raise(
|
|
10703
|
+
throw this.raise(JsxErrors.UnsupportedJsxValue, {
|
|
10704
|
+
at: this.state.startLoc
|
|
10705
|
+
});
|
|
10535
10706
|
}
|
|
10536
10707
|
}
|
|
10537
10708
|
|
|
10538
10709
|
jsxParseEmptyExpression() {
|
|
10539
|
-
var node = this.startNodeAt(this.state.
|
|
10540
|
-
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);
|
|
10541
10712
|
}
|
|
10542
10713
|
|
|
10543
10714
|
jsxParseSpreadChild(node) {
|
|
@@ -10664,13 +10835,19 @@
|
|
|
10664
10835
|
}
|
|
10665
10836
|
}
|
|
10666
10837
|
|
|
10667
|
-
if (isFragment(openingElement) && !isFragment(closingElement)) {
|
|
10668
|
-
this.raise(
|
|
10838
|
+
if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
|
|
10839
|
+
this.raise(JsxErrors.MissingClosingTagFragment, {
|
|
10840
|
+
node: closingElement
|
|
10841
|
+
});
|
|
10669
10842
|
} else if (!isFragment(openingElement) && isFragment(closingElement)) {
|
|
10670
|
-
this.raise(
|
|
10843
|
+
this.raise(JsxErrors.MissingClosingTagElement, {
|
|
10844
|
+
node: closingElement
|
|
10845
|
+
}, getQualifiedJSXName(openingElement.name));
|
|
10671
10846
|
} else if (!isFragment(openingElement) && !isFragment(closingElement)) {
|
|
10672
10847
|
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
|
|
10673
|
-
this.raise(
|
|
10848
|
+
this.raise(JsxErrors.MissingClosingTagElement, {
|
|
10849
|
+
node: closingElement
|
|
10850
|
+
}, getQualifiedJSXName(openingElement.name));
|
|
10674
10851
|
}
|
|
10675
10852
|
}
|
|
10676
10853
|
}
|
|
@@ -10686,7 +10863,9 @@
|
|
|
10686
10863
|
node.children = children;
|
|
10687
10864
|
|
|
10688
10865
|
if (this.match(45)) {
|
|
10689
|
-
throw this.raise(
|
|
10866
|
+
throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, {
|
|
10867
|
+
at: this.state.startLoc
|
|
10868
|
+
});
|
|
10690
10869
|
}
|
|
10691
10870
|
|
|
10692
10871
|
return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
|
|
@@ -10799,7 +10978,7 @@
|
|
|
10799
10978
|
return new TypeScriptScope(flags);
|
|
10800
10979
|
}
|
|
10801
10980
|
|
|
10802
|
-
declareName(name, bindingType,
|
|
10981
|
+
declareName(name, bindingType, loc) {
|
|
10803
10982
|
var scope = this.currentScope();
|
|
10804
10983
|
|
|
10805
10984
|
if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {
|
|
@@ -10812,7 +10991,7 @@
|
|
|
10812
10991
|
|
|
10813
10992
|
if (bindingType & BIND_KIND_TYPE) {
|
|
10814
10993
|
if (!(bindingType & BIND_KIND_VALUE)) {
|
|
10815
|
-
this.checkRedeclarationInScope(scope, name, bindingType,
|
|
10994
|
+
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
|
10816
10995
|
this.maybeExportDefined(scope, name);
|
|
10817
10996
|
}
|
|
10818
10997
|
|
|
@@ -11013,49 +11192,61 @@
|
|
|
11013
11192
|
}
|
|
11014
11193
|
|
|
11015
11194
|
tsParseModifiers(modified, allowedModifiers, disallowedModifiers, errorTemplate, stopOnStartOfClassStaticBlock) {
|
|
11016
|
-
var enforceOrder = (
|
|
11195
|
+
var enforceOrder = (loc, modifier, before, after) => {
|
|
11017
11196
|
if (modifier === before && modified[after]) {
|
|
11018
|
-
this.raise(
|
|
11197
|
+
this.raise(TSErrors.InvalidModifiersOrder, {
|
|
11198
|
+
at: loc
|
|
11199
|
+
}, before, after);
|
|
11019
11200
|
}
|
|
11020
11201
|
};
|
|
11021
11202
|
|
|
11022
|
-
var incompatible = (
|
|
11203
|
+
var incompatible = (loc, modifier, mod1, mod2) => {
|
|
11023
11204
|
if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
|
|
11024
|
-
this.raise(
|
|
11205
|
+
this.raise(TSErrors.IncompatibleModifiers, {
|
|
11206
|
+
at: loc
|
|
11207
|
+
}, mod1, mod2);
|
|
11025
11208
|
}
|
|
11026
11209
|
};
|
|
11027
11210
|
|
|
11028
11211
|
for (;;) {
|
|
11029
|
-
var
|
|
11212
|
+
var {
|
|
11213
|
+
startLoc
|
|
11214
|
+
} = this.state;
|
|
11030
11215
|
var modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
|
|
11031
11216
|
if (!modifier) break;
|
|
11032
11217
|
|
|
11033
11218
|
if (tsIsAccessModifier(modifier)) {
|
|
11034
11219
|
if (modified.accessibility) {
|
|
11035
|
-
this.raise(
|
|
11220
|
+
this.raise(TSErrors.DuplicateAccessibilityModifier, {
|
|
11221
|
+
at: startLoc
|
|
11222
|
+
});
|
|
11036
11223
|
} else {
|
|
11037
|
-
enforceOrder(
|
|
11038
|
-
enforceOrder(
|
|
11039
|
-
enforceOrder(
|
|
11224
|
+
enforceOrder(startLoc, modifier, modifier, "override");
|
|
11225
|
+
enforceOrder(startLoc, modifier, modifier, "static");
|
|
11226
|
+
enforceOrder(startLoc, modifier, modifier, "readonly");
|
|
11040
11227
|
modified.accessibility = modifier;
|
|
11041
11228
|
}
|
|
11042
11229
|
} else {
|
|
11043
11230
|
if (Object.hasOwnProperty.call(modified, modifier)) {
|
|
11044
|
-
this.raise(
|
|
11231
|
+
this.raise(TSErrors.DuplicateModifier, {
|
|
11232
|
+
at: startLoc
|
|
11233
|
+
}, modifier);
|
|
11045
11234
|
} else {
|
|
11046
|
-
enforceOrder(
|
|
11047
|
-
enforceOrder(
|
|
11048
|
-
enforceOrder(
|
|
11049
|
-
enforceOrder(
|
|
11050
|
-
incompatible(
|
|
11051
|
-
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");
|
|
11052
11241
|
}
|
|
11053
11242
|
|
|
11054
11243
|
modified[modifier] = true;
|
|
11055
11244
|
}
|
|
11056
11245
|
|
|
11057
11246
|
if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
|
|
11058
|
-
this.raise(
|
|
11247
|
+
this.raise(errorTemplate, {
|
|
11248
|
+
at: startLoc
|
|
11249
|
+
}, modifier);
|
|
11059
11250
|
}
|
|
11060
11251
|
}
|
|
11061
11252
|
}
|
|
@@ -11160,7 +11351,9 @@
|
|
|
11160
11351
|
this.expect(10);
|
|
11161
11352
|
|
|
11162
11353
|
if (!this.match(125)) {
|
|
11163
|
-
this.raise(
|
|
11354
|
+
this.raise(TSErrors.UnsupportedImportTypeArgument, {
|
|
11355
|
+
at: this.state.startLoc
|
|
11356
|
+
});
|
|
11164
11357
|
}
|
|
11165
11358
|
|
|
11166
11359
|
node.argument = this.parseExprAtom();
|
|
@@ -11258,7 +11451,9 @@
|
|
|
11258
11451
|
node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true, refTrailingCommaPos);
|
|
11259
11452
|
|
|
11260
11453
|
if (node.params.length === 0) {
|
|
11261
|
-
this.raise(
|
|
11454
|
+
this.raise(TSErrors.EmptyTypeParameters, {
|
|
11455
|
+
node
|
|
11456
|
+
});
|
|
11262
11457
|
}
|
|
11263
11458
|
|
|
11264
11459
|
if (refTrailingCommaPos.value !== -1) {
|
|
@@ -11279,21 +11474,25 @@
|
|
|
11279
11474
|
|
|
11280
11475
|
tsFillSignature(returnToken, signature) {
|
|
11281
11476
|
var returnTokenRequired = returnToken === 19;
|
|
11477
|
+
var paramsKey = "parameters";
|
|
11478
|
+
var returnTypeKey = "typeAnnotation";
|
|
11282
11479
|
signature.typeParameters = this.tsTryParseTypeParameters();
|
|
11283
11480
|
this.expect(10);
|
|
11284
|
-
signature
|
|
11481
|
+
signature[paramsKey] = this.tsParseBindingListForSignature();
|
|
11285
11482
|
|
|
11286
11483
|
if (returnTokenRequired) {
|
|
11287
|
-
signature
|
|
11484
|
+
signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
|
11288
11485
|
} else if (this.match(returnToken)) {
|
|
11289
|
-
signature
|
|
11486
|
+
signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
|
11290
11487
|
}
|
|
11291
11488
|
}
|
|
11292
11489
|
|
|
11293
11490
|
tsParseBindingListForSignature() {
|
|
11294
11491
|
return this.parseBindingList(11, 41).map(pattern => {
|
|
11295
11492
|
if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") {
|
|
11296
|
-
this.raise(
|
|
11493
|
+
this.raise(TSErrors.UnsupportedSignatureParameterKind, {
|
|
11494
|
+
node: pattern
|
|
11495
|
+
}, pattern.type);
|
|
11297
11496
|
}
|
|
11298
11497
|
|
|
11299
11498
|
return pattern;
|
|
@@ -11346,47 +11545,67 @@
|
|
|
11346
11545
|
|
|
11347
11546
|
if (this.match(10) || this.match(45)) {
|
|
11348
11547
|
if (readonly) {
|
|
11349
|
-
this.raise(
|
|
11548
|
+
this.raise(TSErrors.ReadonlyForMethodSignature, {
|
|
11549
|
+
node
|
|
11550
|
+
});
|
|
11350
11551
|
}
|
|
11351
11552
|
|
|
11352
11553
|
var method = nodeAny;
|
|
11353
11554
|
|
|
11354
11555
|
if (method.kind && this.match(45)) {
|
|
11355
|
-
this.raise(
|
|
11556
|
+
this.raise(TSErrors.AccesorCannotHaveTypeParameters, {
|
|
11557
|
+
at: this.state.curPosition()
|
|
11558
|
+
});
|
|
11356
11559
|
}
|
|
11357
11560
|
|
|
11358
11561
|
this.tsFillSignature(14, method);
|
|
11359
11562
|
this.tsParseTypeMemberSemicolon();
|
|
11563
|
+
var paramsKey = "parameters";
|
|
11564
|
+
var returnTypeKey = "typeAnnotation";
|
|
11360
11565
|
|
|
11361
11566
|
if (method.kind === "get") {
|
|
11362
|
-
if (method.
|
|
11363
|
-
this.raise(
|
|
11567
|
+
if (method[paramsKey].length > 0) {
|
|
11568
|
+
this.raise(ErrorMessages.BadGetterArity, {
|
|
11569
|
+
at: this.state.curPosition()
|
|
11570
|
+
});
|
|
11364
11571
|
|
|
11365
|
-
if (this.isThisParam(method
|
|
11366
|
-
this.raise(
|
|
11572
|
+
if (this.isThisParam(method[paramsKey][0])) {
|
|
11573
|
+
this.raise(TSErrors.AccesorCannotDeclareThisParameter, {
|
|
11574
|
+
at: this.state.curPosition()
|
|
11575
|
+
});
|
|
11367
11576
|
}
|
|
11368
11577
|
}
|
|
11369
11578
|
} else if (method.kind === "set") {
|
|
11370
|
-
if (method.
|
|
11371
|
-
this.raise(
|
|
11579
|
+
if (method[paramsKey].length !== 1) {
|
|
11580
|
+
this.raise(ErrorMessages.BadSetterArity, {
|
|
11581
|
+
at: this.state.curPosition()
|
|
11582
|
+
});
|
|
11372
11583
|
} else {
|
|
11373
|
-
var firstParameter = method
|
|
11584
|
+
var firstParameter = method[paramsKey][0];
|
|
11374
11585
|
|
|
11375
11586
|
if (this.isThisParam(firstParameter)) {
|
|
11376
|
-
this.raise(
|
|
11587
|
+
this.raise(TSErrors.AccesorCannotDeclareThisParameter, {
|
|
11588
|
+
at: this.state.curPosition()
|
|
11589
|
+
});
|
|
11377
11590
|
}
|
|
11378
11591
|
|
|
11379
11592
|
if (firstParameter.type === "Identifier" && firstParameter.optional) {
|
|
11380
|
-
this.raise(
|
|
11593
|
+
this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, {
|
|
11594
|
+
at: this.state.curPosition()
|
|
11595
|
+
});
|
|
11381
11596
|
}
|
|
11382
11597
|
|
|
11383
11598
|
if (firstParameter.type === "RestElement") {
|
|
11384
|
-
this.raise(
|
|
11599
|
+
this.raise(TSErrors.SetAccesorCannotHaveRestParameter, {
|
|
11600
|
+
at: this.state.curPosition()
|
|
11601
|
+
});
|
|
11385
11602
|
}
|
|
11386
11603
|
}
|
|
11387
11604
|
|
|
11388
|
-
if (method
|
|
11389
|
-
this.raise(
|
|
11605
|
+
if (method[returnTypeKey]) {
|
|
11606
|
+
this.raise(TSErrors.SetAccesorCannotHaveReturnType, {
|
|
11607
|
+
node: method[returnTypeKey]
|
|
11608
|
+
});
|
|
11390
11609
|
}
|
|
11391
11610
|
} else {
|
|
11392
11611
|
method.kind = "method";
|
|
@@ -11528,7 +11747,9 @@
|
|
|
11528
11747
|
} = elementNode;
|
|
11529
11748
|
|
|
11530
11749
|
if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
|
|
11531
|
-
this.raise(
|
|
11750
|
+
this.raise(TSErrors.OptionalTypeBeforeRequired, {
|
|
11751
|
+
node: elementNode
|
|
11752
|
+
});
|
|
11532
11753
|
}
|
|
11533
11754
|
|
|
11534
11755
|
seenOptionalElement = seenOptionalElement || type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType";
|
|
@@ -11542,7 +11763,9 @@
|
|
|
11542
11763
|
labeledElements = (_labeledElements = labeledElements) != null ? _labeledElements : isLabeled;
|
|
11543
11764
|
|
|
11544
11765
|
if (labeledElements !== isLabeled) {
|
|
11545
|
-
this.raise(
|
|
11766
|
+
this.raise(TSErrors.MixedLabeledAndUnlabeledElements, {
|
|
11767
|
+
node: elementNode
|
|
11768
|
+
});
|
|
11546
11769
|
}
|
|
11547
11770
|
});
|
|
11548
11771
|
return this.finishNode(node, "TSTupleType");
|
|
@@ -11565,7 +11788,9 @@
|
|
|
11565
11788
|
if (type.type === "TSTypeReference" && !type.typeParameters && type.typeName.type === "Identifier") {
|
|
11566
11789
|
labeledNode.label = type.typeName;
|
|
11567
11790
|
} else {
|
|
11568
|
-
this.raise(
|
|
11791
|
+
this.raise(TSErrors.InvalidTupleMemberLabel, {
|
|
11792
|
+
node: type
|
|
11793
|
+
});
|
|
11569
11794
|
labeledNode.label = type;
|
|
11570
11795
|
}
|
|
11571
11796
|
|
|
@@ -11761,7 +11986,9 @@
|
|
|
11761
11986
|
return;
|
|
11762
11987
|
|
|
11763
11988
|
default:
|
|
11764
|
-
this.raise(
|
|
11989
|
+
this.raise(TSErrors.UnexpectedReadonly, {
|
|
11990
|
+
node
|
|
11991
|
+
});
|
|
11765
11992
|
}
|
|
11766
11993
|
}
|
|
11767
11994
|
|
|
@@ -11960,7 +12187,9 @@
|
|
|
11960
12187
|
}
|
|
11961
12188
|
|
|
11962
12189
|
if (containsEsc) {
|
|
11963
|
-
this.raise(
|
|
12190
|
+
this.raise(ErrorMessages.InvalidEscapedReservedWord, {
|
|
12191
|
+
at: this.state.lastTokStartLoc
|
|
12192
|
+
}, "asserts");
|
|
11964
12193
|
}
|
|
11965
12194
|
|
|
11966
12195
|
return true;
|
|
@@ -12014,7 +12243,9 @@
|
|
|
12014
12243
|
|
|
12015
12244
|
tsParseTypeAssertion() {
|
|
12016
12245
|
if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
|
|
12017
|
-
this.raise(
|
|
12246
|
+
this.raise(TSErrors.ReservedTypeAssertion, {
|
|
12247
|
+
at: this.state.startLoc
|
|
12248
|
+
});
|
|
12018
12249
|
}
|
|
12019
12250
|
|
|
12020
12251
|
var node = this.startNode();
|
|
@@ -12028,11 +12259,13 @@
|
|
|
12028
12259
|
}
|
|
12029
12260
|
|
|
12030
12261
|
tsParseHeritageClause(descriptor) {
|
|
12031
|
-
var
|
|
12262
|
+
var originalStartLoc = this.state.startLoc;
|
|
12032
12263
|
var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
|
|
12033
12264
|
|
|
12034
12265
|
if (!delimitedList.length) {
|
|
12035
|
-
this.raise(
|
|
12266
|
+
this.raise(TSErrors.EmptyHeritageClauseType, {
|
|
12267
|
+
at: originalStartLoc
|
|
12268
|
+
}, descriptor);
|
|
12036
12269
|
}
|
|
12037
12270
|
|
|
12038
12271
|
return delimitedList;
|
|
@@ -12055,7 +12288,9 @@
|
|
|
12055
12288
|
this.checkLVal(node.id, "typescript interface declaration", BIND_TS_INTERFACE);
|
|
12056
12289
|
} else {
|
|
12057
12290
|
node.id = null;
|
|
12058
|
-
this.raise(
|
|
12291
|
+
this.raise(TSErrors.MissingInterfaceName, {
|
|
12292
|
+
at: this.state.startLoc
|
|
12293
|
+
});
|
|
12059
12294
|
}
|
|
12060
12295
|
|
|
12061
12296
|
node.typeParameters = this.tsTryParseTypeParameters();
|
|
@@ -12215,7 +12450,9 @@
|
|
|
12215
12450
|
var moduleReference = this.tsParseModuleReference();
|
|
12216
12451
|
|
|
12217
12452
|
if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
|
|
12218
|
-
this.raise(
|
|
12453
|
+
this.raise(TSErrors.ImportAliasHasImportType, {
|
|
12454
|
+
node: moduleReference
|
|
12455
|
+
});
|
|
12219
12456
|
}
|
|
12220
12457
|
|
|
12221
12458
|
node.moduleReference = moduleReference;
|
|
@@ -12449,7 +12686,9 @@
|
|
|
12449
12686
|
}));
|
|
12450
12687
|
|
|
12451
12688
|
if (node.params.length === 0) {
|
|
12452
|
-
this.raise(
|
|
12689
|
+
this.raise(TSErrors.EmptyTypeArguments, {
|
|
12690
|
+
node
|
|
12691
|
+
});
|
|
12453
12692
|
}
|
|
12454
12693
|
|
|
12455
12694
|
this.expect(46);
|
|
@@ -12480,7 +12719,9 @@
|
|
|
12480
12719
|
readonly = modified.readonly;
|
|
12481
12720
|
|
|
12482
12721
|
if (allowModifiers === false && (accessibility || readonly || override)) {
|
|
12483
|
-
this.raise(
|
|
12722
|
+
this.raise(TSErrors.UnexpectedParameterModifier, {
|
|
12723
|
+
at: startLoc
|
|
12724
|
+
});
|
|
12484
12725
|
}
|
|
12485
12726
|
}
|
|
12486
12727
|
|
|
@@ -12500,7 +12741,9 @@
|
|
|
12500
12741
|
if (override) pp.override = override;
|
|
12501
12742
|
|
|
12502
12743
|
if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
|
|
12503
|
-
this.raise(
|
|
12744
|
+
this.raise(TSErrors.UnsupportedParameterPropertyKind, {
|
|
12745
|
+
node: pp
|
|
12746
|
+
});
|
|
12504
12747
|
}
|
|
12505
12748
|
|
|
12506
12749
|
pp.parameter = elt;
|
|
@@ -12529,7 +12772,9 @@
|
|
|
12529
12772
|
}
|
|
12530
12773
|
|
|
12531
12774
|
if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
|
|
12532
|
-
this.raise(
|
|
12775
|
+
this.raise(TSErrors.DeclareFunctionHasImplementation, {
|
|
12776
|
+
node
|
|
12777
|
+
});
|
|
12533
12778
|
|
|
12534
12779
|
if (node.declare) {
|
|
12535
12780
|
super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
|
|
@@ -12551,7 +12796,9 @@
|
|
|
12551
12796
|
tsCheckForInvalidTypeCasts(items) {
|
|
12552
12797
|
items.forEach(node => {
|
|
12553
12798
|
if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
|
|
12554
|
-
this.raise(
|
|
12799
|
+
this.raise(TSErrors.UnexpectedTypeAnnotation, {
|
|
12800
|
+
node: node.typeAnnotation
|
|
12801
|
+
});
|
|
12555
12802
|
}
|
|
12556
12803
|
});
|
|
12557
12804
|
}
|
|
@@ -12593,7 +12840,7 @@
|
|
|
12593
12840
|
}
|
|
12594
12841
|
|
|
12595
12842
|
if (this.match(45)) {
|
|
12596
|
-
var
|
|
12843
|
+
var missingParenErrorLoc;
|
|
12597
12844
|
var result = this.tsTryParseAndCatch(() => {
|
|
12598
12845
|
if (!noCalls && this.atPossibleAsyncArrow(base)) {
|
|
12599
12846
|
var asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startPos, startLoc);
|
|
@@ -12609,7 +12856,7 @@
|
|
|
12609
12856
|
|
|
12610
12857
|
if (typeArguments) {
|
|
12611
12858
|
if (isOptionalCall && !this.match(10)) {
|
|
12612
|
-
|
|
12859
|
+
missingParenErrorLoc = this.state.curPosition();
|
|
12613
12860
|
this.unexpected();
|
|
12614
12861
|
}
|
|
12615
12862
|
|
|
@@ -12634,8 +12881,8 @@
|
|
|
12634
12881
|
this.unexpected();
|
|
12635
12882
|
});
|
|
12636
12883
|
|
|
12637
|
-
if (
|
|
12638
|
-
this.unexpected(
|
|
12884
|
+
if (missingParenErrorLoc) {
|
|
12885
|
+
this.unexpected(missingParenErrorLoc, 10);
|
|
12639
12886
|
}
|
|
12640
12887
|
|
|
12641
12888
|
if (result) return result;
|
|
@@ -12705,7 +12952,9 @@
|
|
|
12705
12952
|
var importNode = super.parseImport(node);
|
|
12706
12953
|
|
|
12707
12954
|
if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
|
|
12708
|
-
this.raise(
|
|
12955
|
+
this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, {
|
|
12956
|
+
node: importNode
|
|
12957
|
+
});
|
|
12709
12958
|
}
|
|
12710
12959
|
|
|
12711
12960
|
return importNode;
|
|
@@ -12812,7 +13061,9 @@
|
|
|
12812
13061
|
this.next();
|
|
12813
13062
|
|
|
12814
13063
|
if (this.tsHasSomeModifiers(member, modifiers)) {
|
|
12815
|
-
this.raise(
|
|
13064
|
+
this.raise(TSErrors.StaticBlockCannotHaveModifier, {
|
|
13065
|
+
at: this.state.curPosition()
|
|
13066
|
+
});
|
|
12816
13067
|
}
|
|
12817
13068
|
|
|
12818
13069
|
this.parseClassStaticBlock(classBody, member);
|
|
@@ -12835,31 +13086,43 @@
|
|
|
12835
13086
|
classBody.body.push(idx);
|
|
12836
13087
|
|
|
12837
13088
|
if (member.abstract) {
|
|
12838
|
-
this.raise(
|
|
13089
|
+
this.raise(TSErrors.IndexSignatureHasAbstract, {
|
|
13090
|
+
node: member
|
|
13091
|
+
});
|
|
12839
13092
|
}
|
|
12840
13093
|
|
|
12841
13094
|
if (member.accessibility) {
|
|
12842
|
-
this.raise(
|
|
13095
|
+
this.raise(TSErrors.IndexSignatureHasAccessibility, {
|
|
13096
|
+
node: member
|
|
13097
|
+
}, member.accessibility);
|
|
12843
13098
|
}
|
|
12844
13099
|
|
|
12845
13100
|
if (member.declare) {
|
|
12846
|
-
this.raise(
|
|
13101
|
+
this.raise(TSErrors.IndexSignatureHasDeclare, {
|
|
13102
|
+
node: member
|
|
13103
|
+
});
|
|
12847
13104
|
}
|
|
12848
13105
|
|
|
12849
13106
|
if (member.override) {
|
|
12850
|
-
this.raise(
|
|
13107
|
+
this.raise(TSErrors.IndexSignatureHasOverride, {
|
|
13108
|
+
node: member
|
|
13109
|
+
});
|
|
12851
13110
|
}
|
|
12852
13111
|
|
|
12853
13112
|
return;
|
|
12854
13113
|
}
|
|
12855
13114
|
|
|
12856
13115
|
if (!this.state.inAbstractClass && member.abstract) {
|
|
12857
|
-
this.raise(
|
|
13116
|
+
this.raise(TSErrors.NonAbstractClassHasAbstractMethod, {
|
|
13117
|
+
node: member
|
|
13118
|
+
});
|
|
12858
13119
|
}
|
|
12859
13120
|
|
|
12860
13121
|
if (member.override) {
|
|
12861
13122
|
if (!state.hadSuperClass) {
|
|
12862
|
-
this.raise(
|
|
13123
|
+
this.raise(TSErrors.OverrideNotInSubClass, {
|
|
13124
|
+
node: member
|
|
13125
|
+
});
|
|
12863
13126
|
}
|
|
12864
13127
|
}
|
|
12865
13128
|
|
|
@@ -12871,11 +13134,15 @@
|
|
|
12871
13134
|
if (optional) methodOrProp.optional = true;
|
|
12872
13135
|
|
|
12873
13136
|
if (methodOrProp.readonly && this.match(10)) {
|
|
12874
|
-
this.raise(
|
|
13137
|
+
this.raise(TSErrors.ClassMethodHasReadonly, {
|
|
13138
|
+
node: methodOrProp
|
|
13139
|
+
});
|
|
12875
13140
|
}
|
|
12876
13141
|
|
|
12877
13142
|
if (methodOrProp.declare && this.match(10)) {
|
|
12878
|
-
this.raise(
|
|
13143
|
+
this.raise(TSErrors.ClassMethodHasDeclare, {
|
|
13144
|
+
node: methodOrProp
|
|
13145
|
+
});
|
|
12879
13146
|
}
|
|
12880
13147
|
}
|
|
12881
13148
|
|
|
@@ -12932,7 +13199,9 @@
|
|
|
12932
13199
|
var isDeclare = this.eatContextual(117);
|
|
12933
13200
|
|
|
12934
13201
|
if (isDeclare && (this.isContextual(117) || !this.shouldParseExportDeclaration())) {
|
|
12935
|
-
throw this.raise(
|
|
13202
|
+
throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, {
|
|
13203
|
+
at: this.state.startLoc
|
|
13204
|
+
});
|
|
12936
13205
|
}
|
|
12937
13206
|
|
|
12938
13207
|
var declaration;
|
|
@@ -12980,14 +13249,18 @@
|
|
|
12980
13249
|
this.parseClassPropertyAnnotation(node);
|
|
12981
13250
|
|
|
12982
13251
|
if (this.state.isAmbientContext && this.match(29)) {
|
|
12983
|
-
this.raise(
|
|
13252
|
+
this.raise(TSErrors.DeclareClassFieldHasInitializer, {
|
|
13253
|
+
at: this.state.startLoc
|
|
13254
|
+
});
|
|
12984
13255
|
}
|
|
12985
13256
|
|
|
12986
13257
|
if (node.abstract && this.match(29)) {
|
|
12987
13258
|
var {
|
|
12988
13259
|
key
|
|
12989
13260
|
} = node;
|
|
12990
|
-
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), "]"));
|
|
12991
13264
|
}
|
|
12992
13265
|
|
|
12993
13266
|
return super.parseClassProperty(node);
|
|
@@ -12995,11 +13268,15 @@
|
|
|
12995
13268
|
|
|
12996
13269
|
parseClassPrivateProperty(node) {
|
|
12997
13270
|
if (node.abstract) {
|
|
12998
|
-
this.raise(
|
|
13271
|
+
this.raise(TSErrors.PrivateElementHasAbstract, {
|
|
13272
|
+
node
|
|
13273
|
+
});
|
|
12999
13274
|
}
|
|
13000
13275
|
|
|
13001
13276
|
if (node.accessibility) {
|
|
13002
|
-
this.raise(
|
|
13277
|
+
this.raise(TSErrors.PrivateElementHasAccessibility, {
|
|
13278
|
+
node
|
|
13279
|
+
}, node.accessibility);
|
|
13003
13280
|
}
|
|
13004
13281
|
|
|
13005
13282
|
this.parseClassPropertyAnnotation(node);
|
|
@@ -13010,11 +13287,15 @@
|
|
|
13010
13287
|
var typeParameters = this.tsTryParseTypeParameters();
|
|
13011
13288
|
|
|
13012
13289
|
if (typeParameters && isConstructor) {
|
|
13013
|
-
this.raise(
|
|
13290
|
+
this.raise(TSErrors.ConstructorHasTypeParameters, {
|
|
13291
|
+
node: typeParameters
|
|
13292
|
+
});
|
|
13014
13293
|
}
|
|
13015
13294
|
|
|
13016
13295
|
if (method.declare && (method.kind === "get" || method.kind === "set")) {
|
|
13017
|
-
this.raise(
|
|
13296
|
+
this.raise(TSErrors.DeclareAccessor, {
|
|
13297
|
+
node: method
|
|
13298
|
+
}, method.kind);
|
|
13018
13299
|
}
|
|
13019
13300
|
|
|
13020
13301
|
if (typeParameters) method.typeParameters = typeParameters;
|
|
@@ -13065,7 +13346,7 @@
|
|
|
13065
13346
|
parseVarId(decl, kind) {
|
|
13066
13347
|
super.parseVarId(decl, kind);
|
|
13067
13348
|
|
|
13068
|
-
if (decl.id.type === "Identifier" && this.eat(35)) {
|
|
13349
|
+
if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
|
|
13069
13350
|
decl.definite = true;
|
|
13070
13351
|
}
|
|
13071
13352
|
|
|
@@ -13171,7 +13452,9 @@
|
|
|
13171
13452
|
var _node$extra;
|
|
13172
13453
|
|
|
13173
13454
|
if (node.params.length === 1 && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
|
|
13174
|
-
this.raise(
|
|
13455
|
+
this.raise(TSErrors.ReservedArrowTypeParam, {
|
|
13456
|
+
node
|
|
13457
|
+
});
|
|
13175
13458
|
}
|
|
13176
13459
|
}
|
|
13177
13460
|
|
|
@@ -13204,7 +13487,9 @@
|
|
|
13204
13487
|
parseAssignableListItemTypes(param) {
|
|
13205
13488
|
if (this.eat(17)) {
|
|
13206
13489
|
if (param.type !== "Identifier" && !this.state.isAmbientContext && !this.state.inType) {
|
|
13207
|
-
this.raise(
|
|
13490
|
+
this.raise(TSErrors.PatternIsOptional, {
|
|
13491
|
+
node: param
|
|
13492
|
+
});
|
|
13208
13493
|
}
|
|
13209
13494
|
|
|
13210
13495
|
param.optional = true;
|
|
@@ -13285,7 +13570,9 @@
|
|
|
13285
13570
|
case "TSAsExpression":
|
|
13286
13571
|
case "TSTypeAssertion":
|
|
13287
13572
|
if (!args[0] && contextDescription !== "parenthesized expression" && !((_expr$extra2 = expr.extra) != null && _expr$extra2.parenthesized)) {
|
|
13288
|
-
this.raise(
|
|
13573
|
+
this.raise(ErrorMessages.InvalidLhs, {
|
|
13574
|
+
node: expr
|
|
13575
|
+
}, contextDescription);
|
|
13289
13576
|
break;
|
|
13290
13577
|
}
|
|
13291
13578
|
|
|
@@ -13322,7 +13609,7 @@
|
|
|
13322
13609
|
return call;
|
|
13323
13610
|
}
|
|
13324
13611
|
|
|
13325
|
-
this.unexpected(
|
|
13612
|
+
this.unexpected(null, 10);
|
|
13326
13613
|
}
|
|
13327
13614
|
|
|
13328
13615
|
return super.parseMaybeDecoratorArguments(expr);
|
|
@@ -13331,8 +13618,9 @@
|
|
|
13331
13618
|
checkCommaAfterRest(close) {
|
|
13332
13619
|
if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
|
|
13333
13620
|
this.next();
|
|
13621
|
+
return false;
|
|
13334
13622
|
} else {
|
|
13335
|
-
super.checkCommaAfterRest(close);
|
|
13623
|
+
return super.checkCommaAfterRest(close);
|
|
13336
13624
|
}
|
|
13337
13625
|
}
|
|
13338
13626
|
|
|
@@ -13348,7 +13636,9 @@
|
|
|
13348
13636
|
var node = super.parseMaybeDefault(...arguments);
|
|
13349
13637
|
|
|
13350
13638
|
if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
|
|
13351
|
-
this.raise(
|
|
13639
|
+
this.raise(TSErrors.TypeAnnotationAfterAssign, {
|
|
13640
|
+
node: node.typeAnnotation
|
|
13641
|
+
});
|
|
13352
13642
|
}
|
|
13353
13643
|
|
|
13354
13644
|
return node;
|
|
@@ -13397,7 +13687,9 @@
|
|
|
13397
13687
|
if (!this.state.maybeInArrowParameters) {
|
|
13398
13688
|
exprList[i] = this.typeCastToParameter(expr);
|
|
13399
13689
|
} else {
|
|
13400
|
-
this.raise(
|
|
13690
|
+
this.raise(TSErrors.UnexpectedTypeCastInParameter, {
|
|
13691
|
+
node: expr
|
|
13692
|
+
});
|
|
13401
13693
|
}
|
|
13402
13694
|
|
|
13403
13695
|
break;
|
|
@@ -13409,7 +13701,7 @@
|
|
|
13409
13701
|
|
|
13410
13702
|
typeCastToParameter(node) {
|
|
13411
13703
|
node.expression.typeAnnotation = node.typeAnnotation;
|
|
13412
|
-
this.resetEndLocation(node.expression, node.typeAnnotation.
|
|
13704
|
+
this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
|
|
13413
13705
|
return node.expression;
|
|
13414
13706
|
}
|
|
13415
13707
|
|
|
@@ -13491,7 +13783,9 @@
|
|
|
13491
13783
|
} else if (this.isContextual(121)) {
|
|
13492
13784
|
if (!this.hasFollowingLineBreak()) {
|
|
13493
13785
|
node.abstract = true;
|
|
13494
|
-
this.raise(
|
|
13786
|
+
this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, {
|
|
13787
|
+
node
|
|
13788
|
+
});
|
|
13495
13789
|
this.next();
|
|
13496
13790
|
return this.tsParseInterfaceDeclaration(node);
|
|
13497
13791
|
}
|
|
@@ -13510,7 +13804,9 @@
|
|
|
13510
13804
|
var {
|
|
13511
13805
|
key
|
|
13512
13806
|
} = method;
|
|
13513
|
-
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), "]"));
|
|
13514
13810
|
}
|
|
13515
13811
|
}
|
|
13516
13812
|
|
|
@@ -13569,7 +13865,7 @@
|
|
|
13569
13865
|
var rightOfAs;
|
|
13570
13866
|
var hasTypeSpecifier = false;
|
|
13571
13867
|
var canParseAsKeyword = true;
|
|
13572
|
-
var
|
|
13868
|
+
var loc = leftOfAs.loc.start;
|
|
13573
13869
|
|
|
13574
13870
|
if (this.isContextual(89)) {
|
|
13575
13871
|
var firstAs = this.parseIdentifier();
|
|
@@ -13599,7 +13895,9 @@
|
|
|
13599
13895
|
}
|
|
13600
13896
|
|
|
13601
13897
|
if (hasTypeSpecifier && isInTypeOnlyImportExport) {
|
|
13602
|
-
this.raise(
|
|
13898
|
+
this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, {
|
|
13899
|
+
at: loc
|
|
13900
|
+
});
|
|
13603
13901
|
}
|
|
13604
13902
|
|
|
13605
13903
|
node[leftOfAsKey] = leftOfAs;
|
|
@@ -13622,9 +13920,9 @@
|
|
|
13622
13920
|
|
|
13623
13921
|
};
|
|
13624
13922
|
|
|
13625
|
-
var
|
|
13923
|
+
var PlaceholderErrors = makeErrorTemplates({
|
|
13626
13924
|
ClassNameIsRequired: "A class name is required."
|
|
13627
|
-
}, ErrorCodes.SyntaxError);
|
|
13925
|
+
}, ErrorCodes.SyntaxError, "placeholders");
|
|
13628
13926
|
|
|
13629
13927
|
var placeholders = superClass => class extends superClass {
|
|
13630
13928
|
parsePlaceholder(expectedNode) {
|
|
@@ -13747,7 +14045,9 @@
|
|
|
13747
14045
|
node.body = this.finishPlaceholder(placeholder, "ClassBody");
|
|
13748
14046
|
return this.finishNode(node, type);
|
|
13749
14047
|
} else {
|
|
13750
|
-
this.
|
|
14048
|
+
throw this.raise(PlaceholderErrors.ClassNameIsRequired, {
|
|
14049
|
+
at: this.state.startLoc
|
|
14050
|
+
});
|
|
13751
14051
|
}
|
|
13752
14052
|
} else {
|
|
13753
14053
|
this.parseClassId(node, isStatement, optionalId);
|
|
@@ -13847,7 +14147,7 @@
|
|
|
13847
14147
|
var v8intrinsic = superClass => class extends superClass {
|
|
13848
14148
|
parseV8Intrinsic() {
|
|
13849
14149
|
if (this.match(50)) {
|
|
13850
|
-
var
|
|
14150
|
+
var v8IntrinsicStartLoc = this.state.startLoc;
|
|
13851
14151
|
var node = this.startNode();
|
|
13852
14152
|
this.next();
|
|
13853
14153
|
|
|
@@ -13861,7 +14161,7 @@
|
|
|
13861
14161
|
}
|
|
13862
14162
|
}
|
|
13863
14163
|
|
|
13864
|
-
this.unexpected(
|
|
14164
|
+
this.unexpected(v8IntrinsicStartLoc);
|
|
13865
14165
|
}
|
|
13866
14166
|
}
|
|
13867
14167
|
|
|
@@ -14055,12 +14355,16 @@
|
|
|
14055
14355
|
|
|
14056
14356
|
if (isLHS) {
|
|
14057
14357
|
if (parenthesized.type === "Identifier") {
|
|
14058
|
-
this.expressionScope.recordParenthesizedIdentifierError(
|
|
14358
|
+
this.expressionScope.recordParenthesizedIdentifierError(ErrorMessages.InvalidParenthesizedAssignment, node.loc.start);
|
|
14059
14359
|
} else if (parenthesized.type !== "MemberExpression") {
|
|
14060
|
-
this.raise(
|
|
14360
|
+
this.raise(ErrorMessages.InvalidParenthesizedAssignment, {
|
|
14361
|
+
node
|
|
14362
|
+
});
|
|
14061
14363
|
}
|
|
14062
14364
|
} else {
|
|
14063
|
-
this.raise(
|
|
14365
|
+
this.raise(ErrorMessages.InvalidParenthesizedAssignment, {
|
|
14366
|
+
node
|
|
14367
|
+
});
|
|
14064
14368
|
}
|
|
14065
14369
|
}
|
|
14066
14370
|
|
|
@@ -14082,8 +14386,10 @@
|
|
|
14082
14386
|
var isLast = i === last;
|
|
14083
14387
|
this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
|
|
14084
14388
|
|
|
14085
|
-
if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.
|
|
14086
|
-
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
|
+
});
|
|
14087
14393
|
}
|
|
14088
14394
|
}
|
|
14089
14395
|
|
|
@@ -14104,12 +14410,14 @@
|
|
|
14104
14410
|
|
|
14105
14411
|
case "ArrayExpression":
|
|
14106
14412
|
node.type = "ArrayPattern";
|
|
14107
|
-
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);
|
|
14108
14414
|
break;
|
|
14109
14415
|
|
|
14110
14416
|
case "AssignmentExpression":
|
|
14111
14417
|
if (node.operator !== "=") {
|
|
14112
|
-
this.raise(
|
|
14418
|
+
this.raise(ErrorMessages.MissingEqInAssignment, {
|
|
14419
|
+
at: node.left.loc.end
|
|
14420
|
+
});
|
|
14113
14421
|
}
|
|
14114
14422
|
|
|
14115
14423
|
node.type = "AssignmentPattern";
|
|
@@ -14127,16 +14435,19 @@
|
|
|
14127
14435
|
|
|
14128
14436
|
toAssignableObjectExpressionProp(prop, isLast, isLHS) {
|
|
14129
14437
|
if (prop.type === "ObjectMethod") {
|
|
14130
|
-
|
|
14131
|
-
|
|
14438
|
+
this.raise(prop.kind === "get" || prop.kind === "set" ? ErrorMessages.PatternHasAccessor : ErrorMessages.PatternHasMethod, {
|
|
14439
|
+
node: prop.key
|
|
14440
|
+
});
|
|
14132
14441
|
} else if (prop.type === "SpreadElement" && !isLast) {
|
|
14133
|
-
this.
|
|
14442
|
+
this.raise(ErrorMessages.RestTrailingComma, {
|
|
14443
|
+
node: prop
|
|
14444
|
+
});
|
|
14134
14445
|
} else {
|
|
14135
14446
|
this.toAssignable(prop, isLHS);
|
|
14136
14447
|
}
|
|
14137
14448
|
}
|
|
14138
14449
|
|
|
14139
|
-
toAssignableList(exprList,
|
|
14450
|
+
toAssignableList(exprList, trailingCommaLoc, isLHS) {
|
|
14140
14451
|
var end = exprList.length;
|
|
14141
14452
|
|
|
14142
14453
|
if (end) {
|
|
@@ -14154,8 +14465,10 @@
|
|
|
14154
14465
|
this.unexpected(arg.start);
|
|
14155
14466
|
}
|
|
14156
14467
|
|
|
14157
|
-
if (
|
|
14158
|
-
this.
|
|
14468
|
+
if (trailingCommaLoc) {
|
|
14469
|
+
this.raise(ErrorMessages.RestTrailingComma, {
|
|
14470
|
+
at: trailingCommaLoc
|
|
14471
|
+
});
|
|
14159
14472
|
}
|
|
14160
14473
|
|
|
14161
14474
|
--end;
|
|
@@ -14169,7 +14482,9 @@
|
|
|
14169
14482
|
this.toAssignable(elt, isLHS);
|
|
14170
14483
|
|
|
14171
14484
|
if (elt.type === "RestElement") {
|
|
14172
|
-
this.
|
|
14485
|
+
this.raise(ErrorMessages.RestTrailingComma, {
|
|
14486
|
+
node: elt
|
|
14487
|
+
});
|
|
14173
14488
|
}
|
|
14174
14489
|
}
|
|
14175
14490
|
}
|
|
@@ -14280,14 +14595,18 @@
|
|
|
14280
14595
|
break;
|
|
14281
14596
|
} else if (this.match(21)) {
|
|
14282
14597
|
elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
|
|
14283
|
-
|
|
14284
|
-
this.
|
|
14285
|
-
|
|
14598
|
+
|
|
14599
|
+
if (!this.checkCommaAfterRest(closeCharCode)) {
|
|
14600
|
+
this.expect(close);
|
|
14601
|
+
break;
|
|
14602
|
+
}
|
|
14286
14603
|
} else {
|
|
14287
14604
|
var decorators = [];
|
|
14288
14605
|
|
|
14289
14606
|
if (this.match(26) && this.hasPlugin("decorators")) {
|
|
14290
|
-
this.raise(
|
|
14607
|
+
this.raise(ErrorMessages.UnsupportedParameterDecorator, {
|
|
14608
|
+
at: this.state.startLoc
|
|
14609
|
+
});
|
|
14291
14610
|
}
|
|
14292
14611
|
|
|
14293
14612
|
while (this.match(26)) {
|
|
@@ -14370,23 +14689,29 @@
|
|
|
14370
14689
|
} = expr;
|
|
14371
14690
|
|
|
14372
14691
|
if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(name, this.inModule) : isStrictBindOnlyReservedWord(name))) {
|
|
14373
|
-
this.raise(
|
|
14692
|
+
this.raise(bindingType === BIND_NONE ? ErrorMessages.StrictEvalArguments : ErrorMessages.StrictEvalArgumentsBinding, {
|
|
14693
|
+
node: expr
|
|
14694
|
+
}, name);
|
|
14374
14695
|
}
|
|
14375
14696
|
|
|
14376
14697
|
if (checkClashes) {
|
|
14377
14698
|
if (checkClashes.has(name)) {
|
|
14378
|
-
this.raise(
|
|
14699
|
+
this.raise(ErrorMessages.ParamDupe, {
|
|
14700
|
+
node: expr
|
|
14701
|
+
});
|
|
14379
14702
|
} else {
|
|
14380
14703
|
checkClashes.add(name);
|
|
14381
14704
|
}
|
|
14382
14705
|
}
|
|
14383
14706
|
|
|
14384
14707
|
if (disallowLetBinding && name === "let") {
|
|
14385
|
-
this.raise(
|
|
14708
|
+
this.raise(ErrorMessages.LetInLexicalBinding, {
|
|
14709
|
+
node: expr
|
|
14710
|
+
});
|
|
14386
14711
|
}
|
|
14387
14712
|
|
|
14388
14713
|
if (!(bindingType & BIND_NONE)) {
|
|
14389
|
-
this.scope.declareName(name, bindingType, expr.start);
|
|
14714
|
+
this.scope.declareName(name, bindingType, expr.loc.start);
|
|
14390
14715
|
}
|
|
14391
14716
|
|
|
14392
14717
|
break;
|
|
@@ -14394,7 +14719,9 @@
|
|
|
14394
14719
|
|
|
14395
14720
|
case "MemberExpression":
|
|
14396
14721
|
if (bindingType !== BIND_NONE) {
|
|
14397
|
-
this.raise(
|
|
14722
|
+
this.raise(ErrorMessages.InvalidPropertyBindingPattern, {
|
|
14723
|
+
node: expr
|
|
14724
|
+
});
|
|
14398
14725
|
}
|
|
14399
14726
|
|
|
14400
14727
|
break;
|
|
@@ -14430,33 +14757,30 @@
|
|
|
14430
14757
|
|
|
14431
14758
|
default:
|
|
14432
14759
|
{
|
|
14433
|
-
this.raise(
|
|
14760
|
+
this.raise(bindingType === BIND_NONE ? ErrorMessages.InvalidLhs : ErrorMessages.InvalidLhsBinding, {
|
|
14761
|
+
node: expr
|
|
14762
|
+
}, contextDescription);
|
|
14434
14763
|
}
|
|
14435
14764
|
}
|
|
14436
14765
|
}
|
|
14437
14766
|
|
|
14438
14767
|
checkToRestConversion(node) {
|
|
14439
14768
|
if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
|
|
14440
|
-
this.raise(
|
|
14769
|
+
this.raise(ErrorMessages.InvalidRestAssignmentPattern, {
|
|
14770
|
+
node: node.argument
|
|
14771
|
+
});
|
|
14441
14772
|
}
|
|
14442
14773
|
}
|
|
14443
14774
|
|
|
14444
14775
|
checkCommaAfterRest(close) {
|
|
14445
|
-
if (this.match(12)) {
|
|
14446
|
-
|
|
14447
|
-
this.raiseTrailingCommaAfterRest(this.state.start);
|
|
14448
|
-
} else {
|
|
14449
|
-
this.raiseRestNotLast(this.state.start);
|
|
14450
|
-
}
|
|
14776
|
+
if (!this.match(12)) {
|
|
14777
|
+
return false;
|
|
14451
14778
|
}
|
|
14452
|
-
}
|
|
14453
|
-
|
|
14454
|
-
raiseRestNotLast(pos) {
|
|
14455
|
-
throw this.raise(pos, ErrorMessages.ElementAfterRest);
|
|
14456
|
-
}
|
|
14457
14779
|
|
|
14458
|
-
|
|
14459
|
-
|
|
14780
|
+
this.raise(this.lookaheadCharCode() === close ? ErrorMessages.RestTrailingComma : ErrorMessages.ElementAfterRest, {
|
|
14781
|
+
at: this.state.startLoc
|
|
14782
|
+
});
|
|
14783
|
+
return true;
|
|
14460
14784
|
}
|
|
14461
14785
|
|
|
14462
14786
|
}
|
|
@@ -14474,17 +14798,21 @@
|
|
|
14474
14798
|
|
|
14475
14799
|
if (name === "__proto__") {
|
|
14476
14800
|
if (isRecord) {
|
|
14477
|
-
this.raise(
|
|
14801
|
+
this.raise(ErrorMessages.RecordNoProto, {
|
|
14802
|
+
node: key
|
|
14803
|
+
});
|
|
14478
14804
|
return;
|
|
14479
14805
|
}
|
|
14480
14806
|
|
|
14481
14807
|
if (protoRef.used) {
|
|
14482
14808
|
if (refExpressionErrors) {
|
|
14483
|
-
if (refExpressionErrors.
|
|
14484
|
-
refExpressionErrors.
|
|
14809
|
+
if (refExpressionErrors.doubleProtoLoc === null) {
|
|
14810
|
+
refExpressionErrors.doubleProtoLoc = key.loc.start;
|
|
14485
14811
|
}
|
|
14486
14812
|
} else {
|
|
14487
|
-
this.raise(
|
|
14813
|
+
this.raise(ErrorMessages.DuplicateProto, {
|
|
14814
|
+
node: key
|
|
14815
|
+
});
|
|
14488
14816
|
}
|
|
14489
14817
|
}
|
|
14490
14818
|
|
|
@@ -14553,9 +14881,9 @@
|
|
|
14553
14881
|
}
|
|
14554
14882
|
|
|
14555
14883
|
setOptionalParametersError(refExpressionErrors, resultError) {
|
|
14556
|
-
var _resultError$
|
|
14884
|
+
var _resultError$loc;
|
|
14557
14885
|
|
|
14558
|
-
refExpressionErrors.
|
|
14886
|
+
refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
|
|
14559
14887
|
}
|
|
14560
14888
|
|
|
14561
14889
|
parseMaybeAssign(refExpressionErrors, afterLeftParse) {
|
|
@@ -14605,12 +14933,12 @@
|
|
|
14605
14933
|
if (this.match(29)) {
|
|
14606
14934
|
node.left = this.toAssignable(left, true);
|
|
14607
14935
|
|
|
14608
|
-
if (refExpressionErrors.
|
|
14609
|
-
refExpressionErrors.
|
|
14936
|
+
if (refExpressionErrors.doubleProtoLoc != null && indexes.get(refExpressionErrors.doubleProtoLoc) >= startPos) {
|
|
14937
|
+
refExpressionErrors.doubleProtoLoc = null;
|
|
14610
14938
|
}
|
|
14611
14939
|
|
|
14612
|
-
if (refExpressionErrors.
|
|
14613
|
-
refExpressionErrors.
|
|
14940
|
+
if (refExpressionErrors.shorthandAssignLoc != null && indexes.get(refExpressionErrors.shorthandAssignLoc) >= startPos) {
|
|
14941
|
+
refExpressionErrors.shorthandAssignLoc = null;
|
|
14614
14942
|
}
|
|
14615
14943
|
} else {
|
|
14616
14944
|
node.left = left;
|
|
@@ -14673,15 +15001,14 @@
|
|
|
14673
15001
|
parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
|
|
14674
15002
|
if (this.isPrivateName(left)) {
|
|
14675
15003
|
var value = this.getPrivateNameSV(left);
|
|
14676
|
-
var {
|
|
14677
|
-
start
|
|
14678
|
-
} = left;
|
|
14679
15004
|
|
|
14680
15005
|
if (minPrec >= tokenOperatorPrecedence(54) || !this.prodParam.hasIn || !this.match(54)) {
|
|
14681
|
-
this.raise(
|
|
15006
|
+
this.raise(ErrorMessages.PrivateInExpectedIn, {
|
|
15007
|
+
node: left
|
|
15008
|
+
}, value);
|
|
14682
15009
|
}
|
|
14683
15010
|
|
|
14684
|
-
this.classScope.usePrivateName(value, start);
|
|
15011
|
+
this.classScope.usePrivateName(value, left.loc.start);
|
|
14685
15012
|
}
|
|
14686
15013
|
|
|
14687
15014
|
var op = this.state.type;
|
|
@@ -14697,7 +15024,7 @@
|
|
|
14697
15024
|
return left;
|
|
14698
15025
|
}
|
|
14699
15026
|
|
|
14700
|
-
this.checkPipelineAtInfixOperator(left,
|
|
15027
|
+
this.checkPipelineAtInfixOperator(left, leftStartLoc);
|
|
14701
15028
|
}
|
|
14702
15029
|
|
|
14703
15030
|
var node = this.startNodeAt(leftStartPos, leftStartLoc);
|
|
@@ -14716,7 +15043,9 @@
|
|
|
14716
15043
|
proposal: "minimal"
|
|
14717
15044
|
}])) {
|
|
14718
15045
|
if (this.state.type === 92 && this.prodParam.hasAwait) {
|
|
14719
|
-
throw this.raise(
|
|
15046
|
+
throw this.raise(ErrorMessages.UnexpectedAwaitAfterPipelineBody, {
|
|
15047
|
+
at: this.state.startLoc
|
|
15048
|
+
});
|
|
14720
15049
|
}
|
|
14721
15050
|
}
|
|
14722
15051
|
|
|
@@ -14725,7 +15054,9 @@
|
|
|
14725
15054
|
var nextOp = this.state.type;
|
|
14726
15055
|
|
|
14727
15056
|
if (coalesce && (nextOp === 39 || nextOp === 40) || logical && nextOp === 38) {
|
|
14728
|
-
throw this.raise(
|
|
15057
|
+
throw this.raise(ErrorMessages.MixingCoalesceWithLogical, {
|
|
15058
|
+
at: this.state.startLoc
|
|
15059
|
+
});
|
|
14729
15060
|
}
|
|
14730
15061
|
|
|
14731
15062
|
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
|
|
@@ -14750,7 +15081,9 @@
|
|
|
14750
15081
|
case "smart":
|
|
14751
15082
|
return this.withTopicBindingContext(() => {
|
|
14752
15083
|
if (this.prodParam.hasYield && this.isContextual(101)) {
|
|
14753
|
-
throw this.raise(
|
|
15084
|
+
throw this.raise(ErrorMessages.PipeBodyIsTighter, {
|
|
15085
|
+
at: this.state.startLoc
|
|
15086
|
+
}, this.state.value);
|
|
14754
15087
|
}
|
|
14755
15088
|
|
|
14756
15089
|
return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startPos, startLoc);
|
|
@@ -14777,16 +15110,20 @@
|
|
|
14777
15110
|
var _body$extra;
|
|
14778
15111
|
|
|
14779
15112
|
var {
|
|
14780
|
-
|
|
15113
|
+
startLoc
|
|
14781
15114
|
} = this.state;
|
|
14782
15115
|
var body = this.parseMaybeAssign();
|
|
14783
15116
|
|
|
14784
15117
|
if (invalidHackPipeBodies.has(body.type) && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
|
|
14785
|
-
this.raise(
|
|
15118
|
+
this.raise(ErrorMessages.PipeUnparenthesizedBody, {
|
|
15119
|
+
at: startLoc
|
|
15120
|
+
}, invalidHackPipeBodies.get(body.type));
|
|
14786
15121
|
}
|
|
14787
15122
|
|
|
14788
15123
|
if (!this.topicReferenceWasUsedInCurrentContext()) {
|
|
14789
|
-
this.raise(
|
|
15124
|
+
this.raise(ErrorMessages.PipeTopicUnused, {
|
|
15125
|
+
at: startLoc
|
|
15126
|
+
});
|
|
14790
15127
|
}
|
|
14791
15128
|
|
|
14792
15129
|
return body;
|
|
@@ -14794,7 +15131,9 @@
|
|
|
14794
15131
|
|
|
14795
15132
|
checkExponentialAfterUnary(node) {
|
|
14796
15133
|
if (this.match(53)) {
|
|
14797
|
-
this.raise(
|
|
15134
|
+
this.raise(ErrorMessages.UnexpectedTokenUnaryExponentiation, {
|
|
15135
|
+
node: node.argument
|
|
15136
|
+
});
|
|
14798
15137
|
}
|
|
14799
15138
|
}
|
|
14800
15139
|
|
|
@@ -14832,9 +15171,13 @@
|
|
|
14832
15171
|
var arg = node.argument;
|
|
14833
15172
|
|
|
14834
15173
|
if (arg.type === "Identifier") {
|
|
14835
|
-
this.raise(
|
|
15174
|
+
this.raise(ErrorMessages.StrictDelete, {
|
|
15175
|
+
node
|
|
15176
|
+
});
|
|
14836
15177
|
} else if (this.hasPropertyAsPrivateName(arg)) {
|
|
14837
|
-
this.raise(
|
|
15178
|
+
this.raise(ErrorMessages.DeletePrivateField, {
|
|
15179
|
+
node
|
|
15180
|
+
});
|
|
14838
15181
|
}
|
|
14839
15182
|
}
|
|
14840
15183
|
|
|
@@ -14854,7 +15197,7 @@
|
|
|
14854
15197
|
var _startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(50);
|
|
14855
15198
|
|
|
14856
15199
|
if (_startsExpr && !this.isAmbiguousAwait()) {
|
|
14857
|
-
this.raiseOverwrite(
|
|
15200
|
+
this.raiseOverwrite(startLoc, ErrorMessages.AwaitNotInAsyncContext);
|
|
14858
15201
|
return this.parseAwait(startPos, startLoc);
|
|
14859
15202
|
}
|
|
14860
15203
|
}
|
|
@@ -14962,10 +15305,12 @@
|
|
|
14962
15305
|
this.expect(3);
|
|
14963
15306
|
} else if (this.match(130)) {
|
|
14964
15307
|
if (base.type === "Super") {
|
|
14965
|
-
this.raise(
|
|
15308
|
+
this.raise(ErrorMessages.SuperPrivateField, {
|
|
15309
|
+
at: startLoc
|
|
15310
|
+
});
|
|
14966
15311
|
}
|
|
14967
15312
|
|
|
14968
|
-
this.classScope.usePrivateName(this.state.value, this.state.
|
|
15313
|
+
this.classScope.usePrivateName(this.state.value, this.state.startLoc);
|
|
14969
15314
|
node.property = this.parsePrivateName();
|
|
14970
15315
|
} else {
|
|
14971
15316
|
node.property = this.parseIdentifier(true);
|
|
@@ -15041,14 +15386,16 @@
|
|
|
15041
15386
|
node.quasi = this.parseTemplate(true);
|
|
15042
15387
|
|
|
15043
15388
|
if (state.optionalChainMember) {
|
|
15044
|
-
this.raise(
|
|
15389
|
+
this.raise(ErrorMessages.OptionalChainingNoTemplate, {
|
|
15390
|
+
at: startLoc
|
|
15391
|
+
});
|
|
15045
15392
|
}
|
|
15046
15393
|
|
|
15047
15394
|
return this.finishNode(node, "TaggedTemplateExpression");
|
|
15048
15395
|
}
|
|
15049
15396
|
|
|
15050
15397
|
atPossibleAsyncArrow(base) {
|
|
15051
|
-
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;
|
|
15052
15399
|
}
|
|
15053
15400
|
|
|
15054
15401
|
finishCallExpression(node, optional) {
|
|
@@ -15062,11 +15409,15 @@
|
|
|
15062
15409
|
}
|
|
15063
15410
|
|
|
15064
15411
|
if (node.arguments.length === 0 || node.arguments.length > 2) {
|
|
15065
|
-
this.raise(
|
|
15412
|
+
this.raise(ErrorMessages.ImportCallArity, {
|
|
15413
|
+
node
|
|
15414
|
+
}, this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? "one or two arguments" : "one argument");
|
|
15066
15415
|
} else {
|
|
15067
15416
|
for (var arg of node.arguments) {
|
|
15068
15417
|
if (arg.type === "SpreadElement") {
|
|
15069
|
-
this.raise(
|
|
15418
|
+
this.raise(ErrorMessages.ImportCallSpreadArgument, {
|
|
15419
|
+
node: arg
|
|
15420
|
+
});
|
|
15070
15421
|
}
|
|
15071
15422
|
}
|
|
15072
15423
|
}
|
|
@@ -15089,11 +15440,13 @@
|
|
|
15089
15440
|
|
|
15090
15441
|
if (this.match(close)) {
|
|
15091
15442
|
if (dynamicImport && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
|
|
15092
|
-
this.raise(
|
|
15443
|
+
this.raise(ErrorMessages.ImportCallArgumentTrailingComma, {
|
|
15444
|
+
at: this.state.lastTokStartLoc
|
|
15445
|
+
});
|
|
15093
15446
|
}
|
|
15094
15447
|
|
|
15095
15448
|
if (nodeForExtra) {
|
|
15096
|
-
this.
|
|
15449
|
+
this.addTrailingCommaExtraToNode(nodeForExtra);
|
|
15097
15450
|
}
|
|
15098
15451
|
|
|
15099
15452
|
this.next();
|
|
@@ -15117,7 +15470,7 @@
|
|
|
15117
15470
|
|
|
15118
15471
|
this.resetPreviousNodeTrailingComments(call);
|
|
15119
15472
|
this.expect(19);
|
|
15120
|
-
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);
|
|
15121
15474
|
|
|
15122
15475
|
if (call.innerComments) {
|
|
15123
15476
|
setInnerComments(node, call.innerComments);
|
|
@@ -15155,7 +15508,9 @@
|
|
|
15155
15508
|
}
|
|
15156
15509
|
|
|
15157
15510
|
if (!this.match(10)) {
|
|
15158
|
-
this.raise(
|
|
15511
|
+
this.raise(ErrorMessages.UnsupportedImport, {
|
|
15512
|
+
at: this.state.lastTokStartLoc
|
|
15513
|
+
});
|
|
15159
15514
|
}
|
|
15160
15515
|
|
|
15161
15516
|
return this.finishNode(node, "Import");
|
|
@@ -15254,13 +15609,17 @@
|
|
|
15254
15609
|
if (callee.type === "MemberExpression") {
|
|
15255
15610
|
return this.finishNode(node, "BindExpression");
|
|
15256
15611
|
} else {
|
|
15257
|
-
throw this.raise(
|
|
15612
|
+
throw this.raise(ErrorMessages.UnsupportedBind, {
|
|
15613
|
+
node: callee
|
|
15614
|
+
});
|
|
15258
15615
|
}
|
|
15259
15616
|
}
|
|
15260
15617
|
|
|
15261
15618
|
case 130:
|
|
15262
15619
|
{
|
|
15263
|
-
this.raise(
|
|
15620
|
+
this.raise(ErrorMessages.PrivateInExpectedIn, {
|
|
15621
|
+
at: this.state.startLoc
|
|
15622
|
+
}, this.state.value);
|
|
15264
15623
|
return this.parsePrivateName();
|
|
15265
15624
|
}
|
|
15266
15625
|
|
|
@@ -15352,7 +15711,7 @@
|
|
|
15352
15711
|
this.state.value = topicTokenValue;
|
|
15353
15712
|
this.state.pos--;
|
|
15354
15713
|
this.state.end--;
|
|
15355
|
-
this.state.endLoc.
|
|
15714
|
+
this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
|
|
15356
15715
|
return this.parseTopicReference(pipeProposal);
|
|
15357
15716
|
} else {
|
|
15358
15717
|
throw this.unexpected();
|
|
@@ -15361,38 +15720,32 @@
|
|
|
15361
15720
|
|
|
15362
15721
|
parseTopicReference(pipeProposal) {
|
|
15363
15722
|
var node = this.startNode();
|
|
15364
|
-
var
|
|
15723
|
+
var startLoc = this.state.startLoc;
|
|
15365
15724
|
var tokenType = this.state.type;
|
|
15366
15725
|
this.next();
|
|
15367
|
-
return this.finishTopicReference(node,
|
|
15726
|
+
return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
|
|
15368
15727
|
}
|
|
15369
15728
|
|
|
15370
|
-
finishTopicReference(node,
|
|
15371
|
-
if (this.testTopicReferenceConfiguration(pipeProposal,
|
|
15372
|
-
var nodeType;
|
|
15373
|
-
|
|
15374
|
-
if (pipeProposal === "smart") {
|
|
15375
|
-
nodeType = "PipelinePrimaryTopicReference";
|
|
15376
|
-
} else {
|
|
15377
|
-
nodeType = "TopicReference";
|
|
15378
|
-
}
|
|
15729
|
+
finishTopicReference(node, startLoc, pipeProposal, tokenType) {
|
|
15730
|
+
if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
|
|
15731
|
+
var nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
|
|
15379
15732
|
|
|
15380
15733
|
if (!this.topicReferenceIsAllowedInCurrentContext()) {
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
}
|
|
15384
|
-
this.raise(start, ErrorMessages.PipeTopicUnbound);
|
|
15385
|
-
}
|
|
15734
|
+
this.raise(pipeProposal === "smart" ? ErrorMessages.PrimaryTopicNotAllowed : ErrorMessages.PipeTopicUnbound, {
|
|
15735
|
+
at: startLoc
|
|
15736
|
+
});
|
|
15386
15737
|
}
|
|
15387
15738
|
|
|
15388
15739
|
this.registerTopicReference();
|
|
15389
15740
|
return this.finishNode(node, nodeType);
|
|
15390
15741
|
} else {
|
|
15391
|
-
throw this.raise(
|
|
15742
|
+
throw this.raise(ErrorMessages.PipeTopicUnconfiguredToken, {
|
|
15743
|
+
at: startLoc
|
|
15744
|
+
}, tokenLabelName(tokenType));
|
|
15392
15745
|
}
|
|
15393
15746
|
}
|
|
15394
15747
|
|
|
15395
|
-
testTopicReferenceConfiguration(pipeProposal,
|
|
15748
|
+
testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
|
|
15396
15749
|
switch (pipeProposal) {
|
|
15397
15750
|
case "hack":
|
|
15398
15751
|
{
|
|
@@ -15405,7 +15758,9 @@
|
|
|
15405
15758
|
return tokenType === 27;
|
|
15406
15759
|
|
|
15407
15760
|
default:
|
|
15408
|
-
throw this.raise(
|
|
15761
|
+
throw this.raise(ErrorMessages.PipeTopicRequiresHackPipes, {
|
|
15762
|
+
at: startLoc
|
|
15763
|
+
});
|
|
15409
15764
|
}
|
|
15410
15765
|
}
|
|
15411
15766
|
|
|
@@ -15415,7 +15770,9 @@
|
|
|
15415
15770
|
this.prodParam.exit();
|
|
15416
15771
|
|
|
15417
15772
|
if (this.hasPrecedingLineBreak()) {
|
|
15418
|
-
this.raise(
|
|
15773
|
+
this.raise(ErrorMessages.LineTerminatorBeforeArrow, {
|
|
15774
|
+
at: this.state.curPosition()
|
|
15775
|
+
});
|
|
15419
15776
|
}
|
|
15420
15777
|
|
|
15421
15778
|
this.expect(19);
|
|
@@ -15452,13 +15809,19 @@
|
|
|
15452
15809
|
this.next();
|
|
15453
15810
|
|
|
15454
15811
|
if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
|
|
15455
|
-
this.raise(
|
|
15812
|
+
this.raise(ErrorMessages.SuperNotAllowed, {
|
|
15813
|
+
node
|
|
15814
|
+
});
|
|
15456
15815
|
} else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
|
|
15457
|
-
this.raise(
|
|
15816
|
+
this.raise(ErrorMessages.UnexpectedSuper, {
|
|
15817
|
+
node
|
|
15818
|
+
});
|
|
15458
15819
|
}
|
|
15459
15820
|
|
|
15460
15821
|
if (!this.match(10) && !this.match(0) && !this.match(16)) {
|
|
15461
|
-
this.raise(
|
|
15822
|
+
this.raise(ErrorMessages.UnsupportedSuper, {
|
|
15823
|
+
node
|
|
15824
|
+
});
|
|
15462
15825
|
}
|
|
15463
15826
|
|
|
15464
15827
|
return this.finishNode(node, "Super");
|
|
@@ -15466,7 +15829,7 @@
|
|
|
15466
15829
|
|
|
15467
15830
|
parsePrivateName() {
|
|
15468
15831
|
var node = this.startNode();
|
|
15469
|
-
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));
|
|
15470
15833
|
var name = this.state.value;
|
|
15471
15834
|
this.next();
|
|
15472
15835
|
node.id = this.createIdentifier(id, name);
|
|
@@ -15499,7 +15862,9 @@
|
|
|
15499
15862
|
node.property = this.parseIdentifier(true);
|
|
15500
15863
|
|
|
15501
15864
|
if (node.property.name !== propertyName || containsEsc) {
|
|
15502
|
-
this.raise(
|
|
15865
|
+
this.raise(ErrorMessages.UnsupportedMetaProperty, {
|
|
15866
|
+
node: node.property
|
|
15867
|
+
}, meta.name, propertyName);
|
|
15503
15868
|
}
|
|
15504
15869
|
|
|
15505
15870
|
return this.finishNode(node, "MetaProperty");
|
|
@@ -15511,7 +15876,9 @@
|
|
|
15511
15876
|
|
|
15512
15877
|
if (this.isContextual(96)) {
|
|
15513
15878
|
if (!this.inModule) {
|
|
15514
|
-
this.raise(
|
|
15879
|
+
this.raise(SourceTypeModuleErrorMessages.ImportMetaOutsideModule, {
|
|
15880
|
+
node: id
|
|
15881
|
+
});
|
|
15515
15882
|
}
|
|
15516
15883
|
|
|
15517
15884
|
this.sawUnambiguousESM = true;
|
|
@@ -15584,17 +15951,17 @@
|
|
|
15584
15951
|
var exprList = [];
|
|
15585
15952
|
var refExpressionErrors = new ExpressionErrors();
|
|
15586
15953
|
var first = true;
|
|
15587
|
-
var
|
|
15588
|
-
var
|
|
15954
|
+
var spreadStartLoc;
|
|
15955
|
+
var optionalCommaStartLoc;
|
|
15589
15956
|
|
|
15590
15957
|
while (!this.match(11)) {
|
|
15591
15958
|
if (first) {
|
|
15592
15959
|
first = false;
|
|
15593
15960
|
} else {
|
|
15594
|
-
this.expect(12, refExpressionErrors.
|
|
15961
|
+
this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
|
|
15595
15962
|
|
|
15596
15963
|
if (this.match(11)) {
|
|
15597
|
-
|
|
15964
|
+
optionalCommaStartLoc = this.state.startLoc;
|
|
15598
15965
|
break;
|
|
15599
15966
|
}
|
|
15600
15967
|
}
|
|
@@ -15602,16 +15969,17 @@
|
|
|
15602
15969
|
if (this.match(21)) {
|
|
15603
15970
|
var spreadNodeStartPos = this.state.start;
|
|
15604
15971
|
var spreadNodeStartLoc = this.state.startLoc;
|
|
15605
|
-
|
|
15972
|
+
spreadStartLoc = this.state.startLoc;
|
|
15606
15973
|
exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc));
|
|
15607
|
-
|
|
15608
|
-
|
|
15974
|
+
|
|
15975
|
+
if (!this.checkCommaAfterRest(41)) {
|
|
15976
|
+
break;
|
|
15977
|
+
}
|
|
15609
15978
|
} else {
|
|
15610
15979
|
exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
|
|
15611
15980
|
}
|
|
15612
15981
|
}
|
|
15613
15982
|
|
|
15614
|
-
var innerEndPos = this.state.lastTokEnd;
|
|
15615
15983
|
var innerEndLoc = this.state.lastTokEndLoc;
|
|
15616
15984
|
this.expect(11);
|
|
15617
15985
|
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
@@ -15628,11 +15996,11 @@
|
|
|
15628
15996
|
this.expressionScope.exit();
|
|
15629
15997
|
|
|
15630
15998
|
if (!exprList.length) {
|
|
15631
|
-
this.unexpected(this.state.
|
|
15999
|
+
this.unexpected(this.state.lastTokStartLoc);
|
|
15632
16000
|
}
|
|
15633
16001
|
|
|
15634
|
-
if (
|
|
15635
|
-
if (
|
|
16002
|
+
if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
|
|
16003
|
+
if (spreadStartLoc) this.unexpected(spreadStartLoc);
|
|
15636
16004
|
this.checkExpressionErrors(refExpressionErrors, true);
|
|
15637
16005
|
this.toReferencedListDeep(exprList, true);
|
|
15638
16006
|
|
|
@@ -15640,7 +16008,7 @@
|
|
|
15640
16008
|
val = this.startNodeAt(innerStartPos, innerStartLoc);
|
|
15641
16009
|
val.expressions = exprList;
|
|
15642
16010
|
this.finishNode(val, "SequenceExpression");
|
|
15643
|
-
this.resetEndLocation(val,
|
|
16011
|
+
this.resetEndLocation(val, innerEndLoc);
|
|
15644
16012
|
} else {
|
|
15645
16013
|
val = exprList[0];
|
|
15646
16014
|
}
|
|
@@ -15648,7 +16016,7 @@
|
|
|
15648
16016
|
if (!this.options.createParenthesizedExpressions) {
|
|
15649
16017
|
this.addExtra(val, "parenthesized", true);
|
|
15650
16018
|
this.addExtra(val, "parenStart", startPos);
|
|
15651
|
-
this.takeSurroundingComments(val, startPos, this.state.
|
|
16019
|
+
this.takeSurroundingComments(val, startPos, indexes.get(this.state.lastTokEndLoc));
|
|
15652
16020
|
return val;
|
|
15653
16021
|
}
|
|
15654
16022
|
|
|
@@ -15682,7 +16050,9 @@
|
|
|
15682
16050
|
var metaProp = this.parseMetaProperty(node, meta, "target");
|
|
15683
16051
|
|
|
15684
16052
|
if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
|
|
15685
|
-
this.raise(
|
|
16053
|
+
this.raise(ErrorMessages.UnexpectedNewTarget, {
|
|
16054
|
+
node: metaProp
|
|
16055
|
+
});
|
|
15686
16056
|
}
|
|
15687
16057
|
|
|
15688
16058
|
return metaProp;
|
|
@@ -15695,11 +16065,17 @@
|
|
|
15695
16065
|
node.callee = this.parseNoCallExpr();
|
|
15696
16066
|
|
|
15697
16067
|
if (node.callee.type === "Import") {
|
|
15698
|
-
this.raise(
|
|
16068
|
+
this.raise(ErrorMessages.ImportCallNotNewExpression, {
|
|
16069
|
+
node: node.callee
|
|
16070
|
+
});
|
|
15699
16071
|
} else if (this.isOptionalChain(node.callee)) {
|
|
15700
|
-
this.raise(
|
|
16072
|
+
this.raise(ErrorMessages.OptionalChainingNoNew, {
|
|
16073
|
+
at: this.state.lastTokEndLoc
|
|
16074
|
+
});
|
|
15701
16075
|
} else if (this.eat(18)) {
|
|
15702
|
-
this.raise(
|
|
16076
|
+
this.raise(ErrorMessages.OptionalChainingNoNew, {
|
|
16077
|
+
at: this.state.startLoc
|
|
16078
|
+
});
|
|
15703
16079
|
}
|
|
15704
16080
|
|
|
15705
16081
|
this.parseNewArguments(node);
|
|
@@ -15719,15 +16095,18 @@
|
|
|
15719
16095
|
parseTemplateElement(isTagged) {
|
|
15720
16096
|
var {
|
|
15721
16097
|
start,
|
|
16098
|
+
startLoc,
|
|
15722
16099
|
end,
|
|
15723
16100
|
value
|
|
15724
16101
|
} = this.state;
|
|
15725
16102
|
var elemStart = start + 1;
|
|
15726
|
-
var elem = this.startNodeAt(elemStart, createPositionWithColumnOffset(
|
|
16103
|
+
var elem = this.startNodeAt(elemStart, createPositionWithColumnOffset(startLoc, 1));
|
|
15727
16104
|
|
|
15728
16105
|
if (value === null) {
|
|
15729
16106
|
if (!isTagged) {
|
|
15730
|
-
this.raise(
|
|
16107
|
+
this.raise(ErrorMessages.InvalidEscapeSequenceTemplate, {
|
|
16108
|
+
at: createPositionWithColumnOffset(startLoc, 2)
|
|
16109
|
+
});
|
|
15731
16110
|
}
|
|
15732
16111
|
}
|
|
15733
16112
|
|
|
@@ -15741,7 +16120,7 @@
|
|
|
15741
16120
|
elem.tail = isTail;
|
|
15742
16121
|
this.next();
|
|
15743
16122
|
this.finishNode(elem, "TemplateElement");
|
|
15744
|
-
this.resetEndLocation(elem,
|
|
16123
|
+
this.resetEndLocation(elem, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
|
|
15745
16124
|
return elem;
|
|
15746
16125
|
}
|
|
15747
16126
|
|
|
@@ -15784,7 +16163,7 @@
|
|
|
15784
16163
|
this.expect(12);
|
|
15785
16164
|
|
|
15786
16165
|
if (this.match(close)) {
|
|
15787
|
-
this.
|
|
16166
|
+
this.addTrailingCommaExtraToNode(node);
|
|
15788
16167
|
break;
|
|
15789
16168
|
}
|
|
15790
16169
|
}
|
|
@@ -15799,7 +16178,9 @@
|
|
|
15799
16178
|
}
|
|
15800
16179
|
|
|
15801
16180
|
if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
|
|
15802
|
-
this.raise(
|
|
16181
|
+
this.raise(ErrorMessages.InvalidRecordProperty, {
|
|
16182
|
+
node: prop
|
|
16183
|
+
});
|
|
15803
16184
|
}
|
|
15804
16185
|
|
|
15805
16186
|
if (prop.shorthand) {
|
|
@@ -15822,6 +16203,11 @@
|
|
|
15822
16203
|
return this.finishNode(node, type);
|
|
15823
16204
|
}
|
|
15824
16205
|
|
|
16206
|
+
addTrailingCommaExtraToNode(node) {
|
|
16207
|
+
this.addExtra(node, "trailingComma", this.state.lastTokStart);
|
|
16208
|
+
this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
|
|
16209
|
+
}
|
|
16210
|
+
|
|
15825
16211
|
maybeAsyncOrAccessorProp(prop) {
|
|
15826
16212
|
return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(51));
|
|
15827
16213
|
}
|
|
@@ -15831,7 +16217,9 @@
|
|
|
15831
16217
|
|
|
15832
16218
|
if (this.match(26)) {
|
|
15833
16219
|
if (this.hasPlugin("decorators")) {
|
|
15834
|
-
this.raise(
|
|
16220
|
+
this.raise(ErrorMessages.UnsupportedPropertyDecorator, {
|
|
16221
|
+
at: this.state.startLoc
|
|
16222
|
+
});
|
|
15835
16223
|
}
|
|
15836
16224
|
|
|
15837
16225
|
while (this.match(26)) {
|
|
@@ -15884,7 +16272,9 @@
|
|
|
15884
16272
|
|
|
15885
16273
|
if (this.match(51)) {
|
|
15886
16274
|
isGenerator = true;
|
|
15887
|
-
this.raise(
|
|
16275
|
+
this.raise(ErrorMessages.AccessorIsGenerator, {
|
|
16276
|
+
at: this.state.curPosition()
|
|
16277
|
+
}, keyName);
|
|
15888
16278
|
this.next();
|
|
15889
16279
|
}
|
|
15890
16280
|
|
|
@@ -15909,18 +16299,17 @@
|
|
|
15909
16299
|
|
|
15910
16300
|
var paramCount = this.getGetterSetterExpectedParamCount(method);
|
|
15911
16301
|
var params = this.getObjectOrClassMethodParams(method);
|
|
15912
|
-
var start = method.start;
|
|
15913
16302
|
|
|
15914
16303
|
if (params.length !== paramCount) {
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
}
|
|
15918
|
-
this.raise(start, ErrorMessages.BadSetterArity);
|
|
15919
|
-
}
|
|
16304
|
+
this.raise(method.kind === "get" ? ErrorMessages.BadGetterArity : ErrorMessages.BadSetterArity, {
|
|
16305
|
+
node: method
|
|
16306
|
+
});
|
|
15920
16307
|
}
|
|
15921
16308
|
|
|
15922
16309
|
if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
|
|
15923
|
-
this.raise(
|
|
16310
|
+
this.raise(ErrorMessages.BadSetterRestParameter, {
|
|
16311
|
+
node: method
|
|
16312
|
+
});
|
|
15924
16313
|
}
|
|
15925
16314
|
}
|
|
15926
16315
|
|
|
@@ -15948,19 +16337,21 @@
|
|
|
15948
16337
|
}
|
|
15949
16338
|
|
|
15950
16339
|
if (!prop.computed && prop.key.type === "Identifier") {
|
|
15951
|
-
this.checkReservedWord(prop.key.name, prop.key.start, true, false);
|
|
16340
|
+
this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
|
|
15952
16341
|
|
|
15953
16342
|
if (isPattern) {
|
|
15954
16343
|
prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
|
|
15955
16344
|
} else if (this.match(29)) {
|
|
15956
|
-
var
|
|
16345
|
+
var shorthandAssignLoc = this.state.startLoc;
|
|
15957
16346
|
|
|
15958
16347
|
if (refExpressionErrors != null) {
|
|
15959
|
-
if (refExpressionErrors.
|
|
15960
|
-
refExpressionErrors.
|
|
16348
|
+
if (refExpressionErrors.shorthandAssignLoc === null) {
|
|
16349
|
+
refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
|
|
15961
16350
|
}
|
|
15962
16351
|
} else {
|
|
15963
|
-
this.raise(
|
|
16352
|
+
this.raise(ErrorMessages.InvalidCoverInitializedName, {
|
|
16353
|
+
at: shorthandAssignLoc
|
|
16354
|
+
});
|
|
15964
16355
|
}
|
|
15965
16356
|
|
|
15966
16357
|
prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
|
|
@@ -16013,8 +16404,9 @@
|
|
|
16013
16404
|
|
|
16014
16405
|
case 130:
|
|
16015
16406
|
{
|
|
16016
|
-
|
|
16017
|
-
|
|
16407
|
+
this.raise(ErrorMessages.UnexpectedPrivateField, {
|
|
16408
|
+
at: createPositionWithColumnOffset(this.state.startLoc, 1)
|
|
16409
|
+
});
|
|
16018
16410
|
key = this.parsePrivateName();
|
|
16019
16411
|
break;
|
|
16020
16412
|
}
|
|
@@ -16068,11 +16460,11 @@
|
|
|
16068
16460
|
return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
|
|
16069
16461
|
}
|
|
16070
16462
|
|
|
16071
|
-
parseArrowExpression(node, params, isAsync,
|
|
16463
|
+
parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
|
|
16072
16464
|
this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
|
|
16073
16465
|
var flags = functionFlags(isAsync, false);
|
|
16074
16466
|
|
|
16075
|
-
if (!this.match(
|
|
16467
|
+
if (!this.match(5) && this.prodParam.hasIn) {
|
|
16076
16468
|
flags |= PARAM_IN;
|
|
16077
16469
|
}
|
|
16078
16470
|
|
|
@@ -16082,7 +16474,7 @@
|
|
|
16082
16474
|
|
|
16083
16475
|
if (params) {
|
|
16084
16476
|
this.state.maybeInArrowParameters = true;
|
|
16085
|
-
this.setArrowFunctionParameters(node, params,
|
|
16477
|
+
this.setArrowFunctionParameters(node, params, trailingCommaLoc);
|
|
16086
16478
|
}
|
|
16087
16479
|
|
|
16088
16480
|
this.state.maybeInArrowParameters = false;
|
|
@@ -16093,8 +16485,8 @@
|
|
|
16093
16485
|
return this.finishNode(node, "ArrowFunctionExpression");
|
|
16094
16486
|
}
|
|
16095
16487
|
|
|
16096
|
-
setArrowFunctionParameters(node, params,
|
|
16097
|
-
node.params = this.toAssignableList(params,
|
|
16488
|
+
setArrowFunctionParameters(node, params, trailingCommaLoc) {
|
|
16489
|
+
node.params = this.toAssignableList(params, trailingCommaLoc, false);
|
|
16098
16490
|
}
|
|
16099
16491
|
|
|
16100
16492
|
parseFunctionBodyAndFinish(node, type) {
|
|
@@ -16120,8 +16512,12 @@
|
|
|
16120
16512
|
var nonSimple = !this.isSimpleParamList(node.params);
|
|
16121
16513
|
|
|
16122
16514
|
if (hasStrictModeDirective && nonSimple) {
|
|
16123
|
-
var
|
|
16124
|
-
|
|
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);
|
|
16125
16521
|
}
|
|
16126
16522
|
|
|
16127
16523
|
var strictModeChanged = !oldStrict && this.state.strict;
|
|
@@ -16167,7 +16563,7 @@
|
|
|
16167
16563
|
|
|
16168
16564
|
if (this.match(close)) {
|
|
16169
16565
|
if (nodeForExtra) {
|
|
16170
|
-
this.
|
|
16566
|
+
this.addTrailingCommaExtraToNode(nodeForExtra);
|
|
16171
16567
|
}
|
|
16172
16568
|
|
|
16173
16569
|
this.next();
|
|
@@ -16186,7 +16582,9 @@
|
|
|
16186
16582
|
|
|
16187
16583
|
if (this.match(12)) {
|
|
16188
16584
|
if (!allowEmpty) {
|
|
16189
|
-
this.raise(
|
|
16585
|
+
this.raise(ErrorMessages.UnexpectedToken, {
|
|
16586
|
+
at: this.state.curPosition()
|
|
16587
|
+
}, ",");
|
|
16190
16588
|
}
|
|
16191
16589
|
|
|
16192
16590
|
elt = null;
|
|
@@ -16198,7 +16596,9 @@
|
|
|
16198
16596
|
this.expectPlugin("partialApplication");
|
|
16199
16597
|
|
|
16200
16598
|
if (!allowPlaceholder) {
|
|
16201
|
-
this.raise(
|
|
16599
|
+
this.raise(ErrorMessages.UnexpectedArgumentPlaceholder, {
|
|
16600
|
+
at: this.state.startLoc
|
|
16601
|
+
});
|
|
16202
16602
|
}
|
|
16203
16603
|
|
|
16204
16604
|
var node = this.startNode();
|
|
@@ -16226,7 +16626,7 @@
|
|
|
16226
16626
|
parseIdentifierName(pos, liberal) {
|
|
16227
16627
|
var name;
|
|
16228
16628
|
var {
|
|
16229
|
-
|
|
16629
|
+
startLoc,
|
|
16230
16630
|
type
|
|
16231
16631
|
} = this.state;
|
|
16232
16632
|
|
|
@@ -16243,7 +16643,7 @@
|
|
|
16243
16643
|
this.replaceToken(124);
|
|
16244
16644
|
}
|
|
16245
16645
|
} else {
|
|
16246
|
-
this.checkReservedWord(name,
|
|
16646
|
+
this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
|
|
16247
16647
|
}
|
|
16248
16648
|
|
|
16249
16649
|
this.next();
|
|
@@ -16261,35 +16661,49 @@
|
|
|
16261
16661
|
|
|
16262
16662
|
if (word === "yield") {
|
|
16263
16663
|
if (this.prodParam.hasYield) {
|
|
16264
|
-
this.raise(
|
|
16664
|
+
this.raise(ErrorMessages.YieldBindingIdentifier, {
|
|
16665
|
+
at: startLoc
|
|
16666
|
+
});
|
|
16265
16667
|
return;
|
|
16266
16668
|
}
|
|
16267
16669
|
} else if (word === "await") {
|
|
16268
16670
|
if (this.prodParam.hasAwait) {
|
|
16269
|
-
this.raise(
|
|
16671
|
+
this.raise(ErrorMessages.AwaitBindingIdentifier, {
|
|
16672
|
+
at: startLoc
|
|
16673
|
+
});
|
|
16270
16674
|
return;
|
|
16271
|
-
}
|
|
16272
|
-
|
|
16675
|
+
}
|
|
16676
|
+
|
|
16677
|
+
if (this.scope.inStaticBlock) {
|
|
16678
|
+
this.raise(ErrorMessages.AwaitBindingIdentifierInStaticBlock, {
|
|
16679
|
+
at: startLoc
|
|
16680
|
+
});
|
|
16273
16681
|
return;
|
|
16274
|
-
} else {
|
|
16275
|
-
this.expressionScope.recordAsyncArrowParametersError(startLoc, ErrorMessages.AwaitBindingIdentifier);
|
|
16276
16682
|
}
|
|
16683
|
+
|
|
16684
|
+
this.expressionScope.recordAsyncArrowParametersError(ErrorMessages.AwaitBindingIdentifier, startLoc);
|
|
16277
16685
|
} else if (word === "arguments") {
|
|
16278
16686
|
if (this.scope.inClassAndNotInNonArrowFunction) {
|
|
16279
|
-
this.raise(
|
|
16687
|
+
this.raise(ErrorMessages.ArgumentsInClass, {
|
|
16688
|
+
at: startLoc
|
|
16689
|
+
});
|
|
16280
16690
|
return;
|
|
16281
16691
|
}
|
|
16282
16692
|
}
|
|
16283
16693
|
|
|
16284
16694
|
if (checkKeywords && isKeyword(word)) {
|
|
16285
|
-
this.raise(
|
|
16695
|
+
this.raise(ErrorMessages.UnexpectedKeyword, {
|
|
16696
|
+
at: startLoc
|
|
16697
|
+
}, word);
|
|
16286
16698
|
return;
|
|
16287
16699
|
}
|
|
16288
16700
|
|
|
16289
16701
|
var reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
|
|
16290
16702
|
|
|
16291
16703
|
if (reservedTest(word, this.inModule)) {
|
|
16292
|
-
this.raise(
|
|
16704
|
+
this.raise(ErrorMessages.UnexpectedReservedWord, {
|
|
16705
|
+
at: startLoc
|
|
16706
|
+
}, word);
|
|
16293
16707
|
}
|
|
16294
16708
|
}
|
|
16295
16709
|
|
|
@@ -16305,10 +16719,12 @@
|
|
|
16305
16719
|
|
|
16306
16720
|
parseAwait(startPos, startLoc) {
|
|
16307
16721
|
var node = this.startNodeAt(startPos, startLoc);
|
|
16308
|
-
this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.AwaitExpressionFormalParameter);
|
|
16722
|
+
this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.AwaitExpressionFormalParameter);
|
|
16309
16723
|
|
|
16310
16724
|
if (this.eat(51)) {
|
|
16311
|
-
this.raise(
|
|
16725
|
+
this.raise(ErrorMessages.ObsoleteAwaitStar, {
|
|
16726
|
+
node
|
|
16727
|
+
});
|
|
16312
16728
|
}
|
|
16313
16729
|
|
|
16314
16730
|
if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
|
|
@@ -16336,7 +16752,7 @@
|
|
|
16336
16752
|
|
|
16337
16753
|
parseYield() {
|
|
16338
16754
|
var node = this.startNode();
|
|
16339
|
-
this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.YieldInParameter);
|
|
16755
|
+
this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.YieldInParameter);
|
|
16340
16756
|
this.next();
|
|
16341
16757
|
var delegating = false;
|
|
16342
16758
|
var argument = null;
|
|
@@ -16365,22 +16781,18 @@
|
|
|
16365
16781
|
return this.finishNode(node, "YieldExpression");
|
|
16366
16782
|
}
|
|
16367
16783
|
|
|
16368
|
-
checkPipelineAtInfixOperator(left,
|
|
16784
|
+
checkPipelineAtInfixOperator(left, leftStartLoc) {
|
|
16369
16785
|
if (this.hasPlugin(["pipelineOperator", {
|
|
16370
16786
|
proposal: "smart"
|
|
16371
16787
|
}])) {
|
|
16372
16788
|
if (left.type === "SequenceExpression") {
|
|
16373
|
-
this.raise(
|
|
16789
|
+
this.raise(ErrorMessages.PipelineHeadSequenceExpression, {
|
|
16790
|
+
at: leftStartLoc
|
|
16791
|
+
});
|
|
16374
16792
|
}
|
|
16375
16793
|
}
|
|
16376
16794
|
}
|
|
16377
16795
|
|
|
16378
|
-
checkHackPipeBodyEarlyErrors(startPos) {
|
|
16379
|
-
if (!this.topicReferenceWasUsedInCurrentContext()) {
|
|
16380
|
-
this.raise(startPos, ErrorMessages.PipeTopicUnused);
|
|
16381
|
-
}
|
|
16382
|
-
}
|
|
16383
|
-
|
|
16384
16796
|
parseSmartPipelineBodyInStyle(childExpr, startPos, startLoc) {
|
|
16385
16797
|
var bodyNode = this.startNodeAt(startPos, startLoc);
|
|
16386
16798
|
|
|
@@ -16388,7 +16800,7 @@
|
|
|
16388
16800
|
bodyNode.callee = childExpr;
|
|
16389
16801
|
return this.finishNode(bodyNode, "PipelineBareFunction");
|
|
16390
16802
|
} else {
|
|
16391
|
-
this.checkSmartPipeTopicBodyEarlyErrors(
|
|
16803
|
+
this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
|
|
16392
16804
|
bodyNode.expression = childExpr;
|
|
16393
16805
|
return this.finishNode(bodyNode, "PipelineTopicExpression");
|
|
16394
16806
|
}
|
|
@@ -16407,11 +16819,17 @@
|
|
|
16407
16819
|
}
|
|
16408
16820
|
}
|
|
16409
16821
|
|
|
16410
|
-
checkSmartPipeTopicBodyEarlyErrors(
|
|
16822
|
+
checkSmartPipeTopicBodyEarlyErrors(startLoc) {
|
|
16411
16823
|
if (this.match(19)) {
|
|
16412
|
-
throw this.raise(
|
|
16413
|
-
|
|
16414
|
-
|
|
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
|
+
});
|
|
16415
16833
|
}
|
|
16416
16834
|
}
|
|
16417
16835
|
|
|
@@ -16691,9 +17109,10 @@
|
|
|
16691
17109
|
this.parseBlockBody(program, true, true, end);
|
|
16692
17110
|
|
|
16693
17111
|
if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
|
|
16694
|
-
for (var [name] of Array.from(this.scope.undefinedExports)) {
|
|
16695
|
-
|
|
16696
|
-
|
|
17112
|
+
for (var [name, loc] of Array.from(this.scope.undefinedExports)) {
|
|
17113
|
+
this.raise(ErrorMessages.ModuleExportUndefined, {
|
|
17114
|
+
at: loc
|
|
17115
|
+
}, name);
|
|
16697
17116
|
}
|
|
16698
17117
|
}
|
|
16699
17118
|
|
|
@@ -16802,9 +17221,13 @@
|
|
|
16802
17221
|
|
|
16803
17222
|
if (context) {
|
|
16804
17223
|
if (this.state.strict) {
|
|
16805
|
-
this.raise(
|
|
17224
|
+
this.raise(ErrorMessages.StrictFunction, {
|
|
17225
|
+
at: this.state.startLoc
|
|
17226
|
+
});
|
|
16806
17227
|
} else if (context !== "if" && context !== "label") {
|
|
16807
|
-
this.raise(
|
|
17228
|
+
this.raise(ErrorMessages.SloppyFunction, {
|
|
17229
|
+
at: this.state.startLoc
|
|
17230
|
+
});
|
|
16808
17231
|
}
|
|
16809
17232
|
}
|
|
16810
17233
|
|
|
@@ -16834,7 +17257,9 @@
|
|
|
16834
17257
|
kind = kind || this.state.value;
|
|
16835
17258
|
|
|
16836
17259
|
if (context && kind !== "var") {
|
|
16837
|
-
this.raise(
|
|
17260
|
+
this.raise(ErrorMessages.UnexpectedLexicalDeclaration, {
|
|
17261
|
+
at: this.state.startLoc
|
|
17262
|
+
});
|
|
16838
17263
|
}
|
|
16839
17264
|
|
|
16840
17265
|
return this.parseVarStatement(node, kind);
|
|
@@ -16863,7 +17288,9 @@
|
|
|
16863
17288
|
case 78:
|
|
16864
17289
|
{
|
|
16865
17290
|
if (!this.options.allowImportExportEverywhere && !topLevel) {
|
|
16866
|
-
this.raise(
|
|
17291
|
+
this.raise(ErrorMessages.UnexpectedImportExport, {
|
|
17292
|
+
at: this.state.startLoc
|
|
17293
|
+
});
|
|
16867
17294
|
}
|
|
16868
17295
|
|
|
16869
17296
|
this.next();
|
|
@@ -16891,7 +17318,9 @@
|
|
|
16891
17318
|
{
|
|
16892
17319
|
if (this.isAsyncFunction()) {
|
|
16893
17320
|
if (context) {
|
|
16894
|
-
this.raise(
|
|
17321
|
+
this.raise(ErrorMessages.AsyncFunctionInSingleStatementContext, {
|
|
17322
|
+
at: this.state.startLoc
|
|
17323
|
+
});
|
|
16895
17324
|
}
|
|
16896
17325
|
|
|
16897
17326
|
this.next();
|
|
@@ -16912,7 +17341,9 @@
|
|
|
16912
17341
|
|
|
16913
17342
|
assertModuleNodeAllowed(node) {
|
|
16914
17343
|
if (!this.options.allowImportExportEverywhere && !this.inModule) {
|
|
16915
|
-
this.raise(
|
|
17344
|
+
this.raise(SourceTypeModuleErrorMessages.ImportOutsideModule, {
|
|
17345
|
+
node
|
|
17346
|
+
});
|
|
16916
17347
|
}
|
|
16917
17348
|
}
|
|
16918
17349
|
|
|
@@ -16944,10 +17375,14 @@
|
|
|
16944
17375
|
}
|
|
16945
17376
|
|
|
16946
17377
|
if (this.hasPlugin("decorators") && !this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
|
16947
|
-
this.raise(
|
|
17378
|
+
this.raise(ErrorMessages.DecoratorExportClass, {
|
|
17379
|
+
at: this.state.startLoc
|
|
17380
|
+
});
|
|
16948
17381
|
}
|
|
16949
17382
|
} else if (!this.canHaveLeadingDecorator()) {
|
|
16950
|
-
throw this.raise(
|
|
17383
|
+
throw this.raise(ErrorMessages.UnexpectedLeadingDecorator, {
|
|
17384
|
+
at: this.state.startLoc
|
|
17385
|
+
});
|
|
16951
17386
|
}
|
|
16952
17387
|
}
|
|
16953
17388
|
|
|
@@ -17026,7 +17461,9 @@
|
|
|
17026
17461
|
}
|
|
17027
17462
|
|
|
17028
17463
|
if (i === this.state.labels.length) {
|
|
17029
|
-
this.raise(
|
|
17464
|
+
this.raise(ErrorMessages.IllegalBreakContinue, {
|
|
17465
|
+
node
|
|
17466
|
+
}, isBreak ? "break" : "continue");
|
|
17030
17467
|
}
|
|
17031
17468
|
}
|
|
17032
17469
|
|
|
@@ -17057,17 +17494,17 @@
|
|
|
17057
17494
|
parseForStatement(node) {
|
|
17058
17495
|
this.next();
|
|
17059
17496
|
this.state.labels.push(loopLabel);
|
|
17060
|
-
var awaitAt =
|
|
17497
|
+
var awaitAt = null;
|
|
17061
17498
|
|
|
17062
17499
|
if (this.isAwaitAllowed() && this.eatContextual(92)) {
|
|
17063
|
-
awaitAt = this.state.
|
|
17500
|
+
awaitAt = this.state.lastTokStartLoc;
|
|
17064
17501
|
}
|
|
17065
17502
|
|
|
17066
17503
|
this.scope.enter(SCOPE_OTHER);
|
|
17067
17504
|
this.expect(10);
|
|
17068
17505
|
|
|
17069
17506
|
if (this.match(13)) {
|
|
17070
|
-
if (awaitAt
|
|
17507
|
+
if (awaitAt !== null) {
|
|
17071
17508
|
this.unexpected(awaitAt);
|
|
17072
17509
|
}
|
|
17073
17510
|
|
|
@@ -17089,7 +17526,7 @@
|
|
|
17089
17526
|
return this.parseForIn(node, _init, awaitAt);
|
|
17090
17527
|
}
|
|
17091
17528
|
|
|
17092
|
-
if (awaitAt
|
|
17529
|
+
if (awaitAt !== null) {
|
|
17093
17530
|
this.unexpected(awaitAt);
|
|
17094
17531
|
}
|
|
17095
17532
|
|
|
@@ -17103,9 +17540,15 @@
|
|
|
17103
17540
|
|
|
17104
17541
|
if (isForOf) {
|
|
17105
17542
|
if (startsWithLet) {
|
|
17106
|
-
this.raise(
|
|
17107
|
-
|
|
17108
|
-
|
|
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
|
+
});
|
|
17109
17552
|
}
|
|
17110
17553
|
}
|
|
17111
17554
|
|
|
@@ -17118,7 +17561,7 @@
|
|
|
17118
17561
|
this.checkExpressionErrors(refExpressionErrors, true);
|
|
17119
17562
|
}
|
|
17120
17563
|
|
|
17121
|
-
if (awaitAt
|
|
17564
|
+
if (awaitAt !== null) {
|
|
17122
17565
|
this.unexpected(awaitAt);
|
|
17123
17566
|
}
|
|
17124
17567
|
|
|
@@ -17140,7 +17583,9 @@
|
|
|
17140
17583
|
|
|
17141
17584
|
parseReturnStatement(node) {
|
|
17142
17585
|
if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
|
|
17143
|
-
this.raise(
|
|
17586
|
+
this.raise(ErrorMessages.IllegalReturn, {
|
|
17587
|
+
at: this.state.startLoc
|
|
17588
|
+
});
|
|
17144
17589
|
}
|
|
17145
17590
|
|
|
17146
17591
|
this.next();
|
|
@@ -17176,7 +17621,9 @@
|
|
|
17176
17621
|
cur.test = this.parseExpression();
|
|
17177
17622
|
} else {
|
|
17178
17623
|
if (sawDefault) {
|
|
17179
|
-
this.raise(
|
|
17624
|
+
this.raise(ErrorMessages.MultipleDefaultsInSwitch, {
|
|
17625
|
+
at: this.state.lastTokStartLoc
|
|
17626
|
+
});
|
|
17180
17627
|
}
|
|
17181
17628
|
|
|
17182
17629
|
sawDefault = true;
|
|
@@ -17204,7 +17651,9 @@
|
|
|
17204
17651
|
this.next();
|
|
17205
17652
|
|
|
17206
17653
|
if (this.hasPrecedingLineBreak()) {
|
|
17207
|
-
this.raise(
|
|
17654
|
+
this.raise(ErrorMessages.NewlineAfterThrow, {
|
|
17655
|
+
at: this.state.lastTokEndLoc
|
|
17656
|
+
});
|
|
17208
17657
|
}
|
|
17209
17658
|
|
|
17210
17659
|
node.argument = this.parseExpression();
|
|
@@ -17246,7 +17695,9 @@
|
|
|
17246
17695
|
node.finalizer = this.eat(63) ? this.parseBlock() : null;
|
|
17247
17696
|
|
|
17248
17697
|
if (!node.handler && !node.finalizer) {
|
|
17249
|
-
this.raise(
|
|
17698
|
+
this.raise(ErrorMessages.NoCatchOrFinally, {
|
|
17699
|
+
node
|
|
17700
|
+
});
|
|
17250
17701
|
}
|
|
17251
17702
|
|
|
17252
17703
|
return this.finishNode(node, "TryStatement");
|
|
@@ -17270,7 +17721,9 @@
|
|
|
17270
17721
|
|
|
17271
17722
|
parseWithStatement(node) {
|
|
17272
17723
|
if (this.state.strict) {
|
|
17273
|
-
this.raise(
|
|
17724
|
+
this.raise(ErrorMessages.StrictWith, {
|
|
17725
|
+
at: this.state.startLoc
|
|
17726
|
+
});
|
|
17274
17727
|
}
|
|
17275
17728
|
|
|
17276
17729
|
this.next();
|
|
@@ -17287,7 +17740,9 @@
|
|
|
17287
17740
|
parseLabeledStatement(node, maybeName, expr, context) {
|
|
17288
17741
|
for (var label of this.state.labels) {
|
|
17289
17742
|
if (label.name === maybeName) {
|
|
17290
|
-
this.raise(
|
|
17743
|
+
this.raise(ErrorMessages.LabelRedeclaration, {
|
|
17744
|
+
node: expr
|
|
17745
|
+
}, maybeName);
|
|
17291
17746
|
}
|
|
17292
17747
|
}
|
|
17293
17748
|
|
|
@@ -17413,15 +17868,21 @@
|
|
|
17413
17868
|
this.next();
|
|
17414
17869
|
|
|
17415
17870
|
if (isForIn) {
|
|
17416
|
-
if (awaitAt
|
|
17871
|
+
if (awaitAt !== null) this.unexpected(awaitAt);
|
|
17417
17872
|
} else {
|
|
17418
|
-
node.await = awaitAt
|
|
17873
|
+
node.await = awaitAt !== null;
|
|
17419
17874
|
}
|
|
17420
17875
|
|
|
17421
17876
|
if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
|
|
17422
|
-
this.raise(
|
|
17423
|
-
|
|
17424
|
-
|
|
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");
|
|
17425
17886
|
}
|
|
17426
17887
|
|
|
17427
17888
|
node.left = init;
|
|
@@ -17447,10 +17908,14 @@
|
|
|
17447
17908
|
} else {
|
|
17448
17909
|
if (kind === "const" && !(this.match(54) || this.isContextual(97))) {
|
|
17449
17910
|
if (!isTypescript) {
|
|
17450
|
-
this.raise(
|
|
17911
|
+
this.raise(ErrorMessages.DeclarationMissingInitializer, {
|
|
17912
|
+
at: this.state.lastTokEndLoc
|
|
17913
|
+
}, "Const declarations");
|
|
17451
17914
|
}
|
|
17452
17915
|
} else if (decl.id.type !== "Identifier" && !(isFor && (this.match(54) || this.isContextual(97)))) {
|
|
17453
|
-
this.raise(
|
|
17916
|
+
this.raise(ErrorMessages.DeclarationMissingInitializer, {
|
|
17917
|
+
at: this.state.lastTokEndLoc
|
|
17918
|
+
}, "Complex binding patterns");
|
|
17454
17919
|
}
|
|
17455
17920
|
|
|
17456
17921
|
decl.init = null;
|
|
@@ -17477,7 +17942,9 @@
|
|
|
17477
17942
|
this.initFunction(node, isAsync);
|
|
17478
17943
|
|
|
17479
17944
|
if (this.match(51) && isHangingStatement) {
|
|
17480
|
-
this.raise(
|
|
17945
|
+
this.raise(ErrorMessages.GeneratorInSingleStatementContext, {
|
|
17946
|
+
at: this.state.startLoc
|
|
17947
|
+
});
|
|
17481
17948
|
}
|
|
17482
17949
|
|
|
17483
17950
|
node.generator = this.eat(51);
|
|
@@ -17523,7 +17990,7 @@
|
|
|
17523
17990
|
|
|
17524
17991
|
registerFunctionStatementId(node) {
|
|
17525
17992
|
if (!node.id) return;
|
|
17526
|
-
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);
|
|
17527
17994
|
}
|
|
17528
17995
|
|
|
17529
17996
|
parseClass(node, isStatement, optionalId) {
|
|
@@ -17563,7 +18030,9 @@
|
|
|
17563
18030
|
while (!this.match(8)) {
|
|
17564
18031
|
if (this.eat(13)) {
|
|
17565
18032
|
if (decorators.length > 0) {
|
|
17566
|
-
throw this.raise(
|
|
18033
|
+
throw this.raise(ErrorMessages.DecoratorSemicolon, {
|
|
18034
|
+
at: this.state.lastTokEndLoc
|
|
18035
|
+
});
|
|
17567
18036
|
}
|
|
17568
18037
|
|
|
17569
18038
|
continue;
|
|
@@ -17585,7 +18054,9 @@
|
|
|
17585
18054
|
this.parseClassMember(classBody, member, state);
|
|
17586
18055
|
|
|
17587
18056
|
if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
|
|
17588
|
-
this.raise(
|
|
18057
|
+
this.raise(ErrorMessages.DecoratorConstructor, {
|
|
18058
|
+
node: member
|
|
18059
|
+
});
|
|
17589
18060
|
}
|
|
17590
18061
|
}
|
|
17591
18062
|
});
|
|
@@ -17593,7 +18064,9 @@
|
|
|
17593
18064
|
this.next();
|
|
17594
18065
|
|
|
17595
18066
|
if (decorators.length) {
|
|
17596
|
-
throw this.raise(
|
|
18067
|
+
throw this.raise(ErrorMessages.TrailingDecorator, {
|
|
18068
|
+
at: this.state.startLoc
|
|
18069
|
+
});
|
|
17597
18070
|
}
|
|
17598
18071
|
|
|
17599
18072
|
this.classScope.exit();
|
|
@@ -17662,7 +18135,9 @@
|
|
|
17662
18135
|
}
|
|
17663
18136
|
|
|
17664
18137
|
if (this.isNonstaticConstructor(publicMethod)) {
|
|
17665
|
-
this.raise(
|
|
18138
|
+
this.raise(ErrorMessages.ConstructorIsGenerator, {
|
|
18139
|
+
node: publicMethod.key
|
|
18140
|
+
});
|
|
17666
18141
|
}
|
|
17667
18142
|
|
|
17668
18143
|
this.pushClassMethod(classBody, publicMethod, true, false, false, false);
|
|
@@ -17672,7 +18147,7 @@
|
|
|
17672
18147
|
var isContextual = tokenIsIdentifier(this.state.type) && !this.state.containsEsc;
|
|
17673
18148
|
var isPrivate = this.match(130);
|
|
17674
18149
|
var key = this.parseClassElementName(member);
|
|
17675
|
-
var
|
|
18150
|
+
var maybeQuestionTokenStartLoc = this.state.startLoc;
|
|
17676
18151
|
this.parsePostMemberNameModifiers(publicMember);
|
|
17677
18152
|
|
|
17678
18153
|
if (this.isClassMethod()) {
|
|
@@ -17690,11 +18165,15 @@
|
|
|
17690
18165
|
publicMethod.kind = "constructor";
|
|
17691
18166
|
|
|
17692
18167
|
if (state.hadConstructor && !this.hasPlugin("typescript")) {
|
|
17693
|
-
this.raise(
|
|
18168
|
+
this.raise(ErrorMessages.DuplicateConstructor, {
|
|
18169
|
+
node: key
|
|
18170
|
+
});
|
|
17694
18171
|
}
|
|
17695
18172
|
|
|
17696
18173
|
if (isConstructor && this.hasPlugin("typescript") && member.override) {
|
|
17697
|
-
this.raise(
|
|
18174
|
+
this.raise(ErrorMessages.OverrideOnConstructor, {
|
|
18175
|
+
node: key
|
|
18176
|
+
});
|
|
17698
18177
|
}
|
|
17699
18178
|
|
|
17700
18179
|
state.hadConstructor = true;
|
|
@@ -17713,7 +18192,7 @@
|
|
|
17713
18192
|
var isGenerator = this.eat(51);
|
|
17714
18193
|
|
|
17715
18194
|
if (publicMember.optional) {
|
|
17716
|
-
this.unexpected(
|
|
18195
|
+
this.unexpected(maybeQuestionTokenStartLoc);
|
|
17717
18196
|
}
|
|
17718
18197
|
|
|
17719
18198
|
method.kind = "method";
|
|
@@ -17727,7 +18206,9 @@
|
|
|
17727
18206
|
this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
|
|
17728
18207
|
} else {
|
|
17729
18208
|
if (this.isNonstaticConstructor(publicMethod)) {
|
|
17730
|
-
this.raise(
|
|
18209
|
+
this.raise(ErrorMessages.ConstructorIsAsync, {
|
|
18210
|
+
node: publicMethod.key
|
|
18211
|
+
});
|
|
17731
18212
|
}
|
|
17732
18213
|
|
|
17733
18214
|
this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
|
|
@@ -17744,7 +18225,9 @@
|
|
|
17744
18225
|
this.pushClassPrivateMethod(classBody, privateMethod, false, false);
|
|
17745
18226
|
} else {
|
|
17746
18227
|
if (this.isNonstaticConstructor(publicMethod)) {
|
|
17747
|
-
this.raise(
|
|
18228
|
+
this.raise(ErrorMessages.ConstructorIsAccessor, {
|
|
18229
|
+
node: publicMethod.key
|
|
18230
|
+
});
|
|
17748
18231
|
}
|
|
17749
18232
|
|
|
17750
18233
|
this.pushClassMethod(classBody, publicMethod, false, false, false, false);
|
|
@@ -17765,17 +18248,20 @@
|
|
|
17765
18248
|
parseClassElementName(member) {
|
|
17766
18249
|
var {
|
|
17767
18250
|
type,
|
|
17768
|
-
value
|
|
17769
|
-
start
|
|
18251
|
+
value
|
|
17770
18252
|
} = this.state;
|
|
17771
18253
|
|
|
17772
18254
|
if ((type === 124 || type === 125) && member.static && value === "prototype") {
|
|
17773
|
-
this.raise(
|
|
18255
|
+
this.raise(ErrorMessages.StaticPrototype, {
|
|
18256
|
+
at: this.state.startLoc
|
|
18257
|
+
});
|
|
17774
18258
|
}
|
|
17775
18259
|
|
|
17776
18260
|
if (type === 130) {
|
|
17777
18261
|
if (value === "constructor") {
|
|
17778
|
-
this.raise(
|
|
18262
|
+
this.raise(ErrorMessages.ConstructorClassPrivateField, {
|
|
18263
|
+
at: this.state.startLoc
|
|
18264
|
+
});
|
|
17779
18265
|
}
|
|
17780
18266
|
|
|
17781
18267
|
var key = this.parsePrivateName();
|
|
@@ -17801,13 +18287,17 @@
|
|
|
17801
18287
|
classBody.body.push(this.finishNode(member, "StaticBlock"));
|
|
17802
18288
|
|
|
17803
18289
|
if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
|
|
17804
|
-
this.raise(
|
|
18290
|
+
this.raise(ErrorMessages.DecoratorStaticBlock, {
|
|
18291
|
+
node: member
|
|
18292
|
+
});
|
|
17805
18293
|
}
|
|
17806
18294
|
}
|
|
17807
18295
|
|
|
17808
18296
|
pushClassProperty(classBody, prop) {
|
|
17809
18297
|
if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) {
|
|
17810
|
-
this.raise(
|
|
18298
|
+
this.raise(ErrorMessages.ConstructorClassField, {
|
|
18299
|
+
node: prop.key
|
|
18300
|
+
});
|
|
17811
18301
|
}
|
|
17812
18302
|
|
|
17813
18303
|
classBody.body.push(this.parseClassProperty(prop));
|
|
@@ -17816,7 +18306,7 @@
|
|
|
17816
18306
|
pushClassPrivateProperty(classBody, prop) {
|
|
17817
18307
|
var node = this.parseClassPrivateProperty(prop);
|
|
17818
18308
|
classBody.body.push(node);
|
|
17819
|
-
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);
|
|
17820
18310
|
}
|
|
17821
18311
|
|
|
17822
18312
|
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
|
@@ -17831,7 +18321,7 @@
|
|
|
17831
18321
|
}
|
|
17832
18322
|
|
|
17833
18323
|
declareClassPrivateMethodInScope(node, kind) {
|
|
17834
|
-
this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.start);
|
|
18324
|
+
this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
|
|
17835
18325
|
}
|
|
17836
18326
|
|
|
17837
18327
|
parsePostMemberNameModifiers(methodOrProp) {}
|
|
@@ -17871,7 +18361,9 @@
|
|
|
17871
18361
|
if (optionalId || !isStatement) {
|
|
17872
18362
|
node.id = null;
|
|
17873
18363
|
} else {
|
|
17874
|
-
this.
|
|
18364
|
+
throw this.raise(ErrorMessages.MissingClassName, {
|
|
18365
|
+
at: this.state.startLoc
|
|
18366
|
+
});
|
|
17875
18367
|
}
|
|
17876
18368
|
}
|
|
17877
18369
|
}
|
|
@@ -18004,22 +18496,32 @@
|
|
|
18004
18496
|
}
|
|
18005
18497
|
|
|
18006
18498
|
return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync);
|
|
18007
|
-
}
|
|
18499
|
+
}
|
|
18500
|
+
|
|
18501
|
+
if (this.match(76)) {
|
|
18008
18502
|
return this.parseClass(expr, true, true);
|
|
18009
|
-
}
|
|
18503
|
+
}
|
|
18504
|
+
|
|
18505
|
+
if (this.match(26)) {
|
|
18010
18506
|
if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
|
18011
|
-
this.raise(
|
|
18507
|
+
this.raise(ErrorMessages.DecoratorBeforeExport, {
|
|
18508
|
+
at: this.state.startLoc
|
|
18509
|
+
});
|
|
18012
18510
|
}
|
|
18013
18511
|
|
|
18014
18512
|
this.parseDecorators(false);
|
|
18015
18513
|
return this.parseClass(expr, true, true);
|
|
18016
|
-
} else if (this.match(71) || this.match(70) || this.isLet()) {
|
|
18017
|
-
throw this.raise(this.state.start, ErrorMessages.UnsupportedDefaultExport);
|
|
18018
|
-
} else {
|
|
18019
|
-
var res = this.parseMaybeAssignAllowIn();
|
|
18020
|
-
this.semicolon();
|
|
18021
|
-
return res;
|
|
18022
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;
|
|
18023
18525
|
}
|
|
18024
18526
|
|
|
18025
18527
|
parseExportDeclaration(node) {
|
|
@@ -18091,10 +18593,12 @@
|
|
|
18091
18593
|
|
|
18092
18594
|
if (this.hasPlugin("decorators")) {
|
|
18093
18595
|
if (this.getPluginOption("decorators", "decoratorsBeforeExport")) {
|
|
18094
|
-
this.
|
|
18095
|
-
|
|
18096
|
-
|
|
18596
|
+
throw this.raise(ErrorMessages.DecoratorBeforeExport, {
|
|
18597
|
+
at: this.state.startLoc
|
|
18598
|
+
});
|
|
18097
18599
|
}
|
|
18600
|
+
|
|
18601
|
+
return true;
|
|
18098
18602
|
}
|
|
18099
18603
|
}
|
|
18100
18604
|
|
|
@@ -18112,7 +18616,9 @@
|
|
|
18112
18616
|
var declaration = node.declaration;
|
|
18113
18617
|
|
|
18114
18618
|
if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
|
|
18115
|
-
this.raise(
|
|
18619
|
+
this.raise(ErrorMessages.ExportDefaultFromAsIdentifier, {
|
|
18620
|
+
node: declaration
|
|
18621
|
+
});
|
|
18116
18622
|
}
|
|
18117
18623
|
}
|
|
18118
18624
|
} else if (node.specifiers && node.specifiers.length) {
|
|
@@ -18129,9 +18635,11 @@
|
|
|
18129
18635
|
} = specifier;
|
|
18130
18636
|
|
|
18131
18637
|
if (local.type !== "Identifier") {
|
|
18132
|
-
this.raise(
|
|
18638
|
+
this.raise(ErrorMessages.ExportBindingIsString, {
|
|
18639
|
+
node: specifier
|
|
18640
|
+
}, local.value, exportedName);
|
|
18133
18641
|
} else {
|
|
18134
|
-
this.checkReservedWord(local.name, local.start, true, false);
|
|
18642
|
+
this.checkReservedWord(local.name, local.loc.start, true, false);
|
|
18135
18643
|
this.scope.checkLocalExport(local);
|
|
18136
18644
|
}
|
|
18137
18645
|
}
|
|
@@ -18152,7 +18660,9 @@
|
|
|
18152
18660
|
var currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
|
|
18153
18661
|
|
|
18154
18662
|
if (currentContextDecorators.length) {
|
|
18155
|
-
throw this.raise(
|
|
18663
|
+
throw this.raise(ErrorMessages.UnsupportedDecoratorExport, {
|
|
18664
|
+
node
|
|
18665
|
+
});
|
|
18156
18666
|
}
|
|
18157
18667
|
}
|
|
18158
18668
|
|
|
@@ -18180,7 +18690,9 @@
|
|
|
18180
18690
|
|
|
18181
18691
|
checkDuplicateExports(node, name) {
|
|
18182
18692
|
if (this.exportedIdentifiers.has(name)) {
|
|
18183
|
-
this.raise(
|
|
18693
|
+
this.raise(name === "default" ? ErrorMessages.DuplicateDefaultExport : ErrorMessages.DuplicateExport, {
|
|
18694
|
+
node
|
|
18695
|
+
}, name);
|
|
18184
18696
|
}
|
|
18185
18697
|
|
|
18186
18698
|
this.exportedIdentifiers.add(name);
|
|
@@ -18227,7 +18739,9 @@
|
|
|
18227
18739
|
var surrogate = result.value.match(loneSurrogate);
|
|
18228
18740
|
|
|
18229
18741
|
if (surrogate) {
|
|
18230
|
-
this.raise(
|
|
18742
|
+
this.raise(ErrorMessages.ModuleExportNameHasLoneSurrogate, {
|
|
18743
|
+
node: result
|
|
18744
|
+
}, surrogate[0].charCodeAt(0).toString(16));
|
|
18231
18745
|
}
|
|
18232
18746
|
|
|
18233
18747
|
return result;
|
|
@@ -18292,7 +18806,9 @@
|
|
|
18292
18806
|
var keyName = this.state.value;
|
|
18293
18807
|
|
|
18294
18808
|
if (attrNames.has(keyName)) {
|
|
18295
|
-
this.raise(
|
|
18809
|
+
this.raise(ErrorMessages.ModuleAttributesWithDuplicateKeys, {
|
|
18810
|
+
at: this.state.startLoc
|
|
18811
|
+
}, keyName);
|
|
18296
18812
|
}
|
|
18297
18813
|
|
|
18298
18814
|
attrNames.add(keyName);
|
|
@@ -18306,7 +18822,9 @@
|
|
|
18306
18822
|
this.expect(14);
|
|
18307
18823
|
|
|
18308
18824
|
if (!this.match(125)) {
|
|
18309
|
-
throw this.
|
|
18825
|
+
throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, {
|
|
18826
|
+
at: this.state.startLoc
|
|
18827
|
+
});
|
|
18310
18828
|
}
|
|
18311
18829
|
|
|
18312
18830
|
node.value = this.parseStringLiteral(this.state.value);
|
|
@@ -18334,18 +18852,24 @@
|
|
|
18334
18852
|
node.key = this.parseIdentifier(true);
|
|
18335
18853
|
|
|
18336
18854
|
if (node.key.name !== "type") {
|
|
18337
|
-
this.raise(
|
|
18855
|
+
this.raise(ErrorMessages.ModuleAttributeDifferentFromType, {
|
|
18856
|
+
node: node.key
|
|
18857
|
+
}, node.key.name);
|
|
18338
18858
|
}
|
|
18339
18859
|
|
|
18340
18860
|
if (attributes.has(node.key.name)) {
|
|
18341
|
-
this.raise(
|
|
18861
|
+
this.raise(ErrorMessages.ModuleAttributesWithDuplicateKeys, {
|
|
18862
|
+
node: node.key
|
|
18863
|
+
}, node.key.name);
|
|
18342
18864
|
}
|
|
18343
18865
|
|
|
18344
18866
|
attributes.add(node.key.name);
|
|
18345
18867
|
this.expect(14);
|
|
18346
18868
|
|
|
18347
18869
|
if (!this.match(125)) {
|
|
18348
|
-
throw this.
|
|
18870
|
+
throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, {
|
|
18871
|
+
at: this.state.startLoc
|
|
18872
|
+
});
|
|
18349
18873
|
}
|
|
18350
18874
|
|
|
18351
18875
|
node.value = this.parseStringLiteral(this.state.value);
|
|
@@ -18401,7 +18925,9 @@
|
|
|
18401
18925
|
first = false;
|
|
18402
18926
|
} else {
|
|
18403
18927
|
if (this.eat(14)) {
|
|
18404
|
-
throw this.raise(
|
|
18928
|
+
throw this.raise(ErrorMessages.DestructureNamedImport, {
|
|
18929
|
+
at: this.state.startLoc
|
|
18930
|
+
});
|
|
18405
18931
|
}
|
|
18406
18932
|
|
|
18407
18933
|
this.expect(12);
|
|
@@ -18426,10 +18952,12 @@
|
|
|
18426
18952
|
} = specifier;
|
|
18427
18953
|
|
|
18428
18954
|
if (importedIsString) {
|
|
18429
|
-
throw this.raise(
|
|
18955
|
+
throw this.raise(ErrorMessages.ImportBindingIsString, {
|
|
18956
|
+
node: specifier
|
|
18957
|
+
}, imported.value);
|
|
18430
18958
|
}
|
|
18431
18959
|
|
|
18432
|
-
this.checkReservedWord(imported.name, specifier.start, true, true);
|
|
18960
|
+
this.checkReservedWord(imported.name, specifier.loc.start, true, true);
|
|
18433
18961
|
|
|
18434
18962
|
if (!specifier.local) {
|
|
18435
18963
|
specifier.local = cloneIdentifier(imported);
|