@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/dist/index.esm.js CHANGED
@@ -3057,62 +3057,15 @@ var lib = {};
3057
3057
  Object.defineProperty(lib, '__esModule', {
3058
3058
  value: true
3059
3059
  });
3060
- var lineBreak = /\r\n?|[\n\u2028\u2029]/;
3061
- var lineBreakG = new RegExp(lineBreak.source, "g");
3062
-
3063
- function isNewLine(code) {
3064
- switch (code) {
3065
- case 10:
3066
- case 13:
3067
- case 8232:
3068
- case 8233:
3069
- return true;
3070
-
3071
- default:
3072
- return false;
3073
- }
3074
- }
3075
-
3076
- var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
3077
- var skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
3078
- var skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
3079
-
3080
- function isWhitespace(code) {
3081
- switch (code) {
3082
- case 0x0009:
3083
- case 0x000b:
3084
- case 0x000c:
3085
- case 32:
3086
- case 160:
3087
- case 5760:
3088
- case 0x2000:
3089
- case 0x2001:
3090
- case 0x2002:
3091
- case 0x2003:
3092
- case 0x2004:
3093
- case 0x2005:
3094
- case 0x2006:
3095
- case 0x2007:
3096
- case 0x2008:
3097
- case 0x2009:
3098
- case 0x200a:
3099
- case 0x202f:
3100
- case 0x205f:
3101
- case 0x3000:
3102
- case 0xfeff:
3103
- return true;
3104
-
3105
- default:
3106
- return false;
3107
- }
3108
- }
3109
3060
 
3110
3061
  class Position {
3111
- constructor(line, col) {
3062
+ constructor(line, col, index) {
3112
3063
  this.line = void 0;
3113
3064
  this.column = void 0;
3065
+ this.index = void 0;
3114
3066
  this.line = line;
3115
3067
  this.column = col;
3068
+ indexes.set(this, index);
3116
3069
  }
3117
3070
 
3118
3071
  }
@@ -3129,26 +3082,14 @@ class SourceLocation {
3129
3082
 
3130
3083
  }
3131
3084
 
3132
- function getLineInfo(input, offset) {
3133
- var line = 1;
3134
- var lineStart = 0;
3135
- var match;
3136
- lineBreakG.lastIndex = 0;
3137
-
3138
- while ((match = lineBreakG.exec(input)) && match.index < offset) {
3139
- line++;
3140
- lineStart = lineBreakG.lastIndex;
3141
- }
3142
-
3143
- return new Position(line, offset - lineStart);
3144
- }
3085
+ var indexes = new WeakMap();
3145
3086
 
3146
3087
  function createPositionWithColumnOffset(position, columnOffset) {
3147
3088
  var {
3148
3089
  line,
3149
3090
  column
3150
3091
  } = position;
3151
- return new Position(line, column + columnOffset);
3092
+ return new Position(line, column + columnOffset, indexes.get(position) + columnOffset);
3152
3093
  }
3153
3094
 
3154
3095
  class BaseParser {
@@ -3570,13 +3511,7 @@ function makeErrorTemplates(messages, code, syntaxPlugin) {
3570
3511
  }
3571
3512
 
3572
3513
  class ParserError extends CommentsParser {
3573
- getLocationForPosition(pos) {
3574
- var loc;
3575
- 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);
3576
- return loc;
3577
- }
3578
-
3579
- raise(pos, _ref) {
3514
+ raise(_ref, origin) {
3580
3515
  var {
3581
3516
  code,
3582
3517
  reasonCode,
@@ -3587,13 +3522,13 @@ class ParserError extends CommentsParser {
3587
3522
  params[_key - 2] = arguments[_key];
3588
3523
  }
3589
3524
 
3590
- return this.raiseWithData(pos, {
3525
+ return this.raiseWithData(origin.node ? origin.node.loc.start : origin.at, {
3591
3526
  code,
3592
3527
  reasonCode
3593
3528
  }, template, ...params);
3594
3529
  }
3595
3530
 
3596
- raiseOverwrite(pos, _ref2) {
3531
+ raiseOverwrite(loc, _ref2) {
3597
3532
  var {
3598
3533
  code,
3599
3534
  template
@@ -3603,7 +3538,7 @@ class ParserError extends CommentsParser {
3603
3538
  params[_key2 - 2] = arguments[_key2];
3604
3539
  }
3605
3540
 
3606
- var loc = this.getLocationForPosition(pos);
3541
+ var pos = indexes.get(loc);
3607
3542
  var message = template.replace(/%(\d+)/g, (_, i) => params[i]) + " (".concat(loc.line, ":").concat(loc.column, ")");
3608
3543
 
3609
3544
  if (this.options.errorRecovery) {
@@ -3629,12 +3564,12 @@ class ParserError extends CommentsParser {
3629
3564
  }, message);
3630
3565
  }
3631
3566
 
3632
- raiseWithData(pos, data, errorTemplate) {
3567
+ raiseWithData(loc, data, errorTemplate) {
3633
3568
  for (var _len3 = arguments.length, params = new Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) {
3634
3569
  params[_key3 - 3] = arguments[_key3];
3635
3570
  }
3636
3571
 
3637
- var loc = this.getLocationForPosition(pos);
3572
+ var pos = indexes.get(loc);
3638
3573
  var message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + " (".concat(loc.line, ":").concat(loc.column, ")");
3639
3574
  return this._raise(Object.assign({
3640
3575
  loc,
@@ -3723,9 +3658,9 @@ var estree = superClass => class extends superClass {
3723
3658
  var expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start);
3724
3659
  expression.value = directiveLiteral.extra.expressionValue;
3725
3660
  expression.raw = directiveLiteral.extra.raw;
3726
- stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.end, directiveLiteral.loc.end);
3661
+ stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.loc.end);
3727
3662
  stmt.directive = directiveLiteral.extra.raw.slice(1, -1);
3728
- return this.finishNodeAt(stmt, "ExpressionStatement", directive.end, directive.loc.end);
3663
+ return this.finishNodeAt(stmt, "ExpressionStatement", directive.loc.end);
3729
3664
  }
3730
3665
 
3731
3666
  initFunction(node, isAsync) {
@@ -3907,9 +3842,13 @@ var estree = superClass => class extends superClass {
3907
3842
 
3908
3843
  toAssignableObjectExpressionProp(prop) {
3909
3844
  if (prop.kind === "get" || prop.kind === "set") {
3910
- this.raise(prop.key.start, ErrorMessages.PatternHasAccessor);
3845
+ this.raise(ErrorMessages.PatternHasAccessor, {
3846
+ node: prop.key
3847
+ });
3911
3848
  } else if (prop.method) {
3912
- this.raise(prop.key.start, ErrorMessages.PatternHasMethod);
3849
+ this.raise(ErrorMessages.PatternHasMethod, {
3850
+ node: prop.key
3851
+ });
3913
3852
  } else {
3914
3853
  for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
3915
3854
  args[_key5 - 1] = arguments[_key5];
@@ -4580,10 +4519,6 @@ function getExportedToken(token) {
4580
4519
  return tokenTypes[token];
4581
4520
  }
4582
4521
 
4583
- function isTokenType(obj) {
4584
- return typeof obj === "number";
4585
- }
4586
-
4587
4522
  {
4588
4523
  tokenTypes[8].updateContext = context => {
4589
4524
  context.pop();
@@ -4752,7 +4687,6 @@ class ScopeHandler {
4752
4687
  constructor(raise, inModule) {
4753
4688
  this.scopeStack = [];
4754
4689
  this.undefinedExports = new Map();
4755
- this.undefinedPrivateNames = new Map();
4756
4690
  this.raise = raise;
4757
4691
  this.inModule = inModule;
4758
4692
  }
@@ -4818,11 +4752,11 @@ class ScopeHandler {
4818
4752
  return !!(scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_PROGRAM);
4819
4753
  }
4820
4754
 
4821
- declareName(name, bindingType, pos) {
4755
+ declareName(name, bindingType, loc) {
4822
4756
  var scope = this.currentScope();
4823
4757
 
4824
4758
  if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
4825
- this.checkRedeclarationInScope(scope, name, bindingType, pos);
4759
+ this.checkRedeclarationInScope(scope, name, bindingType, loc);
4826
4760
 
4827
4761
  if (bindingType & BIND_SCOPE_FUNCTION) {
4828
4762
  scope.functions.add(name);
@@ -4836,7 +4770,7 @@ class ScopeHandler {
4836
4770
  } else if (bindingType & BIND_SCOPE_VAR) {
4837
4771
  for (var i = this.scopeStack.length - 1; i >= 0; --i) {
4838
4772
  scope = this.scopeStack[i];
4839
- this.checkRedeclarationInScope(scope, name, bindingType, pos);
4773
+ this.checkRedeclarationInScope(scope, name, bindingType, loc);
4840
4774
  scope.var.add(name);
4841
4775
  this.maybeExportDefined(scope, name);
4842
4776
  if (scope.flags & SCOPE_VAR) break;
@@ -4854,9 +4788,11 @@ class ScopeHandler {
4854
4788
  }
4855
4789
  }
4856
4790
 
4857
- checkRedeclarationInScope(scope, name, bindingType, pos) {
4791
+ checkRedeclarationInScope(scope, name, bindingType, loc) {
4858
4792
  if (this.isRedeclaredInScope(scope, name, bindingType)) {
4859
- this.raise(pos, ErrorMessages.VarRedeclaration, name);
4793
+ this.raise(ErrorMessages.VarRedeclaration, {
4794
+ at: loc
4795
+ }, name);
4860
4796
  }
4861
4797
  }
4862
4798
 
@@ -4881,7 +4817,7 @@ class ScopeHandler {
4881
4817
  var topLevelScope = this.scopeStack[0];
4882
4818
 
4883
4819
  if (!topLevelScope.lexical.has(name) && !topLevelScope.var.has(name) && !topLevelScope.functions.has(name)) {
4884
- this.undefinedExports.set(name, id.start);
4820
+ this.undefinedExports.set(name, id.loc.start);
4885
4821
  }
4886
4822
  }
4887
4823
 
@@ -4928,11 +4864,11 @@ class FlowScopeHandler extends ScopeHandler {
4928
4864
  return new FlowScope(flags);
4929
4865
  }
4930
4866
 
4931
- declareName(name, bindingType, pos) {
4867
+ declareName(name, bindingType, loc) {
4932
4868
  var scope = this.currentScope();
4933
4869
 
4934
4870
  if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {
4935
- this.checkRedeclarationInScope(scope, name, bindingType, pos);
4871
+ this.checkRedeclarationInScope(scope, name, bindingType, loc);
4936
4872
  this.maybeExportDefined(scope, name);
4937
4873
  scope.declareFunctions.add(name);
4938
4874
  return;
@@ -4959,6 +4895,56 @@ class FlowScopeHandler extends ScopeHandler {
4959
4895
 
4960
4896
  }
4961
4897
 
4898
+ var lineBreak = /\r\n?|[\n\u2028\u2029]/;
4899
+ var lineBreakG = new RegExp(lineBreak.source, "g");
4900
+
4901
+ function isNewLine(code) {
4902
+ switch (code) {
4903
+ case 10:
4904
+ case 13:
4905
+ case 8232:
4906
+ case 8233:
4907
+ return true;
4908
+
4909
+ default:
4910
+ return false;
4911
+ }
4912
+ }
4913
+
4914
+ var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
4915
+ var skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
4916
+ var skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
4917
+
4918
+ function isWhitespace(code) {
4919
+ switch (code) {
4920
+ case 0x0009:
4921
+ case 0x000b:
4922
+ case 0x000c:
4923
+ case 32:
4924
+ case 160:
4925
+ case 5760:
4926
+ case 0x2000:
4927
+ case 0x2001:
4928
+ case 0x2002:
4929
+ case 0x2003:
4930
+ case 0x2004:
4931
+ case 0x2005:
4932
+ case 0x2006:
4933
+ case 0x2007:
4934
+ case 0x2008:
4935
+ case 0x2009:
4936
+ case 0x200a:
4937
+ case 0x202f:
4938
+ case 0x205f:
4939
+ case 0x3000:
4940
+ case 0xfeff:
4941
+ return true;
4942
+
4943
+ default:
4944
+ return false;
4945
+ }
4946
+ }
4947
+
4962
4948
  class State {
4963
4949
  constructor() {
4964
4950
  this.strict = void 0;
@@ -4994,7 +4980,6 @@ class State {
4994
4980
  this.lastTokEndLoc = null;
4995
4981
  this.lastTokStartLoc = null;
4996
4982
  this.lastTokStart = 0;
4997
- this.lastTokEnd = 0;
4998
4983
  this.context = [types.brace];
4999
4984
  this.canStartJSXElement = true;
5000
4985
  this.containsEsc = false;
@@ -5012,11 +4997,11 @@ class State {
5012
4997
  this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
5013
4998
  this.curLine = startLine;
5014
4999
  this.lineStart = -startColumn;
5015
- this.startLoc = this.endLoc = new Position(startLine, startColumn);
5000
+ this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
5016
5001
  }
5017
5002
 
5018
5003
  curPosition() {
5019
- return new Position(this.curLine, this.pos - this.lineStart);
5004
+ return new Position(this.curLine, this.pos - this.lineStart, this.pos);
5020
5005
  }
5021
5006
 
5022
5007
  clone(skipArrays) {
@@ -5090,7 +5075,6 @@ class Tokenizer extends ParserError {
5090
5075
  this.pushToken(new Token(this.state));
5091
5076
  }
5092
5077
 
5093
- this.state.lastTokEnd = this.state.end;
5094
5078
  this.state.lastTokStart = this.state.start;
5095
5079
  this.state.lastTokEndLoc = this.state.endLoc;
5096
5080
  this.state.lastTokStartLoc = this.state.startLoc;
@@ -5117,9 +5101,13 @@ class Tokenizer extends ParserError {
5117
5101
  type: state.type,
5118
5102
  start: state.start,
5119
5103
  end: state.end,
5120
- lastTokEnd: state.end,
5121
5104
  context: [this.curContext()],
5122
- inType: state.inType
5105
+ inType: state.inType,
5106
+ startLoc: state.startLoc,
5107
+ lastTokEndLoc: state.lastTokEndLoc,
5108
+ curLine: state.curLine,
5109
+ lineStart: state.lineStart,
5110
+ curPosition: state.curPosition
5123
5111
  };
5124
5112
  }
5125
5113
 
@@ -5165,7 +5153,15 @@ class Tokenizer extends ParserError {
5165
5153
  this.state.strict = strict;
5166
5154
 
5167
5155
  if (strict) {
5168
- this.state.strictErrors.forEach((message, pos) => this.raise(pos, message));
5156
+ this.state.strictErrors.forEach(_ref5 => {
5157
+ var {
5158
+ message,
5159
+ loc
5160
+ } = _ref5;
5161
+ return this.raise(message, {
5162
+ at: loc
5163
+ });
5164
+ });
5169
5165
  this.state.strictErrors.clear();
5170
5166
  }
5171
5167
  }
@@ -5192,7 +5188,13 @@ class Tokenizer extends ParserError {
5192
5188
  if (!this.isLookahead) startLoc = this.state.curPosition();
5193
5189
  var start = this.state.pos;
5194
5190
  var end = this.input.indexOf("*/", start + 2);
5195
- if (end === -1) throw this.raise(start, ErrorMessages.UnterminatedComment);
5191
+
5192
+ if (end === -1) {
5193
+ throw this.raise(ErrorMessages.UnterminatedComment, {
5194
+ at: this.state.curPosition()
5195
+ });
5196
+ }
5197
+
5196
5198
  this.state.pos = end + 2;
5197
5199
  lineBreakG.lastIndex = start + 2;
5198
5200
 
@@ -5350,12 +5352,12 @@ class Tokenizer extends ParserError {
5350
5352
 
5351
5353
  finishToken(type, val) {
5352
5354
  this.state.end = this.state.pos;
5355
+ this.state.endLoc = this.state.curPosition();
5353
5356
  var prevType = this.state.type;
5354
5357
  this.state.type = type;
5355
5358
  this.state.value = val;
5356
5359
 
5357
5360
  if (!this.isLookahead) {
5358
- this.state.endLoc = this.state.curPosition();
5359
5361
  this.updateContext(prevType);
5360
5362
  }
5361
5363
  }
@@ -5374,14 +5376,18 @@ class Tokenizer extends ParserError {
5374
5376
  var next = this.codePointAtPos(nextPos);
5375
5377
 
5376
5378
  if (next >= 48 && next <= 57) {
5377
- throw this.raise(this.state.pos, ErrorMessages.UnexpectedDigitAfterHash);
5379
+ throw this.raise(ErrorMessages.UnexpectedDigitAfterHash, {
5380
+ at: this.state.curPosition()
5381
+ });
5378
5382
  }
5379
5383
 
5380
5384
  if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
5381
5385
  this.expectPlugin("recordAndTuple");
5382
5386
 
5383
5387
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") {
5384
- throw this.raise(this.state.pos, next === 123 ? ErrorMessages.RecordExpressionHashIncorrectStartSyntaxType : ErrorMessages.TupleExpressionHashIncorrectStartSyntaxType);
5388
+ throw this.raise(next === 123 ? ErrorMessages.RecordExpressionHashIncorrectStartSyntaxType : ErrorMessages.TupleExpressionHashIncorrectStartSyntaxType, {
5389
+ at: this.state.curPosition()
5390
+ });
5385
5391
  }
5386
5392
 
5387
5393
  this.state.pos += 2;
@@ -5485,7 +5491,9 @@ class Tokenizer extends ParserError {
5485
5491
 
5486
5492
  if (this.hasPlugin("recordAndTuple") && next === 125) {
5487
5493
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
5488
- throw this.raise(this.state.pos, ErrorMessages.RecordExpressionBarIncorrectEndSyntaxType);
5494
+ throw this.raise(ErrorMessages.RecordExpressionBarIncorrectEndSyntaxType, {
5495
+ at: this.state.curPosition()
5496
+ });
5489
5497
  }
5490
5498
 
5491
5499
  this.state.pos += 2;
@@ -5495,7 +5503,9 @@ class Tokenizer extends ParserError {
5495
5503
 
5496
5504
  if (this.hasPlugin("recordAndTuple") && next === 93) {
5497
5505
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
5498
- throw this.raise(this.state.pos, ErrorMessages.TupleExpressionBarIncorrectEndSyntaxType);
5506
+ throw this.raise(ErrorMessages.TupleExpressionBarIncorrectEndSyntaxType, {
5507
+ at: this.state.curPosition()
5508
+ });
5499
5509
  }
5500
5510
 
5501
5511
  this.state.pos += 2;
@@ -5652,7 +5662,9 @@ class Tokenizer extends ParserError {
5652
5662
  case 91:
5653
5663
  if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
5654
5664
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
5655
- throw this.raise(this.state.pos, ErrorMessages.TupleExpressionBarIncorrectStartSyntaxType);
5665
+ throw this.raise(ErrorMessages.TupleExpressionBarIncorrectStartSyntaxType, {
5666
+ at: this.state.curPosition()
5667
+ });
5656
5668
  }
5657
5669
 
5658
5670
  this.state.pos += 2;
@@ -5672,7 +5684,9 @@ class Tokenizer extends ParserError {
5672
5684
  case 123:
5673
5685
  if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
5674
5686
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
5675
- throw this.raise(this.state.pos, ErrorMessages.RecordExpressionBarIncorrectStartSyntaxType);
5687
+ throw this.raise(ErrorMessages.RecordExpressionBarIncorrectStartSyntaxType, {
5688
+ at: this.state.curPosition()
5689
+ });
5676
5690
  }
5677
5691
 
5678
5692
  this.state.pos += 2;
@@ -5805,7 +5819,9 @@ class Tokenizer extends ParserError {
5805
5819
 
5806
5820
  }
5807
5821
 
5808
- throw this.raise(this.state.pos, ErrorMessages.InvalidOrUnexpectedToken, String.fromCodePoint(code));
5822
+ throw this.raise(ErrorMessages.InvalidOrUnexpectedToken, {
5823
+ at: this.state.curPosition()
5824
+ }, String.fromCodePoint(code));
5809
5825
  }
5810
5826
 
5811
5827
  finishOp(type, size) {
@@ -5815,6 +5831,7 @@ class Tokenizer extends ParserError {
5815
5831
  }
5816
5832
 
5817
5833
  readRegexp() {
5834
+ var startLoc = this.state.startLoc;
5818
5835
  var start = this.state.start + 1;
5819
5836
  var escaped, inClass;
5820
5837
  var {
@@ -5823,13 +5840,17 @@ class Tokenizer extends ParserError {
5823
5840
 
5824
5841
  for (;; ++pos) {
5825
5842
  if (pos >= this.length) {
5826
- throw this.raise(start, ErrorMessages.UnterminatedRegExp);
5843
+ throw this.raise(ErrorMessages.UnterminatedRegExp, {
5844
+ at: createPositionWithColumnOffset(startLoc, 1)
5845
+ });
5827
5846
  }
5828
5847
 
5829
5848
  var ch = this.input.charCodeAt(pos);
5830
5849
 
5831
5850
  if (isNewLine(ch)) {
5832
- throw this.raise(start, ErrorMessages.UnterminatedRegExp);
5851
+ throw this.raise(ErrorMessages.UnterminatedRegExp, {
5852
+ at: createPositionWithColumnOffset(startLoc, 1)
5853
+ });
5833
5854
  }
5834
5855
 
5835
5856
  if (escaped) {
@@ -5857,10 +5878,14 @@ class Tokenizer extends ParserError {
5857
5878
 
5858
5879
  if (VALID_REGEX_FLAGS.has(cp)) {
5859
5880
  if (mods.includes(char)) {
5860
- this.raise(pos + 1, ErrorMessages.DuplicateRegExpFlags);
5881
+ this.raise(ErrorMessages.DuplicateRegExpFlags, {
5882
+ at: createPositionWithColumnOffset(startLoc, pos + 2 - start)
5883
+ });
5861
5884
  }
5862
5885
  } else if (isIdentifierChar(cp) || cp === 92) {
5863
- this.raise(pos + 1, ErrorMessages.MalformedRegExpFlags);
5886
+ this.raise(ErrorMessages.MalformedRegExpFlags, {
5887
+ at: createPositionWithColumnOffset(startLoc, pos + 2 - start)
5888
+ });
5864
5889
  } else {
5865
5890
  break;
5866
5891
  }
@@ -5893,13 +5918,19 @@ class Tokenizer extends ParserError {
5893
5918
  var next = this.input.charCodeAt(this.state.pos + 1);
5894
5919
 
5895
5920
  if (allowedSiblings.indexOf(next) === -1) {
5896
- this.raise(this.state.pos, ErrorMessages.UnexpectedNumericSeparator);
5921
+ this.raise(ErrorMessages.UnexpectedNumericSeparator, {
5922
+ at: this.state.curPosition()
5923
+ });
5897
5924
  } else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
5898
- this.raise(this.state.pos, ErrorMessages.UnexpectedNumericSeparator);
5925
+ this.raise(ErrorMessages.UnexpectedNumericSeparator, {
5926
+ at: this.state.curPosition()
5927
+ });
5899
5928
  }
5900
5929
 
5901
5930
  if (!allowNumSeparator) {
5902
- this.raise(this.state.pos, ErrorMessages.NumericSeparatorInEscapeSequence);
5931
+ this.raise(ErrorMessages.NumericSeparatorInEscapeSequence, {
5932
+ at: this.state.curPosition()
5933
+ });
5903
5934
  }
5904
5935
 
5905
5936
  ++this.state.pos;
@@ -5919,7 +5950,9 @@ class Tokenizer extends ParserError {
5919
5950
  if (val >= radix) {
5920
5951
  if (this.options.errorRecovery && val <= 9) {
5921
5952
  val = 0;
5922
- this.raise(this.state.start + i + 2, ErrorMessages.InvalidDigit, radix);
5953
+ this.raise(ErrorMessages.InvalidDigit, {
5954
+ at: this.state.curPosition()
5955
+ }, radix);
5923
5956
  } else if (forceLen) {
5924
5957
  val = 0;
5925
5958
  invalid = true;
@@ -5940,13 +5973,15 @@ class Tokenizer extends ParserError {
5940
5973
  }
5941
5974
 
5942
5975
  readRadixNumber(radix) {
5943
- var start = this.state.pos;
5976
+ var startLoc = this.state.curPosition();
5944
5977
  var isBigInt = false;
5945
5978
  this.state.pos += 2;
5946
5979
  var val = this.readInt(radix);
5947
5980
 
5948
5981
  if (val == null) {
5949
- this.raise(this.state.start + 2, ErrorMessages.InvalidDigit, radix);
5982
+ this.raise(ErrorMessages.InvalidDigit, {
5983
+ at: createPositionWithColumnOffset(startLoc, 2)
5984
+ }, radix);
5950
5985
  }
5951
5986
 
5952
5987
  var next = this.input.charCodeAt(this.state.pos);
@@ -5955,15 +5990,19 @@ class Tokenizer extends ParserError {
5955
5990
  ++this.state.pos;
5956
5991
  isBigInt = true;
5957
5992
  } else if (next === 109) {
5958
- throw this.raise(start, ErrorMessages.InvalidDecimal);
5993
+ throw this.raise(ErrorMessages.InvalidDecimal, {
5994
+ at: startLoc
5995
+ });
5959
5996
  }
5960
5997
 
5961
5998
  if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
5962
- throw this.raise(this.state.pos, ErrorMessages.NumberIdentifier);
5999
+ throw this.raise(ErrorMessages.NumberIdentifier, {
6000
+ at: this.state.curPosition()
6001
+ });
5963
6002
  }
5964
6003
 
5965
6004
  if (isBigInt) {
5966
- var str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
6005
+ var str = this.input.slice(indexes.get(startLoc), this.state.pos).replace(/[_n]/g, "");
5967
6006
  this.finishToken(127, str);
5968
6007
  return;
5969
6008
  }
@@ -5973,6 +6012,7 @@ class Tokenizer extends ParserError {
5973
6012
 
5974
6013
  readNumber(startsWithDot) {
5975
6014
  var start = this.state.pos;
6015
+ var startLoc = this.state.curPosition();
5976
6016
  var isFloat = false;
5977
6017
  var isBigInt = false;
5978
6018
  var isDecimal = false;
@@ -5980,20 +6020,24 @@ class Tokenizer extends ParserError {
5980
6020
  var isOctal = false;
5981
6021
 
5982
6022
  if (!startsWithDot && this.readInt(10) === null) {
5983
- this.raise(start, ErrorMessages.InvalidNumber);
6023
+ this.raise(ErrorMessages.InvalidNumber, {
6024
+ at: this.state.curPosition()
6025
+ });
5984
6026
  }
5985
6027
 
5986
6028
  var hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
5987
6029
 
5988
6030
  if (hasLeadingZero) {
5989
6031
  var integer = this.input.slice(start, this.state.pos);
5990
- this.recordStrictModeErrors(start, ErrorMessages.StrictOctalLiteral);
6032
+ this.recordStrictModeErrors(ErrorMessages.StrictOctalLiteral, startLoc);
5991
6033
 
5992
6034
  if (!this.state.strict) {
5993
6035
  var underscorePos = integer.indexOf("_");
5994
6036
 
5995
6037
  if (underscorePos > 0) {
5996
- this.raise(underscorePos + start, ErrorMessages.ZeroDigitNumericSeparator);
6038
+ this.raise(ErrorMessages.ZeroDigitNumericSeparator, {
6039
+ at: createPositionWithColumnOffset(startLoc, underscorePos)
6040
+ });
5997
6041
  }
5998
6042
  }
5999
6043
 
@@ -6017,7 +6061,9 @@ class Tokenizer extends ParserError {
6017
6061
  }
6018
6062
 
6019
6063
  if (this.readInt(10) === null) {
6020
- this.raise(start, ErrorMessages.InvalidOrMissingExponent);
6064
+ this.raise(ErrorMessages.InvalidOrMissingExponent, {
6065
+ at: startLoc
6066
+ });
6021
6067
  }
6022
6068
 
6023
6069
  isFloat = true;
@@ -6027,7 +6073,9 @@ class Tokenizer extends ParserError {
6027
6073
 
6028
6074
  if (next === 110) {
6029
6075
  if (isFloat || hasLeadingZero) {
6030
- this.raise(start, ErrorMessages.InvalidBigIntLiteral);
6076
+ this.raise(ErrorMessages.InvalidBigIntLiteral, {
6077
+ at: startLoc
6078
+ });
6031
6079
  }
6032
6080
 
6033
6081
  ++this.state.pos;
@@ -6035,10 +6083,12 @@ class Tokenizer extends ParserError {
6035
6083
  }
6036
6084
 
6037
6085
  if (next === 109) {
6038
- this.expectPlugin("decimal", this.state.pos);
6086
+ this.expectPlugin("decimal", this.state.curPosition());
6039
6087
 
6040
6088
  if (hasExponent || hasLeadingZero) {
6041
- this.raise(start, ErrorMessages.InvalidDecimal);
6089
+ this.raise(ErrorMessages.InvalidDecimal, {
6090
+ at: startLoc
6091
+ });
6042
6092
  }
6043
6093
 
6044
6094
  ++this.state.pos;
@@ -6046,7 +6096,9 @@ class Tokenizer extends ParserError {
6046
6096
  }
6047
6097
 
6048
6098
  if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
6049
- throw this.raise(this.state.pos, ErrorMessages.NumberIdentifier);
6099
+ throw this.raise(ErrorMessages.NumberIdentifier, {
6100
+ at: this.state.curPosition()
6101
+ });
6050
6102
  }
6051
6103
 
6052
6104
  var str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
@@ -6070,13 +6122,15 @@ class Tokenizer extends ParserError {
6070
6122
  var code;
6071
6123
 
6072
6124
  if (ch === 123) {
6073
- var codePos = ++this.state.pos;
6125
+ ++this.state.pos;
6074
6126
  code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, true, throwOnInvalid);
6075
6127
  ++this.state.pos;
6076
6128
 
6077
6129
  if (code !== null && code > 0x10ffff) {
6078
6130
  if (throwOnInvalid) {
6079
- this.raise(codePos, ErrorMessages.InvalidCodePoint);
6131
+ this.raise(ErrorMessages.InvalidCodePoint, {
6132
+ at: this.state.curPosition()
6133
+ });
6080
6134
  } else {
6081
6135
  return null;
6082
6136
  }
@@ -6094,7 +6148,9 @@ class Tokenizer extends ParserError {
6094
6148
 
6095
6149
  for (;;) {
6096
6150
  if (this.state.pos >= this.length) {
6097
- throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
6151
+ throw this.raise(ErrorMessages.UnterminatedString, {
6152
+ at: this.state.startLoc
6153
+ });
6098
6154
  }
6099
6155
 
6100
6156
  var ch = this.input.charCodeAt(this.state.pos);
@@ -6109,7 +6165,9 @@ class Tokenizer extends ParserError {
6109
6165
  ++this.state.curLine;
6110
6166
  this.state.lineStart = this.state.pos;
6111
6167
  } else if (isNewLine(ch)) {
6112
- throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
6168
+ throw this.raise(ErrorMessages.UnterminatedString, {
6169
+ at: this.state.startLoc
6170
+ });
6113
6171
  } else {
6114
6172
  ++this.state.pos;
6115
6173
  }
@@ -6121,7 +6179,7 @@ class Tokenizer extends ParserError {
6121
6179
 
6122
6180
  readTemplateContinuation() {
6123
6181
  if (!this.match(8)) {
6124
- this.unexpected(this.state.start, 8);
6182
+ this.unexpected(null, 8);
6125
6183
  }
6126
6184
 
6127
6185
  this.state.pos--;
@@ -6136,7 +6194,9 @@ class Tokenizer extends ParserError {
6136
6194
 
6137
6195
  for (;;) {
6138
6196
  if (this.state.pos >= this.length) {
6139
- throw this.raise(this.state.start + 1, ErrorMessages.UnterminatedTemplate);
6197
+ throw this.raise(ErrorMessages.UnterminatedTemplate, {
6198
+ at: createPositionWithColumnOffset(this.state.startLoc, 1)
6199
+ });
6140
6200
  }
6141
6201
 
6142
6202
  var ch = this.input.charCodeAt(this.state.pos);
@@ -6194,11 +6254,18 @@ class Tokenizer extends ParserError {
6194
6254
  }
6195
6255
  }
6196
6256
 
6197
- recordStrictModeErrors(pos, message) {
6198
- if (this.state.strict && !this.state.strictErrors.has(pos)) {
6199
- this.raise(pos, message);
6257
+ recordStrictModeErrors(message, loc) {
6258
+ var index = indexes.get(loc);
6259
+
6260
+ if (this.state.strict && !this.state.strictErrors.has(index)) {
6261
+ this.raise(message, {
6262
+ at: loc
6263
+ });
6200
6264
  } else {
6201
- this.state.strictErrors.set(pos, message);
6265
+ this.state.strictErrors.set(index, {
6266
+ loc,
6267
+ message
6268
+ });
6202
6269
  }
6203
6270
  }
6204
6271
 
@@ -6257,12 +6324,12 @@ class Tokenizer extends ParserError {
6257
6324
  if (inTemplate) {
6258
6325
  return null;
6259
6326
  } else {
6260
- this.recordStrictModeErrors(this.state.pos - 1, ErrorMessages.StrictNumericEscape);
6327
+ this.recordStrictModeErrors(ErrorMessages.StrictNumericEscape, createPositionWithColumnOffset(this.state.curPosition(), -1));
6261
6328
  }
6262
6329
 
6263
6330
  default:
6264
6331
  if (ch >= 48 && ch <= 55) {
6265
- var codePos = this.state.pos - 1;
6332
+ var codePos = createPositionWithColumnOffset(this.state.curPosition(), -1);
6266
6333
  var match = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/);
6267
6334
  var octalStr = match[0];
6268
6335
  var octal = parseInt(octalStr, 8);
@@ -6279,7 +6346,7 @@ class Tokenizer extends ParserError {
6279
6346
  if (inTemplate) {
6280
6347
  return null;
6281
6348
  } else {
6282
- this.recordStrictModeErrors(codePos, ErrorMessages.StrictNumericEscape);
6349
+ this.recordStrictModeErrors(ErrorMessages.StrictNumericEscape, codePos);
6283
6350
  }
6284
6351
  }
6285
6352
 
@@ -6291,14 +6358,16 @@ class Tokenizer extends ParserError {
6291
6358
  }
6292
6359
 
6293
6360
  readHexChar(len, forceLen, throwOnInvalid) {
6294
- var codePos = this.state.pos;
6361
+ var codeLoc = this.state.curPosition();
6295
6362
  var n = this.readInt(16, len, forceLen, false);
6296
6363
 
6297
6364
  if (n === null) {
6298
6365
  if (throwOnInvalid) {
6299
- this.raise(codePos, ErrorMessages.InvalidEscapeSequence);
6366
+ this.raise(ErrorMessages.InvalidEscapeSequence, {
6367
+ at: codeLoc
6368
+ });
6300
6369
  } else {
6301
- this.state.pos = codePos - 1;
6370
+ this.state.pos = indexes.get(codeLoc) - 1;
6302
6371
  }
6303
6372
  }
6304
6373
 
@@ -6323,11 +6392,13 @@ class Tokenizer extends ParserError {
6323
6392
  } else if (ch === 92) {
6324
6393
  this.state.containsEsc = true;
6325
6394
  word += this.input.slice(chunkStart, this.state.pos);
6326
- var escStart = this.state.pos;
6395
+ var escStart = this.state.curPosition();
6327
6396
  var identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
6328
6397
 
6329
6398
  if (this.input.charCodeAt(++this.state.pos) !== 117) {
6330
- this.raise(this.state.pos, ErrorMessages.MissingUnicodeEscape);
6399
+ this.raise(ErrorMessages.MissingUnicodeEscape, {
6400
+ at: this.state.curPosition()
6401
+ });
6331
6402
  chunkStart = this.state.pos - 1;
6332
6403
  continue;
6333
6404
  }
@@ -6337,7 +6408,9 @@ class Tokenizer extends ParserError {
6337
6408
 
6338
6409
  if (esc !== null) {
6339
6410
  if (!identifierCheck(esc)) {
6340
- this.raise(escStart, ErrorMessages.EscapedCharNotAnIdentifier);
6411
+ this.raise(ErrorMessages.EscapedCharNotAnIdentifier, {
6412
+ at: escStart
6413
+ });
6341
6414
  }
6342
6415
 
6343
6416
  word += String.fromCodePoint(esc);
@@ -6369,7 +6442,9 @@ class Tokenizer extends ParserError {
6369
6442
  } = this.state;
6370
6443
 
6371
6444
  if (tokenIsKeyword(type) && this.state.containsEsc) {
6372
- this.raise(this.state.start, ErrorMessages.InvalidEscapedReservedWord, tokenLabelName(type));
6445
+ this.raise(ErrorMessages.InvalidEscapedReservedWord, {
6446
+ at: this.state.startLoc
6447
+ }, tokenLabelName(type));
6373
6448
  }
6374
6449
  }
6375
6450
 
@@ -6405,18 +6480,20 @@ class ClassScopeHandler {
6405
6480
  var oldClassScope = this.stack.pop();
6406
6481
  var current = this.current();
6407
6482
 
6408
- for (var [name, pos] of Array.from(oldClassScope.undefinedPrivateNames)) {
6483
+ for (var [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
6409
6484
  if (current) {
6410
6485
  if (!current.undefinedPrivateNames.has(name)) {
6411
- current.undefinedPrivateNames.set(name, pos);
6486
+ current.undefinedPrivateNames.set(name, loc);
6412
6487
  }
6413
6488
  } else {
6414
- this.raise(pos, ErrorMessages.InvalidPrivateFieldResolution, name);
6489
+ this.raise(ErrorMessages.InvalidPrivateFieldResolution, {
6490
+ at: loc
6491
+ }, name);
6415
6492
  }
6416
6493
  }
6417
6494
  }
6418
6495
 
6419
- declarePrivateName(name, elementType, pos) {
6496
+ declarePrivateName(name, elementType, loc) {
6420
6497
  var {
6421
6498
  privateNames,
6422
6499
  loneAccessors,
@@ -6440,14 +6517,16 @@ class ClassScopeHandler {
6440
6517
  }
6441
6518
 
6442
6519
  if (redefined) {
6443
- this.raise(pos, ErrorMessages.PrivateNameRedeclaration, name);
6520
+ this.raise(ErrorMessages.PrivateNameRedeclaration, {
6521
+ at: loc
6522
+ }, name);
6444
6523
  }
6445
6524
 
6446
6525
  privateNames.add(name);
6447
6526
  undefinedPrivateNames.delete(name);
6448
6527
  }
6449
6528
 
6450
- usePrivateName(name, pos) {
6529
+ usePrivateName(name, loc) {
6451
6530
  var classScope;
6452
6531
 
6453
6532
  for (classScope of this.stack) {
@@ -6455,9 +6534,11 @@ class ClassScopeHandler {
6455
6534
  }
6456
6535
 
6457
6536
  if (classScope) {
6458
- classScope.undefinedPrivateNames.set(name, pos);
6537
+ classScope.undefinedPrivateNames.set(name, loc);
6459
6538
  } else {
6460
- this.raise(pos, ErrorMessages.InvalidPrivateFieldResolution, name);
6539
+ this.raise(ErrorMessages.InvalidPrivateFieldResolution, {
6540
+ at: loc
6541
+ }, name);
6461
6542
  }
6462
6543
  }
6463
6544
 
@@ -6491,12 +6572,15 @@ class ArrowHeadParsingScope extends ExpressionScope {
6491
6572
  this.errors = new Map();
6492
6573
  }
6493
6574
 
6494
- recordDeclarationError(pos, template) {
6495
- this.errors.set(pos, template);
6575
+ recordDeclarationError(message, loc) {
6576
+ this.errors.set(indexes.get(loc), {
6577
+ message,
6578
+ loc
6579
+ });
6496
6580
  }
6497
6581
 
6498
- clearDeclarationError(pos) {
6499
- this.errors.delete(pos);
6582
+ clearDeclarationError(loc) {
6583
+ this.errors.delete(indexes.get(loc));
6500
6584
  }
6501
6585
 
6502
6586
  iterateErrors(iterator) {
@@ -6519,7 +6603,7 @@ class ExpressionScopeHandler {
6519
6603
  this.stack.pop();
6520
6604
  }
6521
6605
 
6522
- recordParameterInitializerError(pos, template) {
6606
+ recordParameterInitializerError(loc, template) {
6523
6607
  var {
6524
6608
  stack
6525
6609
  } = this;
@@ -6528,7 +6612,7 @@ class ExpressionScopeHandler {
6528
6612
 
6529
6613
  while (!scope.isCertainlyParameterDeclaration()) {
6530
6614
  if (scope.canBeArrowParameterDeclaration()) {
6531
- scope.recordDeclarationError(pos, template);
6615
+ scope.recordDeclarationError(template, loc);
6532
6616
  } else {
6533
6617
  return;
6534
6618
  }
@@ -6536,25 +6620,29 @@ class ExpressionScopeHandler {
6536
6620
  scope = stack[--i];
6537
6621
  }
6538
6622
 
6539
- this.raise(pos, template);
6623
+ this.raise(template, {
6624
+ at: loc
6625
+ });
6540
6626
  }
6541
6627
 
6542
- recordParenthesizedIdentifierError(pos, template) {
6628
+ recordParenthesizedIdentifierError(template, loc) {
6543
6629
  var {
6544
6630
  stack
6545
6631
  } = this;
6546
6632
  var scope = stack[stack.length - 1];
6547
6633
 
6548
6634
  if (scope.isCertainlyParameterDeclaration()) {
6549
- this.raise(pos, template);
6635
+ this.raise(template, {
6636
+ at: loc
6637
+ });
6550
6638
  } else if (scope.canBeArrowParameterDeclaration()) {
6551
- scope.recordDeclarationError(pos, template);
6639
+ scope.recordDeclarationError(template, loc);
6552
6640
  } else {
6553
6641
  return;
6554
6642
  }
6555
6643
  }
6556
6644
 
6557
- recordAsyncArrowParametersError(pos, template) {
6645
+ recordAsyncArrowParametersError(template, loc) {
6558
6646
  var {
6559
6647
  stack
6560
6648
  } = this;
@@ -6563,7 +6651,7 @@ class ExpressionScopeHandler {
6563
6651
 
6564
6652
  while (scope.canBeArrowParameterDeclaration()) {
6565
6653
  if (scope.type === kMaybeAsyncArrowParameterDeclaration) {
6566
- scope.recordDeclarationError(pos, template);
6654
+ scope.recordDeclarationError(template, loc);
6567
6655
  }
6568
6656
 
6569
6657
  scope = stack[--i];
@@ -6576,13 +6664,19 @@ class ExpressionScopeHandler {
6576
6664
  } = this;
6577
6665
  var currentScope = stack[stack.length - 1];
6578
6666
  if (!currentScope.canBeArrowParameterDeclaration()) return;
6579
- currentScope.iterateErrors((template, pos) => {
6580
- this.raise(pos, template);
6667
+ currentScope.iterateErrors(_ref6 => {
6668
+ var {
6669
+ message,
6670
+ loc
6671
+ } = _ref6;
6672
+ this.raise(message, {
6673
+ at: loc
6674
+ });
6581
6675
  var i = stack.length - 2;
6582
6676
  var scope = stack[i];
6583
6677
 
6584
6678
  while (scope.canBeArrowParameterDeclaration()) {
6585
- scope.clearDeclarationError(pos);
6679
+ scope.clearDeclarationError(loc);
6586
6680
  scope = stack[--i];
6587
6681
  }
6588
6682
  });
@@ -6652,10 +6746,19 @@ function functionFlags(isAsync, isGenerator) {
6652
6746
  }
6653
6747
 
6654
6748
  class UtilParser extends Tokenizer {
6655
- addExtra(node, key, val) {
6749
+ addExtra(node, key, value) {
6750
+ var enumerable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
6656
6751
  if (!node) return;
6657
6752
  var extra = node.extra = node.extra || {};
6658
- extra[key] = val;
6753
+
6754
+ if (enumerable) {
6755
+ extra[key] = value;
6756
+ } else {
6757
+ Object.defineProperty(extra, key, {
6758
+ enumerable,
6759
+ value
6760
+ });
6761
+ }
6659
6762
  }
6660
6763
 
6661
6764
  isContextual(token) {
@@ -6688,7 +6791,15 @@ class UtilParser extends Tokenizer {
6688
6791
  }
6689
6792
 
6690
6793
  expectContextual(token, template) {
6691
- if (!this.eatContextual(token)) this.unexpected(null, template);
6794
+ if (!this.eatContextual(token)) {
6795
+ if (template != null) {
6796
+ throw this.raise(template, {
6797
+ at: this.state.startLoc
6798
+ });
6799
+ }
6800
+
6801
+ throw this.unexpected(null, token);
6802
+ }
6692
6803
  }
6693
6804
 
6694
6805
  canInsertSemicolon() {
@@ -6696,7 +6807,7 @@ class UtilParser extends Tokenizer {
6696
6807
  }
6697
6808
 
6698
6809
  hasPrecedingLineBreak() {
6699
- return lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
6810
+ return lineBreak.test(this.input.slice(indexes.get(this.state.lastTokEndLoc), this.state.start));
6700
6811
  }
6701
6812
 
6702
6813
  hasFollowingLineBreak() {
@@ -6711,41 +6822,37 @@ class UtilParser extends Tokenizer {
6711
6822
  semicolon() {
6712
6823
  var allowAsi = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6713
6824
  if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
6714
- this.raise(this.state.lastTokEnd, ErrorMessages.MissingSemicolon);
6825
+ this.raise(ErrorMessages.MissingSemicolon, {
6826
+ at: this.state.lastTokEndLoc
6827
+ });
6715
6828
  }
6716
6829
 
6717
- expect(type, pos) {
6718
- this.eat(type) || this.unexpected(pos, type);
6830
+ expect(type, loc) {
6831
+ this.eat(type) || this.unexpected(loc, type);
6719
6832
  }
6720
6833
 
6721
6834
  assertNoSpace() {
6722
6835
  var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Unexpected space.";
6723
6836
 
6724
- if (this.state.start > this.state.lastTokEnd) {
6725
- this.raise(this.state.lastTokEnd, {
6837
+ if (this.state.start > indexes.get(this.state.lastTokEndLoc)) {
6838
+ this.raise({
6726
6839
  code: ErrorCodes.SyntaxError,
6727
6840
  reasonCode: "UnexpectedSpace",
6728
6841
  template: message
6842
+ }, {
6843
+ at: this.state.lastTokEndLoc
6729
6844
  });
6730
6845
  }
6731
6846
  }
6732
6847
 
6733
- unexpected(pos) {
6734
- var messageOrType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
6848
+ unexpected(loc, type) {
6849
+ throw this.raise({
6735
6850
  code: ErrorCodes.SyntaxError,
6736
6851
  reasonCode: "UnexpectedToken",
6737
- template: "Unexpected token"
6738
- };
6739
-
6740
- if (isTokenType(messageOrType)) {
6741
- messageOrType = {
6742
- code: ErrorCodes.SyntaxError,
6743
- reasonCode: "UnexpectedToken",
6744
- template: "Unexpected token, expected \"".concat(tokenLabelName(messageOrType), "\"")
6745
- };
6746
- }
6747
-
6748
- throw this.raise(pos != null ? pos : this.state.start, messageOrType);
6852
+ template: type != null ? "Unexpected token, expected \"".concat(tokenLabelName(type), "\"") : "Unexpected token"
6853
+ }, {
6854
+ at: loc != null ? loc : this.state.startLoc
6855
+ });
6749
6856
  }
6750
6857
 
6751
6858
  getPluginNamesFromConfigs(pluginConfigs) {
@@ -6758,9 +6865,9 @@ class UtilParser extends Tokenizer {
6758
6865
  });
6759
6866
  }
6760
6867
 
6761
- expectPlugin(pluginConfig, pos) {
6868
+ expectPlugin(pluginConfig, loc) {
6762
6869
  if (!this.hasPlugin(pluginConfig)) {
6763
- throw this.raiseWithData(pos != null ? pos : this.state.start, {
6870
+ throw this.raiseWithData(loc != null ? loc : this.state.startLoc, {
6764
6871
  missingPlugin: this.getPluginNamesFromConfigs([pluginConfig])
6765
6872
  }, "This experimental syntax requires enabling the parser plugin: ".concat(JSON.stringify(pluginConfig), "."));
6766
6873
  }
@@ -6768,9 +6875,9 @@ class UtilParser extends Tokenizer {
6768
6875
  return true;
6769
6876
  }
6770
6877
 
6771
- expectOnePlugin(pluginConfigs, pos) {
6878
+ expectOnePlugin(pluginConfigs) {
6772
6879
  if (!pluginConfigs.some(c => this.hasPlugin(c))) {
6773
- throw this.raiseWithData(pos != null ? pos : this.state.start, {
6880
+ throw this.raiseWithData(this.state.startLoc, {
6774
6881
  missingPlugin: this.getPluginNamesFromConfigs(pluginConfigs)
6775
6882
  }, "This experimental syntax requires enabling one of the following parser plugin(s): ".concat(pluginConfigs.map(c => JSON.stringify(c)).join(", "), "."));
6776
6883
  }
@@ -6840,26 +6947,30 @@ class UtilParser extends Tokenizer {
6840
6947
  checkExpressionErrors(refExpressionErrors, andThrow) {
6841
6948
  if (!refExpressionErrors) return false;
6842
6949
  var {
6843
- shorthandAssign,
6844
- doubleProto,
6845
- optionalParameters
6950
+ shorthandAssignLoc,
6951
+ doubleProtoLoc,
6952
+ optionalParametersLoc
6846
6953
  } = refExpressionErrors;
6847
- var hasErrors = shorthandAssign + doubleProto + optionalParameters > -3;
6954
+ var hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc;
6848
6955
 
6849
6956
  if (!andThrow) {
6850
6957
  return hasErrors;
6851
- } else if (hasErrors) {
6852
- if (shorthandAssign >= 0) {
6853
- this.raise(shorthandAssign, ErrorMessages.InvalidCoverInitializedName);
6854
- }
6958
+ }
6855
6959
 
6856
- if (doubleProto >= 0) {
6857
- this.raise(doubleProto, ErrorMessages.DuplicateProto);
6858
- }
6960
+ if (shorthandAssignLoc != null) {
6961
+ this.raise(ErrorMessages.InvalidCoverInitializedName, {
6962
+ at: shorthandAssignLoc
6963
+ });
6964
+ }
6859
6965
 
6860
- if (optionalParameters >= 0) {
6861
- this.unexpected(optionalParameters);
6862
- }
6966
+ if (doubleProtoLoc != null) {
6967
+ this.raise(ErrorMessages.DuplicateProto, {
6968
+ at: doubleProtoLoc
6969
+ });
6970
+ }
6971
+
6972
+ if (optionalParametersLoc != null) {
6973
+ this.unexpected(optionalParametersLoc);
6863
6974
  }
6864
6975
  }
6865
6976
 
@@ -6934,9 +7045,9 @@ class UtilParser extends Tokenizer {
6934
7045
 
6935
7046
  class ExpressionErrors {
6936
7047
  constructor() {
6937
- this.shorthandAssign = -1;
6938
- this.doubleProto = -1;
6939
- this.optionalParameters = -1;
7048
+ this.shorthandAssignLoc = null;
7049
+ this.doubleProtoLoc = null;
7050
+ this.optionalParametersLoc = null;
6940
7051
  }
6941
7052
 
6942
7053
  }
@@ -7046,14 +7157,14 @@ class NodeUtils extends UtilParser {
7046
7157
  }
7047
7158
 
7048
7159
  finishNode(node, type) {
7049
- return this.finishNodeAt(node, type, this.state.lastTokEnd, this.state.lastTokEndLoc);
7160
+ return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
7050
7161
  }
7051
7162
 
7052
- finishNodeAt(node, type, pos, loc) {
7163
+ finishNodeAt(node, type, endLoc) {
7053
7164
  node.type = type;
7054
- node.end = pos;
7055
- node.loc.end = loc;
7056
- if (this.options.ranges) node.range[1] = pos;
7165
+ node.end = indexes.get(endLoc);
7166
+ node.loc.end = endLoc;
7167
+ if (this.options.ranges) node.range[1] = node.end;
7057
7168
  if (this.options.attachComment) this.processComment(node);
7058
7169
  return node;
7059
7170
  }
@@ -7065,11 +7176,10 @@ class NodeUtils extends UtilParser {
7065
7176
  }
7066
7177
 
7067
7178
  resetEndLocation(node) {
7068
- var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEnd;
7069
- var endLoc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.state.lastTokEndLoc;
7070
- node.end = end;
7179
+ var endLoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEndLoc;
7180
+ node.end = indexes.get(endLoc);
7071
7181
  node.loc.end = endLoc;
7072
- if (this.options.ranges) node.range[1] = end;
7182
+ if (this.options.ranges) node.range[1] = node.end;
7073
7183
  }
7074
7184
 
7075
7185
  resetStartLocationFromNode(node, locationNode) {
@@ -7215,12 +7325,14 @@ var flow = superClass => class extends superClass {
7215
7325
 
7216
7326
  flowParsePredicate() {
7217
7327
  var node = this.startNode();
7218
- var moduloPos = this.state.start;
7328
+ var moduloLoc = this.state.startLoc;
7219
7329
  this.next();
7220
7330
  this.expectContextual(103);
7221
7331
 
7222
- if (this.state.lastTokStart > moduloPos + 1) {
7223
- this.raise(moduloPos, FlowErrors.UnexpectedSpaceBetweenModuloChecks);
7332
+ if (this.state.lastTokStart > indexes.get(moduloLoc) + 1) {
7333
+ this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, {
7334
+ at: moduloLoc
7335
+ });
7224
7336
  }
7225
7337
 
7226
7338
  if (this.eat(10)) {
@@ -7283,7 +7395,7 @@ var flow = superClass => class extends superClass {
7283
7395
  id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
7284
7396
  this.resetEndLocation(id);
7285
7397
  this.semicolon();
7286
- this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.start);
7398
+ this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.loc.start);
7287
7399
  return this.finishNode(node, "DeclareFunction");
7288
7400
  }
7289
7401
 
@@ -7299,7 +7411,9 @@ var flow = superClass => class extends superClass {
7299
7411
  return this.flowParseDeclareModuleExports(node);
7300
7412
  } else {
7301
7413
  if (insideModule) {
7302
- this.raise(this.state.lastTokStart, FlowErrors.NestedDeclareModule);
7414
+ this.raise(FlowErrors.NestedDeclareModule, {
7415
+ at: this.state.lastTokStartLoc
7416
+ });
7303
7417
  }
7304
7418
 
7305
7419
  return this.flowParseDeclareModule(node);
@@ -7320,7 +7434,7 @@ var flow = superClass => class extends superClass {
7320
7434
  flowParseDeclareVariable(node) {
7321
7435
  this.next();
7322
7436
  node.id = this.flowParseTypeAnnotatableIdentifier(true);
7323
- this.scope.declareName(node.id.name, BIND_VAR, node.id.start);
7437
+ this.scope.declareName(node.id.name, BIND_VAR, node.id.loc.start);
7324
7438
  this.semicolon();
7325
7439
  return this.finishNode(node, "DeclareVariable");
7326
7440
  }
@@ -7345,7 +7459,9 @@ var flow = superClass => class extends superClass {
7345
7459
  this.next();
7346
7460
 
7347
7461
  if (!this.isContextual(122) && !this.match(83)) {
7348
- this.raise(this.state.lastTokStart, FlowErrors.InvalidNonTypeImportInDeclareModule);
7462
+ this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, {
7463
+ at: this.state.lastTokStartLoc
7464
+ });
7349
7465
  }
7350
7466
 
7351
7467
  this.parseImport(_bodyNode);
@@ -7365,17 +7481,23 @@ var flow = superClass => class extends superClass {
7365
7481
  body.forEach(bodyElement => {
7366
7482
  if (isEsModuleType(bodyElement)) {
7367
7483
  if (kind === "CommonJS") {
7368
- this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind);
7484
+ this.raise(FlowErrors.AmbiguousDeclareModuleKind, {
7485
+ node: bodyElement
7486
+ });
7369
7487
  }
7370
7488
 
7371
7489
  kind = "ES";
7372
7490
  } else if (bodyElement.type === "DeclareModuleExports") {
7373
7491
  if (hasModuleExport) {
7374
- this.raise(bodyElement.start, FlowErrors.DuplicateDeclareModuleExports);
7492
+ this.raise(FlowErrors.DuplicateDeclareModuleExports, {
7493
+ node: bodyElement
7494
+ });
7375
7495
  }
7376
7496
 
7377
7497
  if (kind === "ES") {
7378
- this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind);
7498
+ this.raise(FlowErrors.AmbiguousDeclareModuleKind, {
7499
+ node: bodyElement
7500
+ });
7379
7501
  }
7380
7502
 
7381
7503
  kind = "CommonJS";
@@ -7403,7 +7525,9 @@ var flow = superClass => class extends superClass {
7403
7525
  if (this.match(71) || this.isLet() || (this.isContextual(122) || this.isContextual(121)) && !insideModule) {
7404
7526
  var label = this.state.value;
7405
7527
  var suggestion = exportSuggestions[label];
7406
- throw this.raise(this.state.start, FlowErrors.UnsupportedDeclareExportKind, label, suggestion);
7528
+ throw this.raise(FlowErrors.UnsupportedDeclareExportKind, {
7529
+ at: this.state.startLoc
7530
+ }, label, suggestion);
7407
7531
  }
7408
7532
 
7409
7533
  if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(123)) {
@@ -7458,7 +7582,7 @@ var flow = superClass => class extends superClass {
7458
7582
  flowParseInterfaceish(node) {
7459
7583
  var isClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
7460
7584
  node.id = this.flowParseRestrictedIdentifier(!isClass, true);
7461
- this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.start);
7585
+ this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.loc.start);
7462
7586
 
7463
7587
  if (this.match(45)) {
7464
7588
  node.typeParameters = this.flowParseTypeParameterDeclaration();
@@ -7521,23 +7645,27 @@ var flow = superClass => class extends superClass {
7521
7645
 
7522
7646
  checkNotUnderscore(word) {
7523
7647
  if (word === "_") {
7524
- this.raise(this.state.start, FlowErrors.UnexpectedReservedUnderscore);
7648
+ this.raise(FlowErrors.UnexpectedReservedUnderscore, {
7649
+ at: this.state.startLoc
7650
+ });
7525
7651
  }
7526
7652
  }
7527
7653
 
7528
7654
  checkReservedType(word, startLoc, declaration) {
7529
7655
  if (!reservedTypes.has(word)) return;
7530
- this.raise(startLoc, declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, word);
7656
+ this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, {
7657
+ at: startLoc
7658
+ }, word);
7531
7659
  }
7532
7660
 
7533
7661
  flowParseRestrictedIdentifier(liberal, declaration) {
7534
- this.checkReservedType(this.state.value, this.state.start, declaration);
7662
+ this.checkReservedType(this.state.value, this.state.startLoc, declaration);
7535
7663
  return this.parseIdentifier(liberal);
7536
7664
  }
7537
7665
 
7538
7666
  flowParseTypeAlias(node) {
7539
7667
  node.id = this.flowParseRestrictedIdentifier(false, true);
7540
- this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
7668
+ this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start);
7541
7669
 
7542
7670
  if (this.match(45)) {
7543
7671
  node.typeParameters = this.flowParseTypeParameterDeclaration();
@@ -7553,7 +7681,7 @@ var flow = superClass => class extends superClass {
7553
7681
  flowParseOpaqueType(node, declare) {
7554
7682
  this.expectContextual(122);
7555
7683
  node.id = this.flowParseRestrictedIdentifier(true, true);
7556
- this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
7684
+ this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start);
7557
7685
 
7558
7686
  if (this.match(45)) {
7559
7687
  node.typeParameters = this.flowParseTypeParameterDeclaration();
@@ -7579,7 +7707,7 @@ var flow = superClass => class extends superClass {
7579
7707
 
7580
7708
  flowParseTypeParameter() {
7581
7709
  var requireDefault = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
7582
- var nodeStart = this.state.start;
7710
+ var nodeStartLoc = this.state.startLoc;
7583
7711
  var node = this.startNode();
7584
7712
  var variance = this.flowParseVariance();
7585
7713
  var ident = this.flowParseTypeAnnotatableIdentifier();
@@ -7592,7 +7720,9 @@ var flow = superClass => class extends superClass {
7592
7720
  node.default = this.flowParseType();
7593
7721
  } else {
7594
7722
  if (requireDefault) {
7595
- this.raise(nodeStart, FlowErrors.MissingTypeParamDefault);
7723
+ this.raise(FlowErrors.MissingTypeParamDefault, {
7724
+ at: nodeStartLoc
7725
+ });
7596
7726
  }
7597
7727
  }
7598
7728
 
@@ -7784,14 +7914,14 @@ var flow = superClass => class extends superClass {
7784
7914
  return this.finishNode(node, "ObjectTypeCallProperty");
7785
7915
  }
7786
7916
 
7787
- flowParseObjectType(_ref5) {
7917
+ flowParseObjectType(_ref7) {
7788
7918
  var {
7789
7919
  allowStatic,
7790
7920
  allowExact,
7791
7921
  allowSpread,
7792
7922
  allowProto,
7793
7923
  allowInexact
7794
- } = _ref5;
7924
+ } = _ref7;
7795
7925
  var oldInType = this.state.inType;
7796
7926
  this.state.inType = true;
7797
7927
  var nodeStart = this.startNode();
@@ -7817,8 +7947,8 @@ var flow = superClass => class extends superClass {
7817
7947
 
7818
7948
  while (!this.match(endDelim)) {
7819
7949
  var isStatic = false;
7820
- var protoStart = null;
7821
- var inexactStart = null;
7950
+ var protoStartLoc = null;
7951
+ var inexactStartLoc = null;
7822
7952
  var node = this.startNode();
7823
7953
 
7824
7954
  if (allowProto && this.isContextual(111)) {
@@ -7826,7 +7956,7 @@ var flow = superClass => class extends superClass {
7826
7956
 
7827
7957
  if (lookahead.type !== 14 && lookahead.type !== 17) {
7828
7958
  this.next();
7829
- protoStart = this.state.start;
7959
+ protoStartLoc = this.state.startLoc;
7830
7960
  allowStatic = false;
7831
7961
  }
7832
7962
  }
@@ -7843,13 +7973,13 @@ var flow = superClass => class extends superClass {
7843
7973
  var variance = this.flowParseVariance();
7844
7974
 
7845
7975
  if (this.eat(0)) {
7846
- if (protoStart != null) {
7847
- this.unexpected(protoStart);
7976
+ if (protoStartLoc != null) {
7977
+ this.unexpected(protoStartLoc);
7848
7978
  }
7849
7979
 
7850
7980
  if (this.eat(0)) {
7851
7981
  if (variance) {
7852
- this.unexpected(variance.start);
7982
+ this.unexpected(variance.loc.start);
7853
7983
  }
7854
7984
 
7855
7985
  nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
@@ -7857,12 +7987,12 @@ var flow = superClass => class extends superClass {
7857
7987
  nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
7858
7988
  }
7859
7989
  } else if (this.match(10) || this.match(45)) {
7860
- if (protoStart != null) {
7861
- this.unexpected(protoStart);
7990
+ if (protoStartLoc != null) {
7991
+ this.unexpected(protoStartLoc);
7862
7992
  }
7863
7993
 
7864
7994
  if (variance) {
7865
- this.unexpected(variance.start);
7995
+ this.unexpected(variance.loc.start);
7866
7996
  }
7867
7997
 
7868
7998
  nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
@@ -7878,11 +8008,11 @@ var flow = superClass => class extends superClass {
7878
8008
  }
7879
8009
  }
7880
8010
 
7881
- var propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
8011
+ var propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
7882
8012
 
7883
8013
  if (propOrInexact === null) {
7884
8014
  inexact = true;
7885
- inexactStart = this.state.lastTokStart;
8015
+ inexactStartLoc = this.state.lastTokStartLoc;
7886
8016
  } else {
7887
8017
  nodeStart.properties.push(propOrInexact);
7888
8018
  }
@@ -7890,8 +8020,10 @@ var flow = superClass => class extends superClass {
7890
8020
 
7891
8021
  this.flowObjectTypeSemicolon();
7892
8022
 
7893
- if (inexactStart && !this.match(8) && !this.match(9)) {
7894
- this.raise(inexactStart, FlowErrors.UnexpectedExplicitInexactInObject);
8023
+ if (inexactStartLoc && !this.match(8) && !this.match(9)) {
8024
+ this.raise(FlowErrors.UnexpectedExplicitInexactInObject, {
8025
+ at: inexactStartLoc
8026
+ });
7895
8027
  }
7896
8028
  }
7897
8029
 
@@ -7906,34 +8038,44 @@ var flow = superClass => class extends superClass {
7906
8038
  return out;
7907
8039
  }
7908
8040
 
7909
- flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact) {
8041
+ flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
7910
8042
  if (this.eat(21)) {
7911
8043
  var isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
7912
8044
 
7913
8045
  if (isInexactToken) {
7914
8046
  if (!allowSpread) {
7915
- this.raise(this.state.lastTokStart, FlowErrors.InexactInsideNonObject);
8047
+ this.raise(FlowErrors.InexactInsideNonObject, {
8048
+ at: this.state.lastTokStartLoc
8049
+ });
7916
8050
  } else if (!allowInexact) {
7917
- this.raise(this.state.lastTokStart, FlowErrors.InexactInsideExact);
8051
+ this.raise(FlowErrors.InexactInsideExact, {
8052
+ at: this.state.lastTokStartLoc
8053
+ });
7918
8054
  }
7919
8055
 
7920
8056
  if (variance) {
7921
- this.raise(variance.start, FlowErrors.InexactVariance);
8057
+ this.raise(FlowErrors.InexactVariance, {
8058
+ node: variance
8059
+ });
7922
8060
  }
7923
8061
 
7924
8062
  return null;
7925
8063
  }
7926
8064
 
7927
8065
  if (!allowSpread) {
7928
- this.raise(this.state.lastTokStart, FlowErrors.UnexpectedSpreadType);
8066
+ this.raise(FlowErrors.UnexpectedSpreadType, {
8067
+ at: this.state.lastTokStartLoc
8068
+ });
7929
8069
  }
7930
8070
 
7931
- if (protoStart != null) {
7932
- this.unexpected(protoStart);
8071
+ if (protoStartLoc != null) {
8072
+ this.unexpected(protoStartLoc);
7933
8073
  }
7934
8074
 
7935
8075
  if (variance) {
7936
- this.raise(variance.start, FlowErrors.SpreadVariance);
8076
+ this.raise(FlowErrors.SpreadVariance, {
8077
+ node: variance
8078
+ });
7937
8079
  }
7938
8080
 
7939
8081
  node.argument = this.flowParseType();
@@ -7941,19 +8083,19 @@ var flow = superClass => class extends superClass {
7941
8083
  } else {
7942
8084
  node.key = this.flowParseObjectPropertyKey();
7943
8085
  node.static = isStatic;
7944
- node.proto = protoStart != null;
8086
+ node.proto = protoStartLoc != null;
7945
8087
  node.kind = kind;
7946
8088
  var optional = false;
7947
8089
 
7948
8090
  if (this.match(45) || this.match(10)) {
7949
8091
  node.method = true;
7950
8092
 
7951
- if (protoStart != null) {
7952
- this.unexpected(protoStart);
8093
+ if (protoStartLoc != null) {
8094
+ this.unexpected(protoStartLoc);
7953
8095
  }
7954
8096
 
7955
8097
  if (variance) {
7956
- this.unexpected(variance.start);
8098
+ this.unexpected(variance.loc.start);
7957
8099
  }
7958
8100
 
7959
8101
  node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
@@ -7963,7 +8105,9 @@ var flow = superClass => class extends superClass {
7963
8105
  }
7964
8106
 
7965
8107
  if (!allowSpread && node.key.name === "constructor" && node.value.this) {
7966
- this.raise(node.value.this.start, FlowErrors.ThisParamBannedInConstructor);
8108
+ this.raise(FlowErrors.ThisParamBannedInConstructor, {
8109
+ node: node.value.this
8110
+ });
7967
8111
  }
7968
8112
  } else {
7969
8113
  if (kind !== "init") this.unexpected();
@@ -7984,23 +8128,24 @@ var flow = superClass => class extends superClass {
7984
8128
 
7985
8129
  flowCheckGetterSetterParams(property) {
7986
8130
  var paramCount = property.kind === "get" ? 0 : 1;
7987
- var start = property.start;
7988
8131
  var length = property.value.params.length + (property.value.rest ? 1 : 0);
7989
8132
 
7990
8133
  if (property.value.this) {
7991
- this.raise(property.value.this.start, property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam);
8134
+ this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, {
8135
+ node: property.value.this
8136
+ });
7992
8137
  }
7993
8138
 
7994
8139
  if (length !== paramCount) {
7995
- if (property.kind === "get") {
7996
- this.raise(start, ErrorMessages.BadGetterArity);
7997
- } else {
7998
- this.raise(start, ErrorMessages.BadSetterArity);
7999
- }
8140
+ this.raise(property.kind === "get" ? ErrorMessages.BadGetterArity : ErrorMessages.BadSetterArity, {
8141
+ node: property
8142
+ });
8000
8143
  }
8001
8144
 
8002
8145
  if (property.kind === "set" && property.value.rest) {
8003
- this.raise(start, ErrorMessages.BadSetterRestParameter);
8146
+ this.raise(ErrorMessages.BadSetterRestParameter, {
8147
+ node: property
8148
+ });
8004
8149
  }
8005
8150
  }
8006
8151
 
@@ -8069,7 +8214,9 @@ var flow = superClass => class extends superClass {
8069
8214
 
8070
8215
  if (lh.type === 14 || lh.type === 17) {
8071
8216
  if (isThis && !first) {
8072
- this.raise(node.start, FlowErrors.ThisParamMustBeFirst);
8217
+ this.raise(FlowErrors.ThisParamMustBeFirst, {
8218
+ node
8219
+ });
8073
8220
  }
8074
8221
 
8075
8222
  name = this.parseIdentifier(isThis);
@@ -8078,7 +8225,9 @@ var flow = superClass => class extends superClass {
8078
8225
  optional = true;
8079
8226
 
8080
8227
  if (isThis) {
8081
- this.raise(node.start, FlowErrors.ThisParamMayNotBeOptional);
8228
+ this.raise(FlowErrors.ThisParamMayNotBeOptional, {
8229
+ node
8230
+ });
8082
8231
  }
8083
8232
  }
8084
8233
 
@@ -8271,7 +8420,9 @@ var flow = superClass => class extends superClass {
8271
8420
  return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
8272
8421
  }
8273
8422
 
8274
- throw this.raise(this.state.start, FlowErrors.UnexpectedSubtractionOperand);
8423
+ throw this.raise(FlowErrors.UnexpectedSubtractionOperand, {
8424
+ at: this.state.startLoc
8425
+ });
8275
8426
  }
8276
8427
 
8277
8428
  throw this.unexpected();
@@ -8443,7 +8594,7 @@ var flow = superClass => class extends superClass {
8443
8594
 
8444
8595
  typeCastToParameter(node) {
8445
8596
  node.expression.typeAnnotation = node.typeAnnotation;
8446
- this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
8597
+ this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
8447
8598
  return node.expression;
8448
8599
  }
8449
8600
 
@@ -8608,7 +8759,9 @@ var flow = superClass => class extends superClass {
8608
8759
  }
8609
8760
 
8610
8761
  if (failed && valid.length > 1) {
8611
- this.raise(state.start, FlowErrors.AmbiguousConditionalArrow);
8762
+ this.raise(FlowErrors.AmbiguousConditionalArrow, {
8763
+ at: state.startLoc
8764
+ });
8612
8765
  }
8613
8766
 
8614
8767
  if (failed && valid.length === 1) {
@@ -8674,7 +8827,7 @@ var flow = superClass => class extends superClass {
8674
8827
  finishArrowValidation(node) {
8675
8828
  var _node$extra;
8676
8829
 
8677
- this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingComma, false);
8830
+ this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
8678
8831
  this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
8679
8832
  super.checkParams(node, false, true);
8680
8833
  this.scope.exit();
@@ -8783,11 +8936,13 @@ var flow = superClass => class extends superClass {
8783
8936
  }
8784
8937
 
8785
8938
  maybeParseExportNamespaceSpecifier(node) {
8786
- var pos = this.state.start;
8939
+ var {
8940
+ startLoc
8941
+ } = this.state;
8787
8942
  var hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
8788
8943
 
8789
8944
  if (hasNamespace && node.exportKind === "type") {
8790
- this.unexpected(pos);
8945
+ this.unexpected(startLoc);
8791
8946
  }
8792
8947
 
8793
8948
  return hasNamespace;
@@ -8802,7 +8957,9 @@ var flow = superClass => class extends superClass {
8802
8957
  }
8803
8958
 
8804
8959
  parseClassMember(classBody, member, state) {
8805
- var pos = this.state.start;
8960
+ var {
8961
+ startLoc
8962
+ } = this.state;
8806
8963
 
8807
8964
  if (this.isContextual(117)) {
8808
8965
  if (this.parseClassMemberFromModifier(classBody, member)) {
@@ -8816,9 +8973,13 @@ var flow = superClass => class extends superClass {
8816
8973
 
8817
8974
  if (member.declare) {
8818
8975
  if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
8819
- this.raise(pos, FlowErrors.DeclareClassElement);
8976
+ this.raise(FlowErrors.DeclareClassElement, {
8977
+ at: startLoc
8978
+ });
8820
8979
  } else if (member.value) {
8821
- this.raise(member.value.start, FlowErrors.DeclareClassFieldInitializer);
8980
+ this.raise(FlowErrors.DeclareClassFieldInitializer, {
8981
+ node: member.value
8982
+ });
8822
8983
  }
8823
8984
  }
8824
8985
  }
@@ -8832,7 +8993,9 @@ var flow = superClass => class extends superClass {
8832
8993
  var fullWord = "@@" + word;
8833
8994
 
8834
8995
  if (!this.isIterator(word) || !this.state.inType) {
8835
- this.raise(this.state.pos, ErrorMessages.InvalidIdentifier, fullWord);
8996
+ this.raise(ErrorMessages.InvalidIdentifier, {
8997
+ at: this.state.curPosition()
8998
+ }, fullWord);
8836
8999
  }
8837
9000
 
8838
9001
  this.finishToken(124, fullWord);
@@ -8877,7 +9040,7 @@ var flow = superClass => class extends superClass {
8877
9040
  }
8878
9041
  }
8879
9042
 
8880
- toAssignableList(exprList, trailingCommaPos, isLHS) {
9043
+ toAssignableList(exprList, trailingCommaLoc, isLHS) {
8881
9044
  for (var i = 0; i < exprList.length; i++) {
8882
9045
  var expr = exprList[i];
8883
9046
 
@@ -8886,7 +9049,7 @@ var flow = superClass => class extends superClass {
8886
9049
  }
8887
9050
  }
8888
9051
 
8889
- return super.toAssignableList(exprList, trailingCommaPos, isLHS);
9052
+ return super.toAssignableList(exprList, trailingCommaLoc, isLHS);
8890
9053
  }
8891
9054
 
8892
9055
  toReferencedList(exprList, isParenthesizedExpr) {
@@ -8896,7 +9059,9 @@ var flow = superClass => class extends superClass {
8896
9059
  var expr = exprList[i];
8897
9060
 
8898
9061
  if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
8899
- this.raise(expr.typeAnnotation.start, FlowErrors.TypeCastInPattern);
9062
+ this.raise(FlowErrors.TypeCastInPattern, {
9063
+ node: expr.typeAnnotation
9064
+ });
8900
9065
  }
8901
9066
  }
8902
9067
 
@@ -8953,7 +9118,7 @@ var flow = superClass => class extends superClass {
8953
9118
 
8954
9119
  pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
8955
9120
  if (method.variance) {
8956
- this.unexpected(method.variance.start);
9121
+ this.unexpected(method.variance.loc.start);
8957
9122
  }
8958
9123
 
8959
9124
  delete method.variance;
@@ -8968,20 +9133,24 @@ var flow = superClass => class extends superClass {
8968
9133
  var params = method.params;
8969
9134
 
8970
9135
  if (params.length > 0 && this.isThisParam(params[0])) {
8971
- this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
9136
+ this.raise(FlowErrors.ThisParamBannedInConstructor, {
9137
+ node: method
9138
+ });
8972
9139
  }
8973
9140
  } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
8974
9141
  var _params2 = method.value.params;
8975
9142
 
8976
9143
  if (_params2.length > 0 && this.isThisParam(_params2[0])) {
8977
- this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
9144
+ this.raise(FlowErrors.ThisParamBannedInConstructor, {
9145
+ node: method
9146
+ });
8978
9147
  }
8979
9148
  }
8980
9149
  }
8981
9150
 
8982
9151
  pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
8983
9152
  if (method.variance) {
8984
- this.unexpected(method.variance.start);
9153
+ this.unexpected(method.variance.loc.start);
8985
9154
  }
8986
9155
 
8987
9156
  delete method.variance;
@@ -9028,9 +9197,13 @@ var flow = superClass => class extends superClass {
9028
9197
  var param = params[0];
9029
9198
 
9030
9199
  if (this.isThisParam(param) && method.kind === "get") {
9031
- this.raise(param.start, FlowErrors.GetterMayNotHaveThisParam);
9200
+ this.raise(FlowErrors.GetterMayNotHaveThisParam, {
9201
+ node: param
9202
+ });
9032
9203
  } else if (this.isThisParam(param)) {
9033
- this.raise(param.start, FlowErrors.SetterMayNotHaveThisParam);
9204
+ this.raise(FlowErrors.SetterMayNotHaveThisParam, {
9205
+ node: param
9206
+ });
9034
9207
  }
9035
9208
  }
9036
9209
  }
@@ -9041,7 +9214,7 @@ var flow = superClass => class extends superClass {
9041
9214
 
9042
9215
  parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
9043
9216
  if (prop.variance) {
9044
- this.unexpected(prop.variance.start);
9217
+ this.unexpected(prop.variance.loc.start);
9045
9218
  }
9046
9219
 
9047
9220
  delete prop.variance;
@@ -9062,11 +9235,15 @@ var flow = superClass => class extends superClass {
9062
9235
  parseAssignableListItemTypes(param) {
9063
9236
  if (this.eat(17)) {
9064
9237
  if (param.type !== "Identifier") {
9065
- this.raise(param.start, FlowErrors.PatternIsOptional);
9238
+ this.raise(FlowErrors.PatternIsOptional, {
9239
+ node: param
9240
+ });
9066
9241
  }
9067
9242
 
9068
9243
  if (this.isThisParam(param)) {
9069
- this.raise(param.start, FlowErrors.ThisParamMayNotBeOptional);
9244
+ this.raise(FlowErrors.ThisParamMayNotBeOptional, {
9245
+ node: param
9246
+ });
9070
9247
  }
9071
9248
 
9072
9249
  param.optional = true;
@@ -9075,11 +9252,15 @@ var flow = superClass => class extends superClass {
9075
9252
  if (this.match(14)) {
9076
9253
  param.typeAnnotation = this.flowParseTypeAnnotation();
9077
9254
  } else if (this.isThisParam(param)) {
9078
- this.raise(param.start, FlowErrors.ThisParamAnnotationRequired);
9255
+ this.raise(FlowErrors.ThisParamAnnotationRequired, {
9256
+ node: param
9257
+ });
9079
9258
  }
9080
9259
 
9081
9260
  if (this.match(29) && this.isThisParam(param)) {
9082
- this.raise(param.start, FlowErrors.ThisParamNoDefault);
9261
+ this.raise(FlowErrors.ThisParamNoDefault, {
9262
+ node: param
9263
+ });
9083
9264
  }
9084
9265
 
9085
9266
  this.resetEndLocation(param);
@@ -9090,7 +9271,9 @@ var flow = superClass => class extends superClass {
9090
9271
  var node = super.parseMaybeDefault(startPos, startLoc, left);
9091
9272
 
9092
9273
  if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
9093
- this.raise(node.typeAnnotation.start, FlowErrors.TypeBeforeInitializer);
9274
+ this.raise(FlowErrors.TypeBeforeInitializer, {
9275
+ node: node.typeAnnotation
9276
+ });
9094
9277
  }
9095
9278
 
9096
9279
  return node;
@@ -9127,7 +9310,7 @@ var flow = superClass => class extends superClass {
9127
9310
  } = lh;
9128
9311
 
9129
9312
  if (kind === "type" && type === 51) {
9130
- this.unexpected(lh.start);
9313
+ this.unexpected(null, lh.type);
9131
9314
  }
9132
9315
 
9133
9316
  if (isMaybeDefaultImport(type) || type === 5 || type === 51) {
@@ -9171,7 +9354,9 @@ var flow = superClass => class extends superClass {
9171
9354
  specifier.importKind = specifierTypeKind;
9172
9355
  } else {
9173
9356
  if (importedIsString) {
9174
- throw this.raise(specifier.start, ErrorMessages.ImportBindingIsString, firstIdent.value);
9357
+ throw this.raise(ErrorMessages.ImportBindingIsString, {
9358
+ node: specifier
9359
+ }, firstIdent.value);
9175
9360
  }
9176
9361
 
9177
9362
  specifier.imported = firstIdent;
@@ -9189,15 +9374,17 @@ var flow = superClass => class extends superClass {
9189
9374
  var specifierIsTypeImport = hasTypeImportKind(specifier);
9190
9375
 
9191
9376
  if (isInTypeOnlyImport && specifierIsTypeImport) {
9192
- this.raise(specifier.start, FlowErrors.ImportTypeShorthandOnlyInPureImport);
9377
+ this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, {
9378
+ node: specifier
9379
+ });
9193
9380
  }
9194
9381
 
9195
9382
  if (isInTypeOnlyImport || specifierIsTypeImport) {
9196
- this.checkReservedType(specifier.local.name, specifier.local.start, true);
9383
+ this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
9197
9384
  }
9198
9385
 
9199
9386
  if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
9200
- this.checkReservedWord(specifier.local.name, specifier.start, true, true);
9387
+ this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
9201
9388
  }
9202
9389
 
9203
9390
  this.checkLVal(specifier.local, "import specifier", BIND_LEXICAL);
@@ -9294,7 +9481,9 @@ var flow = superClass => class extends superClass {
9294
9481
  if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
9295
9482
  if (!arrow.error && !arrow.aborted) {
9296
9483
  if (arrow.node.async) {
9297
- this.raise(typeParameters.start, FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction);
9484
+ this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, {
9485
+ node: typeParameters
9486
+ });
9298
9487
  }
9299
9488
 
9300
9489
  return arrow.node;
@@ -9315,7 +9504,9 @@ var flow = superClass => class extends superClass {
9315
9504
 
9316
9505
  if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
9317
9506
  if (arrow.thrown) throw arrow.error;
9318
- throw this.raise(typeParameters.start, FlowErrors.UnexpectedTokenAfterTypeParameter);
9507
+ throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, {
9508
+ node: typeParameters
9509
+ });
9319
9510
  }
9320
9511
 
9321
9512
  return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
@@ -9360,7 +9551,9 @@ var flow = superClass => class extends superClass {
9360
9551
 
9361
9552
  for (var i = 0; i < node.params.length; i++) {
9362
9553
  if (this.isThisParam(node.params[i]) && i > 0) {
9363
- this.raise(node.params[i].start, FlowErrors.ThisParamMustBeFirst);
9554
+ this.raise(FlowErrors.ThisParamMustBeFirst, {
9555
+ node: node.params[i]
9556
+ });
9364
9557
  }
9365
9558
  }
9366
9559
 
@@ -9485,7 +9678,9 @@ var flow = superClass => class extends superClass {
9485
9678
  var fileNode = super.parseTopLevel(file, program);
9486
9679
 
9487
9680
  if (this.state.hasFlowComment) {
9488
- this.raise(this.state.pos, FlowErrors.UnterminatedFlowComment);
9681
+ this.raise(FlowErrors.UnterminatedFlowComment, {
9682
+ at: this.state.curPosition()
9683
+ });
9489
9684
  }
9490
9685
 
9491
9686
  return fileNode;
@@ -9494,7 +9689,9 @@ var flow = superClass => class extends superClass {
9494
9689
  skipBlockComment() {
9495
9690
  if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
9496
9691
  if (this.state.hasFlowComment) {
9497
- this.unexpected(null, FlowErrors.NestedFlowComment);
9692
+ throw this.raise(FlowErrors.NestedFlowComment, {
9693
+ at: this.state.startLoc
9694
+ });
9498
9695
  }
9499
9696
 
9500
9697
  this.hasFlowCommentCompletion();
@@ -9504,13 +9701,15 @@ var flow = superClass => class extends superClass {
9504
9701
  }
9505
9702
 
9506
9703
  if (this.state.hasFlowComment) {
9507
- var end = this.input.indexOf("*-/", this.state.pos += 2);
9704
+ var end = this.input.indexOf("*-/", this.state.pos + 2);
9508
9705
 
9509
9706
  if (end === -1) {
9510
- throw this.raise(this.state.pos - 2, ErrorMessages.UnterminatedComment);
9707
+ throw this.raise(ErrorMessages.UnterminatedComment, {
9708
+ at: this.state.curPosition()
9709
+ });
9511
9710
  }
9512
9711
 
9513
- this.state.pos = end + 3;
9712
+ this.state.pos = end + 2 + 3;
9514
9713
  return;
9515
9714
  }
9516
9715
 
@@ -9549,93 +9748,64 @@ var flow = superClass => class extends superClass {
9549
9748
  var end = this.input.indexOf("*/", this.state.pos);
9550
9749
 
9551
9750
  if (end === -1) {
9552
- throw this.raise(this.state.pos, ErrorMessages.UnterminatedComment);
9751
+ throw this.raise(ErrorMessages.UnterminatedComment, {
9752
+ at: this.state.curPosition()
9753
+ });
9553
9754
  }
9554
9755
  }
9555
9756
 
9556
- flowEnumErrorBooleanMemberNotInitialized(pos, _ref6) {
9557
- var {
9558
- enumName,
9559
- memberName
9560
- } = _ref6;
9561
- this.raise(pos, FlowErrors.EnumBooleanMemberNotInitialized, memberName, enumName);
9562
- }
9563
-
9564
- flowEnumErrorInvalidMemberName(pos, _ref7) {
9565
- var {
9566
- enumName,
9567
- memberName
9568
- } = _ref7;
9569
- var suggestion = memberName[0].toUpperCase() + memberName.slice(1);
9570
- this.raise(pos, FlowErrors.EnumInvalidMemberName, memberName, suggestion, enumName);
9571
- }
9572
-
9573
- flowEnumErrorDuplicateMemberName(pos, _ref8) {
9757
+ flowEnumErrorBooleanMemberNotInitialized(loc, _ref8) {
9574
9758
  var {
9575
9759
  enumName,
9576
9760
  memberName
9577
9761
  } = _ref8;
9578
- this.raise(pos, FlowErrors.EnumDuplicateMemberName, memberName, enumName);
9579
- }
9580
-
9581
- flowEnumErrorInconsistentMemberValues(pos, _ref9) {
9582
- var {
9583
- enumName
9584
- } = _ref9;
9585
- this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName);
9762
+ this.raise(FlowErrors.EnumBooleanMemberNotInitialized, {
9763
+ at: loc
9764
+ }, memberName, enumName);
9586
9765
  }
9587
9766
 
9588
- flowEnumErrorInvalidExplicitType(pos, _ref10) {
9767
+ flowEnumErrorInvalidExplicitType(loc, _ref9) {
9589
9768
  var {
9590
9769
  enumName,
9591
9770
  suppliedType
9592
- } = _ref10;
9593
- return this.raise(pos, suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, enumName, suppliedType);
9771
+ } = _ref9;
9772
+ return this.raise(suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, {
9773
+ at: loc
9774
+ }, enumName, suppliedType);
9594
9775
  }
9595
9776
 
9596
- flowEnumErrorInvalidMemberInitializer(pos, _ref11) {
9777
+ flowEnumErrorInvalidMemberInitializer(loc, _ref10) {
9597
9778
  var {
9598
9779
  enumName,
9599
9780
  explicitType,
9600
9781
  memberName
9601
- } = _ref11;
9602
- var message = null;
9603
-
9604
- switch (explicitType) {
9605
- case "boolean":
9606
- case "number":
9607
- case "string":
9608
- message = FlowErrors.EnumInvalidMemberInitializerPrimaryType;
9609
- break;
9610
-
9611
- case "symbol":
9612
- message = FlowErrors.EnumInvalidMemberInitializerSymbolType;
9613
- break;
9614
-
9615
- default:
9616
- message = FlowErrors.EnumInvalidMemberInitializerUnknownType;
9617
- }
9618
-
9619
- return this.raise(pos, message, enumName, memberName, explicitType);
9782
+ } = _ref10;
9783
+ return this.raise(explicitType === "boolean" || explicitType === "number" || explicitType === "string" ? FlowErrors.EnumInvalidMemberInitializerPrimaryType : explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerUnknownType, {
9784
+ at: loc
9785
+ }, enumName, memberName, explicitType);
9620
9786
  }
9621
9787
 
9622
- flowEnumErrorNumberMemberNotInitialized(pos, _ref12) {
9788
+ flowEnumErrorNumberMemberNotInitialized(loc, _ref11) {
9623
9789
  var {
9624
9790
  enumName,
9625
9791
  memberName
9626
- } = _ref12;
9627
- this.raise(pos, FlowErrors.EnumNumberMemberNotInitialized, enumName, memberName);
9792
+ } = _ref11;
9793
+ this.raise(FlowErrors.EnumNumberMemberNotInitialized, {
9794
+ at: loc
9795
+ }, enumName, memberName);
9628
9796
  }
9629
9797
 
9630
- flowEnumErrorStringMemberInconsistentlyInitailized(pos, _ref13) {
9798
+ flowEnumErrorStringMemberInconsistentlyInitailized(node, _ref12) {
9631
9799
  var {
9632
9800
  enumName
9633
- } = _ref13;
9634
- this.raise(pos, FlowErrors.EnumStringMemberInconsistentlyInitailized, enumName);
9801
+ } = _ref12;
9802
+ this.raise(FlowErrors.EnumStringMemberInconsistentlyInitailized, {
9803
+ node
9804
+ }, enumName);
9635
9805
  }
9636
9806
 
9637
9807
  flowEnumMemberInit() {
9638
- var startPos = this.state.start;
9808
+ var startLoc = this.state.startLoc;
9639
9809
 
9640
9810
  var endOfInit = () => this.match(12) || this.match(8);
9641
9811
 
@@ -9647,14 +9817,14 @@ var flow = superClass => class extends superClass {
9647
9817
  if (endOfInit()) {
9648
9818
  return {
9649
9819
  type: "number",
9650
- pos: literal.start,
9820
+ loc: literal.loc.start,
9651
9821
  value: literal
9652
9822
  };
9653
9823
  }
9654
9824
 
9655
9825
  return {
9656
9826
  type: "invalid",
9657
- pos: startPos
9827
+ loc: startLoc
9658
9828
  };
9659
9829
  }
9660
9830
 
@@ -9665,14 +9835,14 @@ var flow = superClass => class extends superClass {
9665
9835
  if (endOfInit()) {
9666
9836
  return {
9667
9837
  type: "string",
9668
- pos: _literal.start,
9838
+ loc: _literal.loc.start,
9669
9839
  value: _literal
9670
9840
  };
9671
9841
  }
9672
9842
 
9673
9843
  return {
9674
9844
  type: "invalid",
9675
- pos: startPos
9845
+ loc: startLoc
9676
9846
  };
9677
9847
  }
9678
9848
 
@@ -9684,31 +9854,31 @@ var flow = superClass => class extends superClass {
9684
9854
  if (endOfInit()) {
9685
9855
  return {
9686
9856
  type: "boolean",
9687
- pos: _literal2.start,
9857
+ loc: _literal2.loc.start,
9688
9858
  value: _literal2
9689
9859
  };
9690
9860
  }
9691
9861
 
9692
9862
  return {
9693
9863
  type: "invalid",
9694
- pos: startPos
9864
+ loc: startLoc
9695
9865
  };
9696
9866
  }
9697
9867
 
9698
9868
  default:
9699
9869
  return {
9700
9870
  type: "invalid",
9701
- pos: startPos
9871
+ loc: startLoc
9702
9872
  };
9703
9873
  }
9704
9874
  }
9705
9875
 
9706
9876
  flowEnumMemberRaw() {
9707
- var pos = this.state.start;
9877
+ var loc = this.state.startLoc;
9708
9878
  var id = this.parseIdentifier(true);
9709
9879
  var init = this.eat(29) ? this.flowEnumMemberInit() : {
9710
9880
  type: "none",
9711
- pos
9881
+ loc
9712
9882
  };
9713
9883
  return {
9714
9884
  id,
@@ -9716,7 +9886,7 @@ var flow = superClass => class extends superClass {
9716
9886
  };
9717
9887
  }
9718
9888
 
9719
- flowEnumCheckExplicitTypeMismatch(pos, context, expectedType) {
9889
+ flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
9720
9890
  var {
9721
9891
  explicitType
9722
9892
  } = context;
@@ -9726,15 +9896,15 @@ var flow = superClass => class extends superClass {
9726
9896
  }
9727
9897
 
9728
9898
  if (explicitType !== expectedType) {
9729
- this.flowEnumErrorInvalidMemberInitializer(pos, context);
9899
+ this.flowEnumErrorInvalidMemberInitializer(loc, context);
9730
9900
  }
9731
9901
  }
9732
9902
 
9733
- flowEnumMembers(_ref14) {
9903
+ flowEnumMembers(_ref13) {
9734
9904
  var {
9735
9905
  enumName,
9736
9906
  explicitType
9737
- } = _ref14;
9907
+ } = _ref13;
9738
9908
  var seenNames = new Set();
9739
9909
  var members = {
9740
9910
  booleanMembers: [],
@@ -9762,17 +9932,15 @@ var flow = superClass => class extends superClass {
9762
9932
  }
9763
9933
 
9764
9934
  if (/^[a-z]/.test(memberName)) {
9765
- this.flowEnumErrorInvalidMemberName(id.start, {
9766
- enumName,
9767
- memberName
9768
- });
9935
+ this.raise(FlowErrors.EnumInvalidMemberName, {
9936
+ node: id
9937
+ }, memberName, memberName[0].toUpperCase() + memberName.slice(1), enumName);
9769
9938
  }
9770
9939
 
9771
9940
  if (seenNames.has(memberName)) {
9772
- this.flowEnumErrorDuplicateMemberName(id.start, {
9773
- enumName,
9774
- memberName
9775
- });
9941
+ this.raise(FlowErrors.EnumDuplicateMemberName, {
9942
+ node: id
9943
+ }, memberName, enumName);
9776
9944
  }
9777
9945
 
9778
9946
  seenNames.add(memberName);
@@ -9786,7 +9954,7 @@ var flow = superClass => class extends superClass {
9786
9954
  switch (init.type) {
9787
9955
  case "boolean":
9788
9956
  {
9789
- this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "boolean");
9957
+ this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
9790
9958
  memberNode.init = init.value;
9791
9959
  members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
9792
9960
  break;
@@ -9794,7 +9962,7 @@ var flow = superClass => class extends superClass {
9794
9962
 
9795
9963
  case "number":
9796
9964
  {
9797
- this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "number");
9965
+ this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
9798
9966
  memberNode.init = init.value;
9799
9967
  members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
9800
9968
  break;
@@ -9802,7 +9970,7 @@ var flow = superClass => class extends superClass {
9802
9970
 
9803
9971
  case "string":
9804
9972
  {
9805
- this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "string");
9973
+ this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
9806
9974
  memberNode.init = init.value;
9807
9975
  members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
9808
9976
  break;
@@ -9810,18 +9978,18 @@ var flow = superClass => class extends superClass {
9810
9978
 
9811
9979
  case "invalid":
9812
9980
  {
9813
- throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context);
9981
+ throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
9814
9982
  }
9815
9983
 
9816
9984
  case "none":
9817
9985
  {
9818
9986
  switch (explicitType) {
9819
9987
  case "boolean":
9820
- this.flowEnumErrorBooleanMemberNotInitialized(init.pos, context);
9988
+ this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
9821
9989
  break;
9822
9990
 
9823
9991
  case "number":
9824
- this.flowEnumErrorNumberMemberNotInitialized(init.pos, context);
9992
+ this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
9825
9993
  break;
9826
9994
 
9827
9995
  default:
@@ -9841,10 +10009,10 @@ var flow = superClass => class extends superClass {
9841
10009
  };
9842
10010
  }
9843
10011
 
9844
- flowEnumStringMembers(initializedMembers, defaultedMembers, _ref15) {
10012
+ flowEnumStringMembers(initializedMembers, defaultedMembers, _ref14) {
9845
10013
  var {
9846
10014
  enumName
9847
- } = _ref15;
10015
+ } = _ref14;
9848
10016
 
9849
10017
  if (initializedMembers.length === 0) {
9850
10018
  return defaultedMembers;
@@ -9852,7 +10020,7 @@ var flow = superClass => class extends superClass {
9852
10020
  return initializedMembers;
9853
10021
  } else if (defaultedMembers.length > initializedMembers.length) {
9854
10022
  for (var member of initializedMembers) {
9855
- this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, {
10023
+ this.flowEnumErrorStringMemberInconsistentlyInitailized(member, {
9856
10024
  enumName
9857
10025
  });
9858
10026
  }
@@ -9860,7 +10028,7 @@ var flow = superClass => class extends superClass {
9860
10028
  return defaultedMembers;
9861
10029
  } else {
9862
10030
  for (var _member of defaultedMembers) {
9863
- this.flowEnumErrorStringMemberInconsistentlyInitailized(_member.start, {
10031
+ this.flowEnumErrorStringMemberInconsistentlyInitailized(_member, {
9864
10032
  enumName
9865
10033
  });
9866
10034
  }
@@ -9869,14 +10037,14 @@ var flow = superClass => class extends superClass {
9869
10037
  }
9870
10038
  }
9871
10039
 
9872
- flowEnumParseExplicitType(_ref16) {
10040
+ flowEnumParseExplicitType(_ref15) {
9873
10041
  var {
9874
10042
  enumName
9875
- } = _ref16;
10043
+ } = _ref15;
9876
10044
 
9877
10045
  if (this.eatContextual(97)) {
9878
10046
  if (!tokenIsIdentifier(this.state.type)) {
9879
- throw this.flowEnumErrorInvalidExplicitType(this.state.start, {
10047
+ throw this.flowEnumErrorInvalidExplicitType(this.state.startLoc, {
9880
10048
  enumName,
9881
10049
  suppliedType: null
9882
10050
  });
@@ -9888,7 +10056,7 @@ var flow = superClass => class extends superClass {
9888
10056
  this.next();
9889
10057
 
9890
10058
  if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
9891
- this.flowEnumErrorInvalidExplicitType(this.state.start, {
10059
+ this.flowEnumErrorInvalidExplicitType(this.state.startLoc, {
9892
10060
  enumName,
9893
10061
  suppliedType: value
9894
10062
  });
@@ -9900,11 +10068,9 @@ var flow = superClass => class extends superClass {
9900
10068
  return null;
9901
10069
  }
9902
10070
 
9903
- flowEnumBody(node, _ref17) {
9904
- var {
9905
- enumName,
9906
- nameLoc
9907
- } = _ref17;
10071
+ flowEnumBody(node, id) {
10072
+ var enumName = id.name;
10073
+ var nameLoc = id.loc.start;
9908
10074
  var explicitType = this.flowEnumParseExplicitType({
9909
10075
  enumName
9910
10076
  });
@@ -9968,7 +10134,7 @@ var flow = superClass => class extends superClass {
9968
10134
  return this.finishNode(node, "EnumStringBody");
9969
10135
  } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
9970
10136
  for (var member of members.defaultedMembers) {
9971
- this.flowEnumErrorBooleanMemberNotInitialized(member.start, {
10137
+ this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
9972
10138
  enumName,
9973
10139
  memberName: member.id.name
9974
10140
  });
@@ -9979,7 +10145,7 @@ var flow = superClass => class extends superClass {
9979
10145
  return this.finishNode(node, "EnumBooleanBody");
9980
10146
  } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
9981
10147
  for (var _member2 of members.defaultedMembers) {
9982
- this.flowEnumErrorNumberMemberNotInitialized(_member2.start, {
10148
+ this.flowEnumErrorNumberMemberNotInitialized(_member2.loc.start, {
9983
10149
  enumName,
9984
10150
  memberName: _member2.id.name
9985
10151
  });
@@ -9989,9 +10155,9 @@ var flow = superClass => class extends superClass {
9989
10155
  this.expect(8);
9990
10156
  return this.finishNode(node, "EnumNumberBody");
9991
10157
  } else {
9992
- this.flowEnumErrorInconsistentMemberValues(nameLoc, {
9993
- enumName
9994
- });
10158
+ this.raise(FlowErrors.EnumInconsistentMemberValues, {
10159
+ at: nameLoc
10160
+ }, enumName);
9995
10161
  return empty();
9996
10162
  }
9997
10163
  }
@@ -10001,10 +10167,7 @@ var flow = superClass => class extends superClass {
10001
10167
  flowParseEnumDeclaration(node) {
10002
10168
  var id = this.parseIdentifier();
10003
10169
  node.id = id;
10004
- node.body = this.flowEnumBody(this.startNode(), {
10005
- enumName: id.name,
10006
- nameLoc: id.start
10007
- });
10170
+ node.body = this.flowEnumBody(this.startNode(), id);
10008
10171
  return this.finishNode(node, "EnumDeclaration");
10009
10172
  }
10010
10173
 
@@ -10319,7 +10482,9 @@ var jsx = superClass => class extends superClass {
10319
10482
 
10320
10483
  for (;;) {
10321
10484
  if (this.state.pos >= this.length) {
10322
- throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent);
10485
+ throw this.raise(JsxErrors.UnterminatedJsxContent, {
10486
+ at: this.state.startLoc
10487
+ });
10323
10488
  }
10324
10489
 
10325
10490
  var ch = this.input.charCodeAt(this.state.pos);
@@ -10383,7 +10548,9 @@ var jsx = superClass => class extends superClass {
10383
10548
 
10384
10549
  for (;;) {
10385
10550
  if (this.state.pos >= this.length) {
10386
- throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
10551
+ throw this.raise(ErrorMessages.UnterminatedString, {
10552
+ at: this.state.startLoc
10553
+ });
10387
10554
  }
10388
10555
 
10389
10556
  var ch = this.input.charCodeAt(this.state.pos);
@@ -10516,7 +10683,9 @@ var jsx = superClass => class extends superClass {
10516
10683
  node = this.jsxParseExpressionContainer(node, types.j_oTag);
10517
10684
 
10518
10685
  if (node.expression.type === "JSXEmptyExpression") {
10519
- this.raise(node.start, JsxErrors.AttributeIsEmpty);
10686
+ this.raise(JsxErrors.AttributeIsEmpty, {
10687
+ node
10688
+ });
10520
10689
  }
10521
10690
 
10522
10691
  return node;
@@ -10526,13 +10695,15 @@ var jsx = superClass => class extends superClass {
10526
10695
  return this.parseExprAtom();
10527
10696
 
10528
10697
  default:
10529
- throw this.raise(this.state.start, JsxErrors.UnsupportedJsxValue);
10698
+ throw this.raise(JsxErrors.UnsupportedJsxValue, {
10699
+ at: this.state.startLoc
10700
+ });
10530
10701
  }
10531
10702
  }
10532
10703
 
10533
10704
  jsxParseEmptyExpression() {
10534
- var node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc);
10535
- return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc);
10705
+ var node = this.startNodeAt(indexes.get(this.state.lastTokEndLoc), this.state.lastTokEndLoc);
10706
+ return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
10536
10707
  }
10537
10708
 
10538
10709
  jsxParseSpreadChild(node) {
@@ -10659,13 +10830,19 @@ var jsx = superClass => class extends superClass {
10659
10830
  }
10660
10831
  }
10661
10832
 
10662
- if (isFragment(openingElement) && !isFragment(closingElement)) {
10663
- this.raise(closingElement.start, JsxErrors.MissingClosingTagFragment);
10833
+ if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
10834
+ this.raise(JsxErrors.MissingClosingTagFragment, {
10835
+ node: closingElement
10836
+ });
10664
10837
  } else if (!isFragment(openingElement) && isFragment(closingElement)) {
10665
- this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
10838
+ this.raise(JsxErrors.MissingClosingTagElement, {
10839
+ node: closingElement
10840
+ }, getQualifiedJSXName(openingElement.name));
10666
10841
  } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
10667
10842
  if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
10668
- this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
10843
+ this.raise(JsxErrors.MissingClosingTagElement, {
10844
+ node: closingElement
10845
+ }, getQualifiedJSXName(openingElement.name));
10669
10846
  }
10670
10847
  }
10671
10848
  }
@@ -10681,7 +10858,9 @@ var jsx = superClass => class extends superClass {
10681
10858
  node.children = children;
10682
10859
 
10683
10860
  if (this.match(45)) {
10684
- throw this.raise(this.state.start, JsxErrors.UnwrappedAdjacentJSXElements);
10861
+ throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, {
10862
+ at: this.state.startLoc
10863
+ });
10685
10864
  }
10686
10865
 
10687
10866
  return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
@@ -10794,7 +10973,7 @@ class TypeScriptScopeHandler extends ScopeHandler {
10794
10973
  return new TypeScriptScope(flags);
10795
10974
  }
10796
10975
 
10797
- declareName(name, bindingType, pos) {
10976
+ declareName(name, bindingType, loc) {
10798
10977
  var scope = this.currentScope();
10799
10978
 
10800
10979
  if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {
@@ -10807,7 +10986,7 @@ class TypeScriptScopeHandler extends ScopeHandler {
10807
10986
 
10808
10987
  if (bindingType & BIND_KIND_TYPE) {
10809
10988
  if (!(bindingType & BIND_KIND_VALUE)) {
10810
- this.checkRedeclarationInScope(scope, name, bindingType, pos);
10989
+ this.checkRedeclarationInScope(scope, name, bindingType, loc);
10811
10990
  this.maybeExportDefined(scope, name);
10812
10991
  }
10813
10992
 
@@ -11008,49 +11187,61 @@ var typescript = superClass => class extends superClass {
11008
11187
  }
11009
11188
 
11010
11189
  tsParseModifiers(modified, allowedModifiers, disallowedModifiers, errorTemplate, stopOnStartOfClassStaticBlock) {
11011
- var enforceOrder = (pos, modifier, before, after) => {
11190
+ var enforceOrder = (loc, modifier, before, after) => {
11012
11191
  if (modifier === before && modified[after]) {
11013
- this.raise(pos, TSErrors.InvalidModifiersOrder, before, after);
11192
+ this.raise(TSErrors.InvalidModifiersOrder, {
11193
+ at: loc
11194
+ }, before, after);
11014
11195
  }
11015
11196
  };
11016
11197
 
11017
- var incompatible = (pos, modifier, mod1, mod2) => {
11198
+ var incompatible = (loc, modifier, mod1, mod2) => {
11018
11199
  if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
11019
- this.raise(pos, TSErrors.IncompatibleModifiers, mod1, mod2);
11200
+ this.raise(TSErrors.IncompatibleModifiers, {
11201
+ at: loc
11202
+ }, mod1, mod2);
11020
11203
  }
11021
11204
  };
11022
11205
 
11023
11206
  for (;;) {
11024
- var startPos = this.state.start;
11207
+ var {
11208
+ startLoc
11209
+ } = this.state;
11025
11210
  var modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
11026
11211
  if (!modifier) break;
11027
11212
 
11028
11213
  if (tsIsAccessModifier(modifier)) {
11029
11214
  if (modified.accessibility) {
11030
- this.raise(startPos, TSErrors.DuplicateAccessibilityModifier);
11215
+ this.raise(TSErrors.DuplicateAccessibilityModifier, {
11216
+ at: startLoc
11217
+ });
11031
11218
  } else {
11032
- enforceOrder(startPos, modifier, modifier, "override");
11033
- enforceOrder(startPos, modifier, modifier, "static");
11034
- enforceOrder(startPos, modifier, modifier, "readonly");
11219
+ enforceOrder(startLoc, modifier, modifier, "override");
11220
+ enforceOrder(startLoc, modifier, modifier, "static");
11221
+ enforceOrder(startLoc, modifier, modifier, "readonly");
11035
11222
  modified.accessibility = modifier;
11036
11223
  }
11037
11224
  } else {
11038
11225
  if (Object.hasOwnProperty.call(modified, modifier)) {
11039
- this.raise(startPos, TSErrors.DuplicateModifier, modifier);
11226
+ this.raise(TSErrors.DuplicateModifier, {
11227
+ at: startLoc
11228
+ }, modifier);
11040
11229
  } else {
11041
- enforceOrder(startPos, modifier, "static", "readonly");
11042
- enforceOrder(startPos, modifier, "static", "override");
11043
- enforceOrder(startPos, modifier, "override", "readonly");
11044
- enforceOrder(startPos, modifier, "abstract", "override");
11045
- incompatible(startPos, modifier, "declare", "override");
11046
- incompatible(startPos, modifier, "static", "abstract");
11230
+ enforceOrder(startLoc, modifier, "static", "readonly");
11231
+ enforceOrder(startLoc, modifier, "static", "override");
11232
+ enforceOrder(startLoc, modifier, "override", "readonly");
11233
+ enforceOrder(startLoc, modifier, "abstract", "override");
11234
+ incompatible(startLoc, modifier, "declare", "override");
11235
+ incompatible(startLoc, modifier, "static", "abstract");
11047
11236
  }
11048
11237
 
11049
11238
  modified[modifier] = true;
11050
11239
  }
11051
11240
 
11052
11241
  if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
11053
- this.raise(startPos, errorTemplate, modifier);
11242
+ this.raise(errorTemplate, {
11243
+ at: startLoc
11244
+ }, modifier);
11054
11245
  }
11055
11246
  }
11056
11247
  }
@@ -11155,7 +11346,9 @@ var typescript = superClass => class extends superClass {
11155
11346
  this.expect(10);
11156
11347
 
11157
11348
  if (!this.match(125)) {
11158
- this.raise(this.state.start, TSErrors.UnsupportedImportTypeArgument);
11349
+ this.raise(TSErrors.UnsupportedImportTypeArgument, {
11350
+ at: this.state.startLoc
11351
+ });
11159
11352
  }
11160
11353
 
11161
11354
  node.argument = this.parseExprAtom();
@@ -11253,7 +11446,9 @@ var typescript = superClass => class extends superClass {
11253
11446
  node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true, refTrailingCommaPos);
11254
11447
 
11255
11448
  if (node.params.length === 0) {
11256
- this.raise(node.start, TSErrors.EmptyTypeParameters);
11449
+ this.raise(TSErrors.EmptyTypeParameters, {
11450
+ node
11451
+ });
11257
11452
  }
11258
11453
 
11259
11454
  if (refTrailingCommaPos.value !== -1) {
@@ -11274,21 +11469,25 @@ var typescript = superClass => class extends superClass {
11274
11469
 
11275
11470
  tsFillSignature(returnToken, signature) {
11276
11471
  var returnTokenRequired = returnToken === 19;
11472
+ var paramsKey = "parameters";
11473
+ var returnTypeKey = "typeAnnotation";
11277
11474
  signature.typeParameters = this.tsTryParseTypeParameters();
11278
11475
  this.expect(10);
11279
- signature.parameters = this.tsParseBindingListForSignature();
11476
+ signature[paramsKey] = this.tsParseBindingListForSignature();
11280
11477
 
11281
11478
  if (returnTokenRequired) {
11282
- signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
11479
+ signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
11283
11480
  } else if (this.match(returnToken)) {
11284
- signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
11481
+ signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
11285
11482
  }
11286
11483
  }
11287
11484
 
11288
11485
  tsParseBindingListForSignature() {
11289
11486
  return this.parseBindingList(11, 41).map(pattern => {
11290
11487
  if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") {
11291
- this.raise(pattern.start, TSErrors.UnsupportedSignatureParameterKind, pattern.type);
11488
+ this.raise(TSErrors.UnsupportedSignatureParameterKind, {
11489
+ node: pattern
11490
+ }, pattern.type);
11292
11491
  }
11293
11492
 
11294
11493
  return pattern;
@@ -11341,47 +11540,67 @@ var typescript = superClass => class extends superClass {
11341
11540
 
11342
11541
  if (this.match(10) || this.match(45)) {
11343
11542
  if (readonly) {
11344
- this.raise(node.start, TSErrors.ReadonlyForMethodSignature);
11543
+ this.raise(TSErrors.ReadonlyForMethodSignature, {
11544
+ node
11545
+ });
11345
11546
  }
11346
11547
 
11347
11548
  var method = nodeAny;
11348
11549
 
11349
11550
  if (method.kind && this.match(45)) {
11350
- this.raise(this.state.pos, TSErrors.AccesorCannotHaveTypeParameters);
11551
+ this.raise(TSErrors.AccesorCannotHaveTypeParameters, {
11552
+ at: this.state.curPosition()
11553
+ });
11351
11554
  }
11352
11555
 
11353
11556
  this.tsFillSignature(14, method);
11354
11557
  this.tsParseTypeMemberSemicolon();
11558
+ var paramsKey = "parameters";
11559
+ var returnTypeKey = "typeAnnotation";
11355
11560
 
11356
11561
  if (method.kind === "get") {
11357
- if (method.parameters.length > 0) {
11358
- this.raise(this.state.pos, ErrorMessages.BadGetterArity);
11562
+ if (method[paramsKey].length > 0) {
11563
+ this.raise(ErrorMessages.BadGetterArity, {
11564
+ at: this.state.curPosition()
11565
+ });
11359
11566
 
11360
- if (this.isThisParam(method.parameters[0])) {
11361
- this.raise(this.state.pos, TSErrors.AccesorCannotDeclareThisParameter);
11567
+ if (this.isThisParam(method[paramsKey][0])) {
11568
+ this.raise(TSErrors.AccesorCannotDeclareThisParameter, {
11569
+ at: this.state.curPosition()
11570
+ });
11362
11571
  }
11363
11572
  }
11364
11573
  } else if (method.kind === "set") {
11365
- if (method.parameters.length !== 1) {
11366
- this.raise(this.state.pos, ErrorMessages.BadSetterArity);
11574
+ if (method[paramsKey].length !== 1) {
11575
+ this.raise(ErrorMessages.BadSetterArity, {
11576
+ at: this.state.curPosition()
11577
+ });
11367
11578
  } else {
11368
- var firstParameter = method.parameters[0];
11579
+ var firstParameter = method[paramsKey][0];
11369
11580
 
11370
11581
  if (this.isThisParam(firstParameter)) {
11371
- this.raise(this.state.pos, TSErrors.AccesorCannotDeclareThisParameter);
11582
+ this.raise(TSErrors.AccesorCannotDeclareThisParameter, {
11583
+ at: this.state.curPosition()
11584
+ });
11372
11585
  }
11373
11586
 
11374
11587
  if (firstParameter.type === "Identifier" && firstParameter.optional) {
11375
- this.raise(this.state.pos, TSErrors.SetAccesorCannotHaveOptionalParameter);
11588
+ this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, {
11589
+ at: this.state.curPosition()
11590
+ });
11376
11591
  }
11377
11592
 
11378
11593
  if (firstParameter.type === "RestElement") {
11379
- this.raise(this.state.pos, TSErrors.SetAccesorCannotHaveRestParameter);
11594
+ this.raise(TSErrors.SetAccesorCannotHaveRestParameter, {
11595
+ at: this.state.curPosition()
11596
+ });
11380
11597
  }
11381
11598
  }
11382
11599
 
11383
- if (method.typeAnnotation) {
11384
- this.raise(method.typeAnnotation.start, TSErrors.SetAccesorCannotHaveReturnType);
11600
+ if (method[returnTypeKey]) {
11601
+ this.raise(TSErrors.SetAccesorCannotHaveReturnType, {
11602
+ node: method[returnTypeKey]
11603
+ });
11385
11604
  }
11386
11605
  } else {
11387
11606
  method.kind = "method";
@@ -11523,7 +11742,9 @@ var typescript = superClass => class extends superClass {
11523
11742
  } = elementNode;
11524
11743
 
11525
11744
  if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
11526
- this.raise(elementNode.start, TSErrors.OptionalTypeBeforeRequired);
11745
+ this.raise(TSErrors.OptionalTypeBeforeRequired, {
11746
+ node: elementNode
11747
+ });
11527
11748
  }
11528
11749
 
11529
11750
  seenOptionalElement = seenOptionalElement || type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType";
@@ -11537,7 +11758,9 @@ var typescript = superClass => class extends superClass {
11537
11758
  labeledElements = (_labeledElements = labeledElements) != null ? _labeledElements : isLabeled;
11538
11759
 
11539
11760
  if (labeledElements !== isLabeled) {
11540
- this.raise(elementNode.start, TSErrors.MixedLabeledAndUnlabeledElements);
11761
+ this.raise(TSErrors.MixedLabeledAndUnlabeledElements, {
11762
+ node: elementNode
11763
+ });
11541
11764
  }
11542
11765
  });
11543
11766
  return this.finishNode(node, "TSTupleType");
@@ -11560,7 +11783,9 @@ var typescript = superClass => class extends superClass {
11560
11783
  if (type.type === "TSTypeReference" && !type.typeParameters && type.typeName.type === "Identifier") {
11561
11784
  labeledNode.label = type.typeName;
11562
11785
  } else {
11563
- this.raise(type.start, TSErrors.InvalidTupleMemberLabel);
11786
+ this.raise(TSErrors.InvalidTupleMemberLabel, {
11787
+ node: type
11788
+ });
11564
11789
  labeledNode.label = type;
11565
11790
  }
11566
11791
 
@@ -11756,7 +11981,9 @@ var typescript = superClass => class extends superClass {
11756
11981
  return;
11757
11982
 
11758
11983
  default:
11759
- this.raise(node.start, TSErrors.UnexpectedReadonly);
11984
+ this.raise(TSErrors.UnexpectedReadonly, {
11985
+ node
11986
+ });
11760
11987
  }
11761
11988
  }
11762
11989
 
@@ -11955,7 +12182,9 @@ var typescript = superClass => class extends superClass {
11955
12182
  }
11956
12183
 
11957
12184
  if (containsEsc) {
11958
- this.raise(this.state.lastTokStart, ErrorMessages.InvalidEscapedReservedWord, "asserts");
12185
+ this.raise(ErrorMessages.InvalidEscapedReservedWord, {
12186
+ at: this.state.lastTokStartLoc
12187
+ }, "asserts");
11959
12188
  }
11960
12189
 
11961
12190
  return true;
@@ -12009,7 +12238,9 @@ var typescript = superClass => class extends superClass {
12009
12238
 
12010
12239
  tsParseTypeAssertion() {
12011
12240
  if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
12012
- this.raise(this.state.start, TSErrors.ReservedTypeAssertion);
12241
+ this.raise(TSErrors.ReservedTypeAssertion, {
12242
+ at: this.state.startLoc
12243
+ });
12013
12244
  }
12014
12245
 
12015
12246
  var node = this.startNode();
@@ -12023,11 +12254,13 @@ var typescript = superClass => class extends superClass {
12023
12254
  }
12024
12255
 
12025
12256
  tsParseHeritageClause(descriptor) {
12026
- var originalStart = this.state.start;
12257
+ var originalStartLoc = this.state.startLoc;
12027
12258
  var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
12028
12259
 
12029
12260
  if (!delimitedList.length) {
12030
- this.raise(originalStart, TSErrors.EmptyHeritageClauseType, descriptor);
12261
+ this.raise(TSErrors.EmptyHeritageClauseType, {
12262
+ at: originalStartLoc
12263
+ }, descriptor);
12031
12264
  }
12032
12265
 
12033
12266
  return delimitedList;
@@ -12050,7 +12283,9 @@ var typescript = superClass => class extends superClass {
12050
12283
  this.checkLVal(node.id, "typescript interface declaration", BIND_TS_INTERFACE);
12051
12284
  } else {
12052
12285
  node.id = null;
12053
- this.raise(this.state.start, TSErrors.MissingInterfaceName);
12286
+ this.raise(TSErrors.MissingInterfaceName, {
12287
+ at: this.state.startLoc
12288
+ });
12054
12289
  }
12055
12290
 
12056
12291
  node.typeParameters = this.tsTryParseTypeParameters();
@@ -12210,7 +12445,9 @@ var typescript = superClass => class extends superClass {
12210
12445
  var moduleReference = this.tsParseModuleReference();
12211
12446
 
12212
12447
  if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
12213
- this.raise(moduleReference.start, TSErrors.ImportAliasHasImportType);
12448
+ this.raise(TSErrors.ImportAliasHasImportType, {
12449
+ node: moduleReference
12450
+ });
12214
12451
  }
12215
12452
 
12216
12453
  node.moduleReference = moduleReference;
@@ -12444,7 +12681,9 @@ var typescript = superClass => class extends superClass {
12444
12681
  }));
12445
12682
 
12446
12683
  if (node.params.length === 0) {
12447
- this.raise(node.start, TSErrors.EmptyTypeArguments);
12684
+ this.raise(TSErrors.EmptyTypeArguments, {
12685
+ node
12686
+ });
12448
12687
  }
12449
12688
 
12450
12689
  this.expect(46);
@@ -12475,7 +12714,9 @@ var typescript = superClass => class extends superClass {
12475
12714
  readonly = modified.readonly;
12476
12715
 
12477
12716
  if (allowModifiers === false && (accessibility || readonly || override)) {
12478
- this.raise(startPos, TSErrors.UnexpectedParameterModifier);
12717
+ this.raise(TSErrors.UnexpectedParameterModifier, {
12718
+ at: startLoc
12719
+ });
12479
12720
  }
12480
12721
  }
12481
12722
 
@@ -12495,7 +12736,9 @@ var typescript = superClass => class extends superClass {
12495
12736
  if (override) pp.override = override;
12496
12737
 
12497
12738
  if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
12498
- this.raise(pp.start, TSErrors.UnsupportedParameterPropertyKind);
12739
+ this.raise(TSErrors.UnsupportedParameterPropertyKind, {
12740
+ node: pp
12741
+ });
12499
12742
  }
12500
12743
 
12501
12744
  pp.parameter = elt;
@@ -12524,7 +12767,9 @@ var typescript = superClass => class extends superClass {
12524
12767
  }
12525
12768
 
12526
12769
  if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
12527
- this.raise(node.start, TSErrors.DeclareFunctionHasImplementation);
12770
+ this.raise(TSErrors.DeclareFunctionHasImplementation, {
12771
+ node
12772
+ });
12528
12773
 
12529
12774
  if (node.declare) {
12530
12775
  super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
@@ -12546,7 +12791,9 @@ var typescript = superClass => class extends superClass {
12546
12791
  tsCheckForInvalidTypeCasts(items) {
12547
12792
  items.forEach(node => {
12548
12793
  if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
12549
- this.raise(node.typeAnnotation.start, TSErrors.UnexpectedTypeAnnotation);
12794
+ this.raise(TSErrors.UnexpectedTypeAnnotation, {
12795
+ node: node.typeAnnotation
12796
+ });
12550
12797
  }
12551
12798
  });
12552
12799
  }
@@ -12588,7 +12835,7 @@ var typescript = superClass => class extends superClass {
12588
12835
  }
12589
12836
 
12590
12837
  if (this.match(45)) {
12591
- var missingParenErrorPos;
12838
+ var missingParenErrorLoc;
12592
12839
  var result = this.tsTryParseAndCatch(() => {
12593
12840
  if (!noCalls && this.atPossibleAsyncArrow(base)) {
12594
12841
  var asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startPos, startLoc);
@@ -12604,7 +12851,7 @@ var typescript = superClass => class extends superClass {
12604
12851
 
12605
12852
  if (typeArguments) {
12606
12853
  if (isOptionalCall && !this.match(10)) {
12607
- missingParenErrorPos = this.state.pos;
12854
+ missingParenErrorLoc = this.state.curPosition();
12608
12855
  this.unexpected();
12609
12856
  }
12610
12857
 
@@ -12629,8 +12876,8 @@ var typescript = superClass => class extends superClass {
12629
12876
  this.unexpected();
12630
12877
  });
12631
12878
 
12632
- if (missingParenErrorPos) {
12633
- this.unexpected(missingParenErrorPos, 10);
12879
+ if (missingParenErrorLoc) {
12880
+ this.unexpected(missingParenErrorLoc, 10);
12634
12881
  }
12635
12882
 
12636
12883
  if (result) return result;
@@ -12700,7 +12947,9 @@ var typescript = superClass => class extends superClass {
12700
12947
  var importNode = super.parseImport(node);
12701
12948
 
12702
12949
  if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
12703
- this.raise(importNode.start, TSErrors.TypeImportCannotSpecifyDefaultAndNamed);
12950
+ this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, {
12951
+ node: importNode
12952
+ });
12704
12953
  }
12705
12954
 
12706
12955
  return importNode;
@@ -12807,7 +13056,9 @@ var typescript = superClass => class extends superClass {
12807
13056
  this.next();
12808
13057
 
12809
13058
  if (this.tsHasSomeModifiers(member, modifiers)) {
12810
- this.raise(this.state.pos, TSErrors.StaticBlockCannotHaveModifier);
13059
+ this.raise(TSErrors.StaticBlockCannotHaveModifier, {
13060
+ at: this.state.curPosition()
13061
+ });
12811
13062
  }
12812
13063
 
12813
13064
  this.parseClassStaticBlock(classBody, member);
@@ -12830,31 +13081,43 @@ var typescript = superClass => class extends superClass {
12830
13081
  classBody.body.push(idx);
12831
13082
 
12832
13083
  if (member.abstract) {
12833
- this.raise(member.start, TSErrors.IndexSignatureHasAbstract);
13084
+ this.raise(TSErrors.IndexSignatureHasAbstract, {
13085
+ node: member
13086
+ });
12834
13087
  }
12835
13088
 
12836
13089
  if (member.accessibility) {
12837
- this.raise(member.start, TSErrors.IndexSignatureHasAccessibility, member.accessibility);
13090
+ this.raise(TSErrors.IndexSignatureHasAccessibility, {
13091
+ node: member
13092
+ }, member.accessibility);
12838
13093
  }
12839
13094
 
12840
13095
  if (member.declare) {
12841
- this.raise(member.start, TSErrors.IndexSignatureHasDeclare);
13096
+ this.raise(TSErrors.IndexSignatureHasDeclare, {
13097
+ node: member
13098
+ });
12842
13099
  }
12843
13100
 
12844
13101
  if (member.override) {
12845
- this.raise(member.start, TSErrors.IndexSignatureHasOverride);
13102
+ this.raise(TSErrors.IndexSignatureHasOverride, {
13103
+ node: member
13104
+ });
12846
13105
  }
12847
13106
 
12848
13107
  return;
12849
13108
  }
12850
13109
 
12851
13110
  if (!this.state.inAbstractClass && member.abstract) {
12852
- this.raise(member.start, TSErrors.NonAbstractClassHasAbstractMethod);
13111
+ this.raise(TSErrors.NonAbstractClassHasAbstractMethod, {
13112
+ node: member
13113
+ });
12853
13114
  }
12854
13115
 
12855
13116
  if (member.override) {
12856
13117
  if (!state.hadSuperClass) {
12857
- this.raise(member.start, TSErrors.OverrideNotInSubClass);
13118
+ this.raise(TSErrors.OverrideNotInSubClass, {
13119
+ node: member
13120
+ });
12858
13121
  }
12859
13122
  }
12860
13123
 
@@ -12866,11 +13129,15 @@ var typescript = superClass => class extends superClass {
12866
13129
  if (optional) methodOrProp.optional = true;
12867
13130
 
12868
13131
  if (methodOrProp.readonly && this.match(10)) {
12869
- this.raise(methodOrProp.start, TSErrors.ClassMethodHasReadonly);
13132
+ this.raise(TSErrors.ClassMethodHasReadonly, {
13133
+ node: methodOrProp
13134
+ });
12870
13135
  }
12871
13136
 
12872
13137
  if (methodOrProp.declare && this.match(10)) {
12873
- this.raise(methodOrProp.start, TSErrors.ClassMethodHasDeclare);
13138
+ this.raise(TSErrors.ClassMethodHasDeclare, {
13139
+ node: methodOrProp
13140
+ });
12874
13141
  }
12875
13142
  }
12876
13143
 
@@ -12927,7 +13194,9 @@ var typescript = superClass => class extends superClass {
12927
13194
  var isDeclare = this.eatContextual(117);
12928
13195
 
12929
13196
  if (isDeclare && (this.isContextual(117) || !this.shouldParseExportDeclaration())) {
12930
- throw this.raise(this.state.start, TSErrors.ExpectedAmbientAfterExportDeclare);
13197
+ throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, {
13198
+ at: this.state.startLoc
13199
+ });
12931
13200
  }
12932
13201
 
12933
13202
  var declaration;
@@ -12975,14 +13244,18 @@ var typescript = superClass => class extends superClass {
12975
13244
  this.parseClassPropertyAnnotation(node);
12976
13245
 
12977
13246
  if (this.state.isAmbientContext && this.match(29)) {
12978
- this.raise(this.state.start, TSErrors.DeclareClassFieldHasInitializer);
13247
+ this.raise(TSErrors.DeclareClassFieldHasInitializer, {
13248
+ at: this.state.startLoc
13249
+ });
12979
13250
  }
12980
13251
 
12981
13252
  if (node.abstract && this.match(29)) {
12982
13253
  var {
12983
13254
  key
12984
13255
  } = node;
12985
- this.raise(this.state.start, TSErrors.AbstractPropertyHasInitializer, key.type === "Identifier" && !node.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
13256
+ this.raise(TSErrors.AbstractPropertyHasInitializer, {
13257
+ at: this.state.startLoc
13258
+ }, key.type === "Identifier" && !node.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
12986
13259
  }
12987
13260
 
12988
13261
  return super.parseClassProperty(node);
@@ -12990,11 +13263,15 @@ var typescript = superClass => class extends superClass {
12990
13263
 
12991
13264
  parseClassPrivateProperty(node) {
12992
13265
  if (node.abstract) {
12993
- this.raise(node.start, TSErrors.PrivateElementHasAbstract);
13266
+ this.raise(TSErrors.PrivateElementHasAbstract, {
13267
+ node
13268
+ });
12994
13269
  }
12995
13270
 
12996
13271
  if (node.accessibility) {
12997
- this.raise(node.start, TSErrors.PrivateElementHasAccessibility, node.accessibility);
13272
+ this.raise(TSErrors.PrivateElementHasAccessibility, {
13273
+ node
13274
+ }, node.accessibility);
12998
13275
  }
12999
13276
 
13000
13277
  this.parseClassPropertyAnnotation(node);
@@ -13005,11 +13282,15 @@ var typescript = superClass => class extends superClass {
13005
13282
  var typeParameters = this.tsTryParseTypeParameters();
13006
13283
 
13007
13284
  if (typeParameters && isConstructor) {
13008
- this.raise(typeParameters.start, TSErrors.ConstructorHasTypeParameters);
13285
+ this.raise(TSErrors.ConstructorHasTypeParameters, {
13286
+ node: typeParameters
13287
+ });
13009
13288
  }
13010
13289
 
13011
13290
  if (method.declare && (method.kind === "get" || method.kind === "set")) {
13012
- this.raise(method.start, TSErrors.DeclareAccessor, method.kind);
13291
+ this.raise(TSErrors.DeclareAccessor, {
13292
+ node: method
13293
+ }, method.kind);
13013
13294
  }
13014
13295
 
13015
13296
  if (typeParameters) method.typeParameters = typeParameters;
@@ -13060,7 +13341,7 @@ var typescript = superClass => class extends superClass {
13060
13341
  parseVarId(decl, kind) {
13061
13342
  super.parseVarId(decl, kind);
13062
13343
 
13063
- if (decl.id.type === "Identifier" && this.eat(35)) {
13344
+ if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
13064
13345
  decl.definite = true;
13065
13346
  }
13066
13347
 
@@ -13166,7 +13447,9 @@ var typescript = superClass => class extends superClass {
13166
13447
  var _node$extra;
13167
13448
 
13168
13449
  if (node.params.length === 1 && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
13169
- this.raise(node.start, TSErrors.ReservedArrowTypeParam);
13450
+ this.raise(TSErrors.ReservedArrowTypeParam, {
13451
+ node
13452
+ });
13170
13453
  }
13171
13454
  }
13172
13455
 
@@ -13199,7 +13482,9 @@ var typescript = superClass => class extends superClass {
13199
13482
  parseAssignableListItemTypes(param) {
13200
13483
  if (this.eat(17)) {
13201
13484
  if (param.type !== "Identifier" && !this.state.isAmbientContext && !this.state.inType) {
13202
- this.raise(param.start, TSErrors.PatternIsOptional);
13485
+ this.raise(TSErrors.PatternIsOptional, {
13486
+ node: param
13487
+ });
13203
13488
  }
13204
13489
 
13205
13490
  param.optional = true;
@@ -13280,7 +13565,9 @@ var typescript = superClass => class extends superClass {
13280
13565
  case "TSAsExpression":
13281
13566
  case "TSTypeAssertion":
13282
13567
  if (!args[0] && contextDescription !== "parenthesized expression" && !((_expr$extra2 = expr.extra) != null && _expr$extra2.parenthesized)) {
13283
- this.raise(expr.start, ErrorMessages.InvalidLhs, contextDescription);
13568
+ this.raise(ErrorMessages.InvalidLhs, {
13569
+ node: expr
13570
+ }, contextDescription);
13284
13571
  break;
13285
13572
  }
13286
13573
 
@@ -13317,7 +13604,7 @@ var typescript = superClass => class extends superClass {
13317
13604
  return call;
13318
13605
  }
13319
13606
 
13320
- this.unexpected(this.state.start, 10);
13607
+ this.unexpected(null, 10);
13321
13608
  }
13322
13609
 
13323
13610
  return super.parseMaybeDecoratorArguments(expr);
@@ -13326,8 +13613,9 @@ var typescript = superClass => class extends superClass {
13326
13613
  checkCommaAfterRest(close) {
13327
13614
  if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
13328
13615
  this.next();
13616
+ return false;
13329
13617
  } else {
13330
- super.checkCommaAfterRest(close);
13618
+ return super.checkCommaAfterRest(close);
13331
13619
  }
13332
13620
  }
13333
13621
 
@@ -13343,7 +13631,9 @@ var typescript = superClass => class extends superClass {
13343
13631
  var node = super.parseMaybeDefault(...arguments);
13344
13632
 
13345
13633
  if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
13346
- this.raise(node.typeAnnotation.start, TSErrors.TypeAnnotationAfterAssign);
13634
+ this.raise(TSErrors.TypeAnnotationAfterAssign, {
13635
+ node: node.typeAnnotation
13636
+ });
13347
13637
  }
13348
13638
 
13349
13639
  return node;
@@ -13392,7 +13682,9 @@ var typescript = superClass => class extends superClass {
13392
13682
  if (!this.state.maybeInArrowParameters) {
13393
13683
  exprList[i] = this.typeCastToParameter(expr);
13394
13684
  } else {
13395
- this.raise(expr.start, TSErrors.UnexpectedTypeCastInParameter);
13685
+ this.raise(TSErrors.UnexpectedTypeCastInParameter, {
13686
+ node: expr
13687
+ });
13396
13688
  }
13397
13689
 
13398
13690
  break;
@@ -13404,7 +13696,7 @@ var typescript = superClass => class extends superClass {
13404
13696
 
13405
13697
  typeCastToParameter(node) {
13406
13698
  node.expression.typeAnnotation = node.typeAnnotation;
13407
- this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
13699
+ this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
13408
13700
  return node.expression;
13409
13701
  }
13410
13702
 
@@ -13486,7 +13778,9 @@ var typescript = superClass => class extends superClass {
13486
13778
  } else if (this.isContextual(121)) {
13487
13779
  if (!this.hasFollowingLineBreak()) {
13488
13780
  node.abstract = true;
13489
- this.raise(node.start, TSErrors.NonClassMethodPropertyHasAbstractModifer);
13781
+ this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, {
13782
+ node
13783
+ });
13490
13784
  this.next();
13491
13785
  return this.tsParseInterfaceDeclaration(node);
13492
13786
  }
@@ -13505,7 +13799,9 @@ var typescript = superClass => class extends superClass {
13505
13799
  var {
13506
13800
  key
13507
13801
  } = method;
13508
- this.raise(method.start, TSErrors.AbstractMethodHasImplementation, key.type === "Identifier" && !method.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
13802
+ this.raise(TSErrors.AbstractMethodHasImplementation, {
13803
+ node: method
13804
+ }, key.type === "Identifier" && !method.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
13509
13805
  }
13510
13806
  }
13511
13807
 
@@ -13564,7 +13860,7 @@ var typescript = superClass => class extends superClass {
13564
13860
  var rightOfAs;
13565
13861
  var hasTypeSpecifier = false;
13566
13862
  var canParseAsKeyword = true;
13567
- var pos = leftOfAs.start;
13863
+ var loc = leftOfAs.loc.start;
13568
13864
 
13569
13865
  if (this.isContextual(89)) {
13570
13866
  var firstAs = this.parseIdentifier();
@@ -13594,7 +13890,9 @@ var typescript = superClass => class extends superClass {
13594
13890
  }
13595
13891
 
13596
13892
  if (hasTypeSpecifier && isInTypeOnlyImportExport) {
13597
- this.raise(pos, isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports);
13893
+ this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, {
13894
+ at: loc
13895
+ });
13598
13896
  }
13599
13897
 
13600
13898
  node[leftOfAsKey] = leftOfAs;
@@ -13617,9 +13915,9 @@ var typescript = superClass => class extends superClass {
13617
13915
 
13618
13916
  };
13619
13917
 
13620
- var PlaceHolderErrors = makeErrorTemplates({
13918
+ var PlaceholderErrors = makeErrorTemplates({
13621
13919
  ClassNameIsRequired: "A class name is required."
13622
- }, ErrorCodes.SyntaxError);
13920
+ }, ErrorCodes.SyntaxError, "placeholders");
13623
13921
 
13624
13922
  var placeholders = superClass => class extends superClass {
13625
13923
  parsePlaceholder(expectedNode) {
@@ -13742,7 +14040,9 @@ var placeholders = superClass => class extends superClass {
13742
14040
  node.body = this.finishPlaceholder(placeholder, "ClassBody");
13743
14041
  return this.finishNode(node, type);
13744
14042
  } else {
13745
- this.unexpected(null, PlaceHolderErrors.ClassNameIsRequired);
14043
+ throw this.raise(PlaceholderErrors.ClassNameIsRequired, {
14044
+ at: this.state.startLoc
14045
+ });
13746
14046
  }
13747
14047
  } else {
13748
14048
  this.parseClassId(node, isStatement, optionalId);
@@ -13842,7 +14142,7 @@ var placeholders = superClass => class extends superClass {
13842
14142
  var v8intrinsic = superClass => class extends superClass {
13843
14143
  parseV8Intrinsic() {
13844
14144
  if (this.match(50)) {
13845
- var v8IntrinsicStart = this.state.start;
14145
+ var v8IntrinsicStartLoc = this.state.startLoc;
13846
14146
  var node = this.startNode();
13847
14147
  this.next();
13848
14148
 
@@ -13856,7 +14156,7 @@ var v8intrinsic = superClass => class extends superClass {
13856
14156
  }
13857
14157
  }
13858
14158
 
13859
- this.unexpected(v8IntrinsicStart);
14159
+ this.unexpected(v8IntrinsicStartLoc);
13860
14160
  }
13861
14161
  }
13862
14162
 
@@ -14050,12 +14350,16 @@ class LValParser extends NodeUtils {
14050
14350
 
14051
14351
  if (isLHS) {
14052
14352
  if (parenthesized.type === "Identifier") {
14053
- this.expressionScope.recordParenthesizedIdentifierError(node.start, ErrorMessages.InvalidParenthesizedAssignment);
14353
+ this.expressionScope.recordParenthesizedIdentifierError(ErrorMessages.InvalidParenthesizedAssignment, node.loc.start);
14054
14354
  } else if (parenthesized.type !== "MemberExpression") {
14055
- this.raise(node.start, ErrorMessages.InvalidParenthesizedAssignment);
14355
+ this.raise(ErrorMessages.InvalidParenthesizedAssignment, {
14356
+ node
14357
+ });
14056
14358
  }
14057
14359
  } else {
14058
- this.raise(node.start, ErrorMessages.InvalidParenthesizedAssignment);
14360
+ this.raise(ErrorMessages.InvalidParenthesizedAssignment, {
14361
+ node
14362
+ });
14059
14363
  }
14060
14364
  }
14061
14365
 
@@ -14077,8 +14381,10 @@ class LValParser extends NodeUtils {
14077
14381
  var isLast = i === last;
14078
14382
  this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
14079
14383
 
14080
- if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingComma) {
14081
- this.raiseRestNotLast(node.extra.trailingComma);
14384
+ if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
14385
+ this.raise(ErrorMessages.RestTrailingComma, {
14386
+ at: node.extra.trailingCommaLoc
14387
+ });
14082
14388
  }
14083
14389
  }
14084
14390
 
@@ -14099,12 +14405,14 @@ class LValParser extends NodeUtils {
14099
14405
 
14100
14406
  case "ArrayExpression":
14101
14407
  node.type = "ArrayPattern";
14102
- this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingComma, isLHS);
14408
+ this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
14103
14409
  break;
14104
14410
 
14105
14411
  case "AssignmentExpression":
14106
14412
  if (node.operator !== "=") {
14107
- this.raise(node.left.end, ErrorMessages.MissingEqInAssignment);
14413
+ this.raise(ErrorMessages.MissingEqInAssignment, {
14414
+ at: node.left.loc.end
14415
+ });
14108
14416
  }
14109
14417
 
14110
14418
  node.type = "AssignmentPattern";
@@ -14122,16 +14430,19 @@ class LValParser extends NodeUtils {
14122
14430
 
14123
14431
  toAssignableObjectExpressionProp(prop, isLast, isLHS) {
14124
14432
  if (prop.type === "ObjectMethod") {
14125
- var error = prop.kind === "get" || prop.kind === "set" ? ErrorMessages.PatternHasAccessor : ErrorMessages.PatternHasMethod;
14126
- this.raise(prop.key.start, error);
14433
+ this.raise(prop.kind === "get" || prop.kind === "set" ? ErrorMessages.PatternHasAccessor : ErrorMessages.PatternHasMethod, {
14434
+ node: prop.key
14435
+ });
14127
14436
  } else if (prop.type === "SpreadElement" && !isLast) {
14128
- this.raiseRestNotLast(prop.start);
14437
+ this.raise(ErrorMessages.RestTrailingComma, {
14438
+ node: prop
14439
+ });
14129
14440
  } else {
14130
14441
  this.toAssignable(prop, isLHS);
14131
14442
  }
14132
14443
  }
14133
14444
 
14134
- toAssignableList(exprList, trailingCommaPos, isLHS) {
14445
+ toAssignableList(exprList, trailingCommaLoc, isLHS) {
14135
14446
  var end = exprList.length;
14136
14447
 
14137
14448
  if (end) {
@@ -14149,8 +14460,10 @@ class LValParser extends NodeUtils {
14149
14460
  this.unexpected(arg.start);
14150
14461
  }
14151
14462
 
14152
- if (trailingCommaPos) {
14153
- this.raiseTrailingCommaAfterRest(trailingCommaPos);
14463
+ if (trailingCommaLoc) {
14464
+ this.raise(ErrorMessages.RestTrailingComma, {
14465
+ at: trailingCommaLoc
14466
+ });
14154
14467
  }
14155
14468
 
14156
14469
  --end;
@@ -14164,7 +14477,9 @@ class LValParser extends NodeUtils {
14164
14477
  this.toAssignable(elt, isLHS);
14165
14478
 
14166
14479
  if (elt.type === "RestElement") {
14167
- this.raiseRestNotLast(elt.start);
14480
+ this.raise(ErrorMessages.RestTrailingComma, {
14481
+ node: elt
14482
+ });
14168
14483
  }
14169
14484
  }
14170
14485
  }
@@ -14275,14 +14590,18 @@ class LValParser extends NodeUtils {
14275
14590
  break;
14276
14591
  } else if (this.match(21)) {
14277
14592
  elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
14278
- this.checkCommaAfterRest(closeCharCode);
14279
- this.expect(close);
14280
- break;
14593
+
14594
+ if (!this.checkCommaAfterRest(closeCharCode)) {
14595
+ this.expect(close);
14596
+ break;
14597
+ }
14281
14598
  } else {
14282
14599
  var decorators = [];
14283
14600
 
14284
14601
  if (this.match(26) && this.hasPlugin("decorators")) {
14285
- this.raise(this.state.start, ErrorMessages.UnsupportedParameterDecorator);
14602
+ this.raise(ErrorMessages.UnsupportedParameterDecorator, {
14603
+ at: this.state.startLoc
14604
+ });
14286
14605
  }
14287
14606
 
14288
14607
  while (this.match(26)) {
@@ -14365,23 +14684,29 @@ class LValParser extends NodeUtils {
14365
14684
  } = expr;
14366
14685
 
14367
14686
  if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(name, this.inModule) : isStrictBindOnlyReservedWord(name))) {
14368
- this.raise(expr.start, bindingType === BIND_NONE ? ErrorMessages.StrictEvalArguments : ErrorMessages.StrictEvalArgumentsBinding, name);
14687
+ this.raise(bindingType === BIND_NONE ? ErrorMessages.StrictEvalArguments : ErrorMessages.StrictEvalArgumentsBinding, {
14688
+ node: expr
14689
+ }, name);
14369
14690
  }
14370
14691
 
14371
14692
  if (checkClashes) {
14372
14693
  if (checkClashes.has(name)) {
14373
- this.raise(expr.start, ErrorMessages.ParamDupe);
14694
+ this.raise(ErrorMessages.ParamDupe, {
14695
+ node: expr
14696
+ });
14374
14697
  } else {
14375
14698
  checkClashes.add(name);
14376
14699
  }
14377
14700
  }
14378
14701
 
14379
14702
  if (disallowLetBinding && name === "let") {
14380
- this.raise(expr.start, ErrorMessages.LetInLexicalBinding);
14703
+ this.raise(ErrorMessages.LetInLexicalBinding, {
14704
+ node: expr
14705
+ });
14381
14706
  }
14382
14707
 
14383
14708
  if (!(bindingType & BIND_NONE)) {
14384
- this.scope.declareName(name, bindingType, expr.start);
14709
+ this.scope.declareName(name, bindingType, expr.loc.start);
14385
14710
  }
14386
14711
 
14387
14712
  break;
@@ -14389,7 +14714,9 @@ class LValParser extends NodeUtils {
14389
14714
 
14390
14715
  case "MemberExpression":
14391
14716
  if (bindingType !== BIND_NONE) {
14392
- this.raise(expr.start, ErrorMessages.InvalidPropertyBindingPattern);
14717
+ this.raise(ErrorMessages.InvalidPropertyBindingPattern, {
14718
+ node: expr
14719
+ });
14393
14720
  }
14394
14721
 
14395
14722
  break;
@@ -14425,33 +14752,30 @@ class LValParser extends NodeUtils {
14425
14752
 
14426
14753
  default:
14427
14754
  {
14428
- this.raise(expr.start, bindingType === BIND_NONE ? ErrorMessages.InvalidLhs : ErrorMessages.InvalidLhsBinding, contextDescription);
14755
+ this.raise(bindingType === BIND_NONE ? ErrorMessages.InvalidLhs : ErrorMessages.InvalidLhsBinding, {
14756
+ node: expr
14757
+ }, contextDescription);
14429
14758
  }
14430
14759
  }
14431
14760
  }
14432
14761
 
14433
14762
  checkToRestConversion(node) {
14434
14763
  if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
14435
- this.raise(node.argument.start, ErrorMessages.InvalidRestAssignmentPattern);
14764
+ this.raise(ErrorMessages.InvalidRestAssignmentPattern, {
14765
+ node: node.argument
14766
+ });
14436
14767
  }
14437
14768
  }
14438
14769
 
14439
14770
  checkCommaAfterRest(close) {
14440
- if (this.match(12)) {
14441
- if (this.lookaheadCharCode() === close) {
14442
- this.raiseTrailingCommaAfterRest(this.state.start);
14443
- } else {
14444
- this.raiseRestNotLast(this.state.start);
14445
- }
14771
+ if (!this.match(12)) {
14772
+ return false;
14446
14773
  }
14447
- }
14448
-
14449
- raiseRestNotLast(pos) {
14450
- throw this.raise(pos, ErrorMessages.ElementAfterRest);
14451
- }
14452
14774
 
14453
- raiseTrailingCommaAfterRest(pos) {
14454
- this.raise(pos, ErrorMessages.RestTrailingComma);
14775
+ this.raise(this.lookaheadCharCode() === close ? ErrorMessages.RestTrailingComma : ErrorMessages.ElementAfterRest, {
14776
+ at: this.state.startLoc
14777
+ });
14778
+ return true;
14455
14779
  }
14456
14780
 
14457
14781
  }
@@ -14469,17 +14793,21 @@ class ExpressionParser extends LValParser {
14469
14793
 
14470
14794
  if (name === "__proto__") {
14471
14795
  if (isRecord) {
14472
- this.raise(key.start, ErrorMessages.RecordNoProto);
14796
+ this.raise(ErrorMessages.RecordNoProto, {
14797
+ node: key
14798
+ });
14473
14799
  return;
14474
14800
  }
14475
14801
 
14476
14802
  if (protoRef.used) {
14477
14803
  if (refExpressionErrors) {
14478
- if (refExpressionErrors.doubleProto === -1) {
14479
- refExpressionErrors.doubleProto = key.start;
14804
+ if (refExpressionErrors.doubleProtoLoc === null) {
14805
+ refExpressionErrors.doubleProtoLoc = key.loc.start;
14480
14806
  }
14481
14807
  } else {
14482
- this.raise(key.start, ErrorMessages.DuplicateProto);
14808
+ this.raise(ErrorMessages.DuplicateProto, {
14809
+ node: key
14810
+ });
14483
14811
  }
14484
14812
  }
14485
14813
 
@@ -14548,9 +14876,9 @@ class ExpressionParser extends LValParser {
14548
14876
  }
14549
14877
 
14550
14878
  setOptionalParametersError(refExpressionErrors, resultError) {
14551
- var _resultError$pos;
14879
+ var _resultError$loc;
14552
14880
 
14553
- refExpressionErrors.optionalParameters = (_resultError$pos = resultError == null ? void 0 : resultError.pos) != null ? _resultError$pos : this.state.start;
14881
+ refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
14554
14882
  }
14555
14883
 
14556
14884
  parseMaybeAssign(refExpressionErrors, afterLeftParse) {
@@ -14600,12 +14928,12 @@ class ExpressionParser extends LValParser {
14600
14928
  if (this.match(29)) {
14601
14929
  node.left = this.toAssignable(left, true);
14602
14930
 
14603
- if (refExpressionErrors.doubleProto >= startPos) {
14604
- refExpressionErrors.doubleProto = -1;
14931
+ if (refExpressionErrors.doubleProtoLoc != null && indexes.get(refExpressionErrors.doubleProtoLoc) >= startPos) {
14932
+ refExpressionErrors.doubleProtoLoc = null;
14605
14933
  }
14606
14934
 
14607
- if (refExpressionErrors.shorthandAssign >= startPos) {
14608
- refExpressionErrors.shorthandAssign = -1;
14935
+ if (refExpressionErrors.shorthandAssignLoc != null && indexes.get(refExpressionErrors.shorthandAssignLoc) >= startPos) {
14936
+ refExpressionErrors.shorthandAssignLoc = null;
14609
14937
  }
14610
14938
  } else {
14611
14939
  node.left = left;
@@ -14668,15 +14996,14 @@ class ExpressionParser extends LValParser {
14668
14996
  parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
14669
14997
  if (this.isPrivateName(left)) {
14670
14998
  var value = this.getPrivateNameSV(left);
14671
- var {
14672
- start
14673
- } = left;
14674
14999
 
14675
15000
  if (minPrec >= tokenOperatorPrecedence(54) || !this.prodParam.hasIn || !this.match(54)) {
14676
- this.raise(start, ErrorMessages.PrivateInExpectedIn, value);
15001
+ this.raise(ErrorMessages.PrivateInExpectedIn, {
15002
+ node: left
15003
+ }, value);
14677
15004
  }
14678
15005
 
14679
- this.classScope.usePrivateName(value, start);
15006
+ this.classScope.usePrivateName(value, left.loc.start);
14680
15007
  }
14681
15008
 
14682
15009
  var op = this.state.type;
@@ -14692,7 +15019,7 @@ class ExpressionParser extends LValParser {
14692
15019
  return left;
14693
15020
  }
14694
15021
 
14695
- this.checkPipelineAtInfixOperator(left, leftStartPos);
15022
+ this.checkPipelineAtInfixOperator(left, leftStartLoc);
14696
15023
  }
14697
15024
 
14698
15025
  var node = this.startNodeAt(leftStartPos, leftStartLoc);
@@ -14711,7 +15038,9 @@ class ExpressionParser extends LValParser {
14711
15038
  proposal: "minimal"
14712
15039
  }])) {
14713
15040
  if (this.state.type === 92 && this.prodParam.hasAwait) {
14714
- throw this.raise(this.state.start, ErrorMessages.UnexpectedAwaitAfterPipelineBody);
15041
+ throw this.raise(ErrorMessages.UnexpectedAwaitAfterPipelineBody, {
15042
+ at: this.state.startLoc
15043
+ });
14715
15044
  }
14716
15045
  }
14717
15046
 
@@ -14720,7 +15049,9 @@ class ExpressionParser extends LValParser {
14720
15049
  var nextOp = this.state.type;
14721
15050
 
14722
15051
  if (coalesce && (nextOp === 39 || nextOp === 40) || logical && nextOp === 38) {
14723
- throw this.raise(this.state.start, ErrorMessages.MixingCoalesceWithLogical);
15052
+ throw this.raise(ErrorMessages.MixingCoalesceWithLogical, {
15053
+ at: this.state.startLoc
15054
+ });
14724
15055
  }
14725
15056
 
14726
15057
  return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
@@ -14745,7 +15076,9 @@ class ExpressionParser extends LValParser {
14745
15076
  case "smart":
14746
15077
  return this.withTopicBindingContext(() => {
14747
15078
  if (this.prodParam.hasYield && this.isContextual(101)) {
14748
- throw this.raise(this.state.start, ErrorMessages.PipeBodyIsTighter, this.state.value);
15079
+ throw this.raise(ErrorMessages.PipeBodyIsTighter, {
15080
+ at: this.state.startLoc
15081
+ }, this.state.value);
14749
15082
  }
14750
15083
 
14751
15084
  return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startPos, startLoc);
@@ -14772,16 +15105,20 @@ class ExpressionParser extends LValParser {
14772
15105
  var _body$extra;
14773
15106
 
14774
15107
  var {
14775
- start
15108
+ startLoc
14776
15109
  } = this.state;
14777
15110
  var body = this.parseMaybeAssign();
14778
15111
 
14779
15112
  if (invalidHackPipeBodies.has(body.type) && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
14780
- this.raise(start, ErrorMessages.PipeUnparenthesizedBody, invalidHackPipeBodies.get(body.type));
15113
+ this.raise(ErrorMessages.PipeUnparenthesizedBody, {
15114
+ at: startLoc
15115
+ }, invalidHackPipeBodies.get(body.type));
14781
15116
  }
14782
15117
 
14783
15118
  if (!this.topicReferenceWasUsedInCurrentContext()) {
14784
- this.raise(start, ErrorMessages.PipeTopicUnused);
15119
+ this.raise(ErrorMessages.PipeTopicUnused, {
15120
+ at: startLoc
15121
+ });
14785
15122
  }
14786
15123
 
14787
15124
  return body;
@@ -14789,7 +15126,9 @@ class ExpressionParser extends LValParser {
14789
15126
 
14790
15127
  checkExponentialAfterUnary(node) {
14791
15128
  if (this.match(53)) {
14792
- this.raise(node.argument.start, ErrorMessages.UnexpectedTokenUnaryExponentiation);
15129
+ this.raise(ErrorMessages.UnexpectedTokenUnaryExponentiation, {
15130
+ node: node.argument
15131
+ });
14793
15132
  }
14794
15133
  }
14795
15134
 
@@ -14827,9 +15166,13 @@ class ExpressionParser extends LValParser {
14827
15166
  var arg = node.argument;
14828
15167
 
14829
15168
  if (arg.type === "Identifier") {
14830
- this.raise(node.start, ErrorMessages.StrictDelete);
15169
+ this.raise(ErrorMessages.StrictDelete, {
15170
+ node
15171
+ });
14831
15172
  } else if (this.hasPropertyAsPrivateName(arg)) {
14832
- this.raise(node.start, ErrorMessages.DeletePrivateField);
15173
+ this.raise(ErrorMessages.DeletePrivateField, {
15174
+ node
15175
+ });
14833
15176
  }
14834
15177
  }
14835
15178
 
@@ -14849,7 +15192,7 @@ class ExpressionParser extends LValParser {
14849
15192
  var _startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(50);
14850
15193
 
14851
15194
  if (_startsExpr && !this.isAmbiguousAwait()) {
14852
- this.raiseOverwrite(startPos, ErrorMessages.AwaitNotInAsyncContext);
15195
+ this.raiseOverwrite(startLoc, ErrorMessages.AwaitNotInAsyncContext);
14853
15196
  return this.parseAwait(startPos, startLoc);
14854
15197
  }
14855
15198
  }
@@ -14957,10 +15300,12 @@ class ExpressionParser extends LValParser {
14957
15300
  this.expect(3);
14958
15301
  } else if (this.match(130)) {
14959
15302
  if (base.type === "Super") {
14960
- this.raise(startPos, ErrorMessages.SuperPrivateField);
15303
+ this.raise(ErrorMessages.SuperPrivateField, {
15304
+ at: startLoc
15305
+ });
14961
15306
  }
14962
15307
 
14963
- this.classScope.usePrivateName(this.state.value, this.state.start);
15308
+ this.classScope.usePrivateName(this.state.value, this.state.startLoc);
14964
15309
  node.property = this.parsePrivateName();
14965
15310
  } else {
14966
15311
  node.property = this.parseIdentifier(true);
@@ -15036,14 +15381,16 @@ class ExpressionParser extends LValParser {
15036
15381
  node.quasi = this.parseTemplate(true);
15037
15382
 
15038
15383
  if (state.optionalChainMember) {
15039
- this.raise(startPos, ErrorMessages.OptionalChainingNoTemplate);
15384
+ this.raise(ErrorMessages.OptionalChainingNoTemplate, {
15385
+ at: startLoc
15386
+ });
15040
15387
  }
15041
15388
 
15042
15389
  return this.finishNode(node, "TaggedTemplateExpression");
15043
15390
  }
15044
15391
 
15045
15392
  atPossibleAsyncArrow(base) {
15046
- return base.type === "Identifier" && base.name === "async" && this.state.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt;
15393
+ 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;
15047
15394
  }
15048
15395
 
15049
15396
  finishCallExpression(node, optional) {
@@ -15057,11 +15404,15 @@ class ExpressionParser extends LValParser {
15057
15404
  }
15058
15405
 
15059
15406
  if (node.arguments.length === 0 || node.arguments.length > 2) {
15060
- this.raise(node.start, ErrorMessages.ImportCallArity, this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? "one or two arguments" : "one argument");
15407
+ this.raise(ErrorMessages.ImportCallArity, {
15408
+ node
15409
+ }, this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? "one or two arguments" : "one argument");
15061
15410
  } else {
15062
15411
  for (var arg of node.arguments) {
15063
15412
  if (arg.type === "SpreadElement") {
15064
- this.raise(arg.start, ErrorMessages.ImportCallSpreadArgument);
15413
+ this.raise(ErrorMessages.ImportCallSpreadArgument, {
15414
+ node: arg
15415
+ });
15065
15416
  }
15066
15417
  }
15067
15418
  }
@@ -15084,11 +15435,13 @@ class ExpressionParser extends LValParser {
15084
15435
 
15085
15436
  if (this.match(close)) {
15086
15437
  if (dynamicImport && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
15087
- this.raise(this.state.lastTokStart, ErrorMessages.ImportCallArgumentTrailingComma);
15438
+ this.raise(ErrorMessages.ImportCallArgumentTrailingComma, {
15439
+ at: this.state.lastTokStartLoc
15440
+ });
15088
15441
  }
15089
15442
 
15090
15443
  if (nodeForExtra) {
15091
- this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart);
15444
+ this.addTrailingCommaExtraToNode(nodeForExtra);
15092
15445
  }
15093
15446
 
15094
15447
  this.next();
@@ -15112,7 +15465,7 @@ class ExpressionParser extends LValParser {
15112
15465
 
15113
15466
  this.resetPreviousNodeTrailingComments(call);
15114
15467
  this.expect(19);
15115
- this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingComma);
15468
+ this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
15116
15469
 
15117
15470
  if (call.innerComments) {
15118
15471
  setInnerComments(node, call.innerComments);
@@ -15150,7 +15503,9 @@ class ExpressionParser extends LValParser {
15150
15503
  }
15151
15504
 
15152
15505
  if (!this.match(10)) {
15153
- this.raise(this.state.lastTokStart, ErrorMessages.UnsupportedImport);
15506
+ this.raise(ErrorMessages.UnsupportedImport, {
15507
+ at: this.state.lastTokStartLoc
15508
+ });
15154
15509
  }
15155
15510
 
15156
15511
  return this.finishNode(node, "Import");
@@ -15249,13 +15604,17 @@ class ExpressionParser extends LValParser {
15249
15604
  if (callee.type === "MemberExpression") {
15250
15605
  return this.finishNode(node, "BindExpression");
15251
15606
  } else {
15252
- throw this.raise(callee.start, ErrorMessages.UnsupportedBind);
15607
+ throw this.raise(ErrorMessages.UnsupportedBind, {
15608
+ node: callee
15609
+ });
15253
15610
  }
15254
15611
  }
15255
15612
 
15256
15613
  case 130:
15257
15614
  {
15258
- this.raise(this.state.start, ErrorMessages.PrivateInExpectedIn, this.state.value);
15615
+ this.raise(ErrorMessages.PrivateInExpectedIn, {
15616
+ at: this.state.startLoc
15617
+ }, this.state.value);
15259
15618
  return this.parsePrivateName();
15260
15619
  }
15261
15620
 
@@ -15347,7 +15706,7 @@ class ExpressionParser extends LValParser {
15347
15706
  this.state.value = topicTokenValue;
15348
15707
  this.state.pos--;
15349
15708
  this.state.end--;
15350
- this.state.endLoc.column--;
15709
+ this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
15351
15710
  return this.parseTopicReference(pipeProposal);
15352
15711
  } else {
15353
15712
  throw this.unexpected();
@@ -15356,38 +15715,32 @@ class ExpressionParser extends LValParser {
15356
15715
 
15357
15716
  parseTopicReference(pipeProposal) {
15358
15717
  var node = this.startNode();
15359
- var start = this.state.start;
15718
+ var startLoc = this.state.startLoc;
15360
15719
  var tokenType = this.state.type;
15361
15720
  this.next();
15362
- return this.finishTopicReference(node, start, pipeProposal, tokenType);
15721
+ return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
15363
15722
  }
15364
15723
 
15365
- finishTopicReference(node, start, pipeProposal, tokenType) {
15366
- if (this.testTopicReferenceConfiguration(pipeProposal, start, tokenType)) {
15367
- var nodeType;
15368
-
15369
- if (pipeProposal === "smart") {
15370
- nodeType = "PipelinePrimaryTopicReference";
15371
- } else {
15372
- nodeType = "TopicReference";
15373
- }
15724
+ finishTopicReference(node, startLoc, pipeProposal, tokenType) {
15725
+ if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
15726
+ var nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
15374
15727
 
15375
15728
  if (!this.topicReferenceIsAllowedInCurrentContext()) {
15376
- if (pipeProposal === "smart") {
15377
- this.raise(start, ErrorMessages.PrimaryTopicNotAllowed);
15378
- } else {
15379
- this.raise(start, ErrorMessages.PipeTopicUnbound);
15380
- }
15729
+ this.raise(pipeProposal === "smart" ? ErrorMessages.PrimaryTopicNotAllowed : ErrorMessages.PipeTopicUnbound, {
15730
+ at: startLoc
15731
+ });
15381
15732
  }
15382
15733
 
15383
15734
  this.registerTopicReference();
15384
15735
  return this.finishNode(node, nodeType);
15385
15736
  } else {
15386
- throw this.raise(start, ErrorMessages.PipeTopicUnconfiguredToken, tokenLabelName(tokenType));
15737
+ throw this.raise(ErrorMessages.PipeTopicUnconfiguredToken, {
15738
+ at: startLoc
15739
+ }, tokenLabelName(tokenType));
15387
15740
  }
15388
15741
  }
15389
15742
 
15390
- testTopicReferenceConfiguration(pipeProposal, start, tokenType) {
15743
+ testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
15391
15744
  switch (pipeProposal) {
15392
15745
  case "hack":
15393
15746
  {
@@ -15400,7 +15753,9 @@ class ExpressionParser extends LValParser {
15400
15753
  return tokenType === 27;
15401
15754
 
15402
15755
  default:
15403
- throw this.raise(start, ErrorMessages.PipeTopicRequiresHackPipes);
15756
+ throw this.raise(ErrorMessages.PipeTopicRequiresHackPipes, {
15757
+ at: startLoc
15758
+ });
15404
15759
  }
15405
15760
  }
15406
15761
 
@@ -15410,7 +15765,9 @@ class ExpressionParser extends LValParser {
15410
15765
  this.prodParam.exit();
15411
15766
 
15412
15767
  if (this.hasPrecedingLineBreak()) {
15413
- this.raise(this.state.pos, ErrorMessages.LineTerminatorBeforeArrow);
15768
+ this.raise(ErrorMessages.LineTerminatorBeforeArrow, {
15769
+ at: this.state.curPosition()
15770
+ });
15414
15771
  }
15415
15772
 
15416
15773
  this.expect(19);
@@ -15447,13 +15804,19 @@ class ExpressionParser extends LValParser {
15447
15804
  this.next();
15448
15805
 
15449
15806
  if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
15450
- this.raise(node.start, ErrorMessages.SuperNotAllowed);
15807
+ this.raise(ErrorMessages.SuperNotAllowed, {
15808
+ node
15809
+ });
15451
15810
  } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
15452
- this.raise(node.start, ErrorMessages.UnexpectedSuper);
15811
+ this.raise(ErrorMessages.UnexpectedSuper, {
15812
+ node
15813
+ });
15453
15814
  }
15454
15815
 
15455
15816
  if (!this.match(10) && !this.match(0) && !this.match(16)) {
15456
- this.raise(node.start, ErrorMessages.UnsupportedSuper);
15817
+ this.raise(ErrorMessages.UnsupportedSuper, {
15818
+ node
15819
+ });
15457
15820
  }
15458
15821
 
15459
15822
  return this.finishNode(node, "Super");
@@ -15461,7 +15824,7 @@ class ExpressionParser extends LValParser {
15461
15824
 
15462
15825
  parsePrivateName() {
15463
15826
  var node = this.startNode();
15464
- var id = this.startNodeAt(this.state.start + 1, new Position(this.state.curLine, this.state.start + 1 - this.state.lineStart));
15827
+ var id = this.startNodeAt(this.state.start + 1, new Position(this.state.curLine, this.state.start + 1 - this.state.lineStart, this.state.start + 1));
15465
15828
  var name = this.state.value;
15466
15829
  this.next();
15467
15830
  node.id = this.createIdentifier(id, name);
@@ -15494,7 +15857,9 @@ class ExpressionParser extends LValParser {
15494
15857
  node.property = this.parseIdentifier(true);
15495
15858
 
15496
15859
  if (node.property.name !== propertyName || containsEsc) {
15497
- this.raise(node.property.start, ErrorMessages.UnsupportedMetaProperty, meta.name, propertyName);
15860
+ this.raise(ErrorMessages.UnsupportedMetaProperty, {
15861
+ node: node.property
15862
+ }, meta.name, propertyName);
15498
15863
  }
15499
15864
 
15500
15865
  return this.finishNode(node, "MetaProperty");
@@ -15506,7 +15871,9 @@ class ExpressionParser extends LValParser {
15506
15871
 
15507
15872
  if (this.isContextual(96)) {
15508
15873
  if (!this.inModule) {
15509
- this.raise(id.start, SourceTypeModuleErrorMessages.ImportMetaOutsideModule);
15874
+ this.raise(SourceTypeModuleErrorMessages.ImportMetaOutsideModule, {
15875
+ node: id
15876
+ });
15510
15877
  }
15511
15878
 
15512
15879
  this.sawUnambiguousESM = true;
@@ -15579,17 +15946,17 @@ class ExpressionParser extends LValParser {
15579
15946
  var exprList = [];
15580
15947
  var refExpressionErrors = new ExpressionErrors();
15581
15948
  var first = true;
15582
- var spreadStart;
15583
- var optionalCommaStart;
15949
+ var spreadStartLoc;
15950
+ var optionalCommaStartLoc;
15584
15951
 
15585
15952
  while (!this.match(11)) {
15586
15953
  if (first) {
15587
15954
  first = false;
15588
15955
  } else {
15589
- this.expect(12, refExpressionErrors.optionalParameters === -1 ? null : refExpressionErrors.optionalParameters);
15956
+ this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
15590
15957
 
15591
15958
  if (this.match(11)) {
15592
- optionalCommaStart = this.state.start;
15959
+ optionalCommaStartLoc = this.state.startLoc;
15593
15960
  break;
15594
15961
  }
15595
15962
  }
@@ -15597,16 +15964,17 @@ class ExpressionParser extends LValParser {
15597
15964
  if (this.match(21)) {
15598
15965
  var spreadNodeStartPos = this.state.start;
15599
15966
  var spreadNodeStartLoc = this.state.startLoc;
15600
- spreadStart = this.state.start;
15967
+ spreadStartLoc = this.state.startLoc;
15601
15968
  exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc));
15602
- this.checkCommaAfterRest(41);
15603
- break;
15969
+
15970
+ if (!this.checkCommaAfterRest(41)) {
15971
+ break;
15972
+ }
15604
15973
  } else {
15605
15974
  exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
15606
15975
  }
15607
15976
  }
15608
15977
 
15609
- var innerEndPos = this.state.lastTokEnd;
15610
15978
  var innerEndLoc = this.state.lastTokEndLoc;
15611
15979
  this.expect(11);
15612
15980
  this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
@@ -15623,11 +15991,11 @@ class ExpressionParser extends LValParser {
15623
15991
  this.expressionScope.exit();
15624
15992
 
15625
15993
  if (!exprList.length) {
15626
- this.unexpected(this.state.lastTokStart);
15994
+ this.unexpected(this.state.lastTokStartLoc);
15627
15995
  }
15628
15996
 
15629
- if (optionalCommaStart) this.unexpected(optionalCommaStart);
15630
- if (spreadStart) this.unexpected(spreadStart);
15997
+ if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
15998
+ if (spreadStartLoc) this.unexpected(spreadStartLoc);
15631
15999
  this.checkExpressionErrors(refExpressionErrors, true);
15632
16000
  this.toReferencedListDeep(exprList, true);
15633
16001
 
@@ -15635,7 +16003,7 @@ class ExpressionParser extends LValParser {
15635
16003
  val = this.startNodeAt(innerStartPos, innerStartLoc);
15636
16004
  val.expressions = exprList;
15637
16005
  this.finishNode(val, "SequenceExpression");
15638
- this.resetEndLocation(val, innerEndPos, innerEndLoc);
16006
+ this.resetEndLocation(val, innerEndLoc);
15639
16007
  } else {
15640
16008
  val = exprList[0];
15641
16009
  }
@@ -15643,7 +16011,7 @@ class ExpressionParser extends LValParser {
15643
16011
  if (!this.options.createParenthesizedExpressions) {
15644
16012
  this.addExtra(val, "parenthesized", true);
15645
16013
  this.addExtra(val, "parenStart", startPos);
15646
- this.takeSurroundingComments(val, startPos, this.state.lastTokEnd);
16014
+ this.takeSurroundingComments(val, startPos, indexes.get(this.state.lastTokEndLoc));
15647
16015
  return val;
15648
16016
  }
15649
16017
 
@@ -15677,7 +16045,9 @@ class ExpressionParser extends LValParser {
15677
16045
  var metaProp = this.parseMetaProperty(node, meta, "target");
15678
16046
 
15679
16047
  if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
15680
- this.raise(metaProp.start, ErrorMessages.UnexpectedNewTarget);
16048
+ this.raise(ErrorMessages.UnexpectedNewTarget, {
16049
+ node: metaProp
16050
+ });
15681
16051
  }
15682
16052
 
15683
16053
  return metaProp;
@@ -15690,11 +16060,17 @@ class ExpressionParser extends LValParser {
15690
16060
  node.callee = this.parseNoCallExpr();
15691
16061
 
15692
16062
  if (node.callee.type === "Import") {
15693
- this.raise(node.callee.start, ErrorMessages.ImportCallNotNewExpression);
16063
+ this.raise(ErrorMessages.ImportCallNotNewExpression, {
16064
+ node: node.callee
16065
+ });
15694
16066
  } else if (this.isOptionalChain(node.callee)) {
15695
- this.raise(this.state.lastTokEnd, ErrorMessages.OptionalChainingNoNew);
16067
+ this.raise(ErrorMessages.OptionalChainingNoNew, {
16068
+ at: this.state.lastTokEndLoc
16069
+ });
15696
16070
  } else if (this.eat(18)) {
15697
- this.raise(this.state.start, ErrorMessages.OptionalChainingNoNew);
16071
+ this.raise(ErrorMessages.OptionalChainingNoNew, {
16072
+ at: this.state.startLoc
16073
+ });
15698
16074
  }
15699
16075
 
15700
16076
  this.parseNewArguments(node);
@@ -15714,15 +16090,18 @@ class ExpressionParser extends LValParser {
15714
16090
  parseTemplateElement(isTagged) {
15715
16091
  var {
15716
16092
  start,
16093
+ startLoc,
15717
16094
  end,
15718
16095
  value
15719
16096
  } = this.state;
15720
16097
  var elemStart = start + 1;
15721
- var elem = this.startNodeAt(elemStart, createPositionWithColumnOffset(this.state.startLoc, 1));
16098
+ var elem = this.startNodeAt(elemStart, createPositionWithColumnOffset(startLoc, 1));
15722
16099
 
15723
16100
  if (value === null) {
15724
16101
  if (!isTagged) {
15725
- this.raise(start + 2, ErrorMessages.InvalidEscapeSequenceTemplate);
16102
+ this.raise(ErrorMessages.InvalidEscapeSequenceTemplate, {
16103
+ at: createPositionWithColumnOffset(startLoc, 2)
16104
+ });
15726
16105
  }
15727
16106
  }
15728
16107
 
@@ -15736,7 +16115,7 @@ class ExpressionParser extends LValParser {
15736
16115
  elem.tail = isTail;
15737
16116
  this.next();
15738
16117
  this.finishNode(elem, "TemplateElement");
15739
- this.resetEndLocation(elem, elemEnd, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
16118
+ this.resetEndLocation(elem, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
15740
16119
  return elem;
15741
16120
  }
15742
16121
 
@@ -15779,7 +16158,7 @@ class ExpressionParser extends LValParser {
15779
16158
  this.expect(12);
15780
16159
 
15781
16160
  if (this.match(close)) {
15782
- this.addExtra(node, "trailingComma", this.state.lastTokStart);
16161
+ this.addTrailingCommaExtraToNode(node);
15783
16162
  break;
15784
16163
  }
15785
16164
  }
@@ -15794,7 +16173,9 @@ class ExpressionParser extends LValParser {
15794
16173
  }
15795
16174
 
15796
16175
  if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
15797
- this.raise(prop.start, ErrorMessages.InvalidRecordProperty);
16176
+ this.raise(ErrorMessages.InvalidRecordProperty, {
16177
+ node: prop
16178
+ });
15798
16179
  }
15799
16180
 
15800
16181
  if (prop.shorthand) {
@@ -15817,6 +16198,11 @@ class ExpressionParser extends LValParser {
15817
16198
  return this.finishNode(node, type);
15818
16199
  }
15819
16200
 
16201
+ addTrailingCommaExtraToNode(node) {
16202
+ this.addExtra(node, "trailingComma", this.state.lastTokStart);
16203
+ this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
16204
+ }
16205
+
15820
16206
  maybeAsyncOrAccessorProp(prop) {
15821
16207
  return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(51));
15822
16208
  }
@@ -15826,7 +16212,9 @@ class ExpressionParser extends LValParser {
15826
16212
 
15827
16213
  if (this.match(26)) {
15828
16214
  if (this.hasPlugin("decorators")) {
15829
- this.raise(this.state.start, ErrorMessages.UnsupportedPropertyDecorator);
16215
+ this.raise(ErrorMessages.UnsupportedPropertyDecorator, {
16216
+ at: this.state.startLoc
16217
+ });
15830
16218
  }
15831
16219
 
15832
16220
  while (this.match(26)) {
@@ -15879,7 +16267,9 @@ class ExpressionParser extends LValParser {
15879
16267
 
15880
16268
  if (this.match(51)) {
15881
16269
  isGenerator = true;
15882
- this.raise(this.state.pos, ErrorMessages.AccessorIsGenerator, keyName);
16270
+ this.raise(ErrorMessages.AccessorIsGenerator, {
16271
+ at: this.state.curPosition()
16272
+ }, keyName);
15883
16273
  this.next();
15884
16274
  }
15885
16275
 
@@ -15904,18 +16294,17 @@ class ExpressionParser extends LValParser {
15904
16294
 
15905
16295
  var paramCount = this.getGetterSetterExpectedParamCount(method);
15906
16296
  var params = this.getObjectOrClassMethodParams(method);
15907
- var start = method.start;
15908
16297
 
15909
16298
  if (params.length !== paramCount) {
15910
- if (method.kind === "get") {
15911
- this.raise(start, ErrorMessages.BadGetterArity);
15912
- } else {
15913
- this.raise(start, ErrorMessages.BadSetterArity);
15914
- }
16299
+ this.raise(method.kind === "get" ? ErrorMessages.BadGetterArity : ErrorMessages.BadSetterArity, {
16300
+ node: method
16301
+ });
15915
16302
  }
15916
16303
 
15917
16304
  if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
15918
- this.raise(start, ErrorMessages.BadSetterRestParameter);
16305
+ this.raise(ErrorMessages.BadSetterRestParameter, {
16306
+ node: method
16307
+ });
15919
16308
  }
15920
16309
  }
15921
16310
 
@@ -15943,19 +16332,21 @@ class ExpressionParser extends LValParser {
15943
16332
  }
15944
16333
 
15945
16334
  if (!prop.computed && prop.key.type === "Identifier") {
15946
- this.checkReservedWord(prop.key.name, prop.key.start, true, false);
16335
+ this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
15947
16336
 
15948
16337
  if (isPattern) {
15949
16338
  prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
15950
16339
  } else if (this.match(29)) {
15951
- var shorthandAssign = this.state.start;
16340
+ var shorthandAssignLoc = this.state.startLoc;
15952
16341
 
15953
16342
  if (refExpressionErrors != null) {
15954
- if (refExpressionErrors.shorthandAssign === -1) {
15955
- refExpressionErrors.shorthandAssign = shorthandAssign;
16343
+ if (refExpressionErrors.shorthandAssignLoc === null) {
16344
+ refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
15956
16345
  }
15957
16346
  } else {
15958
- this.raise(shorthandAssign, ErrorMessages.InvalidCoverInitializedName);
16347
+ this.raise(ErrorMessages.InvalidCoverInitializedName, {
16348
+ at: shorthandAssignLoc
16349
+ });
15959
16350
  }
15960
16351
 
15961
16352
  prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
@@ -16008,8 +16399,9 @@ class ExpressionParser extends LValParser {
16008
16399
 
16009
16400
  case 130:
16010
16401
  {
16011
- var privateKeyPos = this.state.start + 1;
16012
- this.raise(privateKeyPos, ErrorMessages.UnexpectedPrivateField);
16402
+ this.raise(ErrorMessages.UnexpectedPrivateField, {
16403
+ at: createPositionWithColumnOffset(this.state.startLoc, 1)
16404
+ });
16013
16405
  key = this.parsePrivateName();
16014
16406
  break;
16015
16407
  }
@@ -16063,11 +16455,11 @@ class ExpressionParser extends LValParser {
16063
16455
  return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
16064
16456
  }
16065
16457
 
16066
- parseArrowExpression(node, params, isAsync, trailingCommaPos) {
16458
+ parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
16067
16459
  this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
16068
16460
  var flags = functionFlags(isAsync, false);
16069
16461
 
16070
- if (!this.match(0) && this.prodParam.hasIn) {
16462
+ if (!this.match(5) && this.prodParam.hasIn) {
16071
16463
  flags |= PARAM_IN;
16072
16464
  }
16073
16465
 
@@ -16077,7 +16469,7 @@ class ExpressionParser extends LValParser {
16077
16469
 
16078
16470
  if (params) {
16079
16471
  this.state.maybeInArrowParameters = true;
16080
- this.setArrowFunctionParameters(node, params, trailingCommaPos);
16472
+ this.setArrowFunctionParameters(node, params, trailingCommaLoc);
16081
16473
  }
16082
16474
 
16083
16475
  this.state.maybeInArrowParameters = false;
@@ -16088,8 +16480,8 @@ class ExpressionParser extends LValParser {
16088
16480
  return this.finishNode(node, "ArrowFunctionExpression");
16089
16481
  }
16090
16482
 
16091
- setArrowFunctionParameters(node, params, trailingCommaPos) {
16092
- node.params = this.toAssignableList(params, trailingCommaPos, false);
16483
+ setArrowFunctionParameters(node, params, trailingCommaLoc) {
16484
+ node.params = this.toAssignableList(params, trailingCommaLoc, false);
16093
16485
  }
16094
16486
 
16095
16487
  parseFunctionBodyAndFinish(node, type) {
@@ -16115,8 +16507,12 @@ class ExpressionParser extends LValParser {
16115
16507
  var nonSimple = !this.isSimpleParamList(node.params);
16116
16508
 
16117
16509
  if (hasStrictModeDirective && nonSimple) {
16118
- var errorPos = (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.end : node.start;
16119
- this.raise(errorPos, ErrorMessages.IllegalLanguageModeDirective);
16510
+ var errorOrigin = (node.kind === "method" || node.kind === "constructor") && !!node.key ? {
16511
+ at: node.key.loc.end
16512
+ } : {
16513
+ node
16514
+ };
16515
+ this.raise(ErrorMessages.IllegalLanguageModeDirective, errorOrigin);
16120
16516
  }
16121
16517
 
16122
16518
  var strictModeChanged = !oldStrict && this.state.strict;
@@ -16162,7 +16558,7 @@ class ExpressionParser extends LValParser {
16162
16558
 
16163
16559
  if (this.match(close)) {
16164
16560
  if (nodeForExtra) {
16165
- this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart);
16561
+ this.addTrailingCommaExtraToNode(nodeForExtra);
16166
16562
  }
16167
16563
 
16168
16564
  this.next();
@@ -16181,7 +16577,9 @@ class ExpressionParser extends LValParser {
16181
16577
 
16182
16578
  if (this.match(12)) {
16183
16579
  if (!allowEmpty) {
16184
- this.raise(this.state.pos, ErrorMessages.UnexpectedToken, ",");
16580
+ this.raise(ErrorMessages.UnexpectedToken, {
16581
+ at: this.state.curPosition()
16582
+ }, ",");
16185
16583
  }
16186
16584
 
16187
16585
  elt = null;
@@ -16193,7 +16591,9 @@ class ExpressionParser extends LValParser {
16193
16591
  this.expectPlugin("partialApplication");
16194
16592
 
16195
16593
  if (!allowPlaceholder) {
16196
- this.raise(this.state.start, ErrorMessages.UnexpectedArgumentPlaceholder);
16594
+ this.raise(ErrorMessages.UnexpectedArgumentPlaceholder, {
16595
+ at: this.state.startLoc
16596
+ });
16197
16597
  }
16198
16598
 
16199
16599
  var node = this.startNode();
@@ -16221,7 +16621,7 @@ class ExpressionParser extends LValParser {
16221
16621
  parseIdentifierName(pos, liberal) {
16222
16622
  var name;
16223
16623
  var {
16224
- start,
16624
+ startLoc,
16225
16625
  type
16226
16626
  } = this.state;
16227
16627
 
@@ -16238,7 +16638,7 @@ class ExpressionParser extends LValParser {
16238
16638
  this.replaceToken(124);
16239
16639
  }
16240
16640
  } else {
16241
- this.checkReservedWord(name, start, tokenIsKeyword, false);
16641
+ this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
16242
16642
  }
16243
16643
 
16244
16644
  this.next();
@@ -16256,35 +16656,49 @@ class ExpressionParser extends LValParser {
16256
16656
 
16257
16657
  if (word === "yield") {
16258
16658
  if (this.prodParam.hasYield) {
16259
- this.raise(startLoc, ErrorMessages.YieldBindingIdentifier);
16659
+ this.raise(ErrorMessages.YieldBindingIdentifier, {
16660
+ at: startLoc
16661
+ });
16260
16662
  return;
16261
16663
  }
16262
16664
  } else if (word === "await") {
16263
16665
  if (this.prodParam.hasAwait) {
16264
- this.raise(startLoc, ErrorMessages.AwaitBindingIdentifier);
16666
+ this.raise(ErrorMessages.AwaitBindingIdentifier, {
16667
+ at: startLoc
16668
+ });
16265
16669
  return;
16266
- } else if (this.scope.inStaticBlock) {
16267
- this.raise(startLoc, ErrorMessages.AwaitBindingIdentifierInStaticBlock);
16670
+ }
16671
+
16672
+ if (this.scope.inStaticBlock) {
16673
+ this.raise(ErrorMessages.AwaitBindingIdentifierInStaticBlock, {
16674
+ at: startLoc
16675
+ });
16268
16676
  return;
16269
- } else {
16270
- this.expressionScope.recordAsyncArrowParametersError(startLoc, ErrorMessages.AwaitBindingIdentifier);
16271
16677
  }
16678
+
16679
+ this.expressionScope.recordAsyncArrowParametersError(ErrorMessages.AwaitBindingIdentifier, startLoc);
16272
16680
  } else if (word === "arguments") {
16273
16681
  if (this.scope.inClassAndNotInNonArrowFunction) {
16274
- this.raise(startLoc, ErrorMessages.ArgumentsInClass);
16682
+ this.raise(ErrorMessages.ArgumentsInClass, {
16683
+ at: startLoc
16684
+ });
16275
16685
  return;
16276
16686
  }
16277
16687
  }
16278
16688
 
16279
16689
  if (checkKeywords && isKeyword(word)) {
16280
- this.raise(startLoc, ErrorMessages.UnexpectedKeyword, word);
16690
+ this.raise(ErrorMessages.UnexpectedKeyword, {
16691
+ at: startLoc
16692
+ }, word);
16281
16693
  return;
16282
16694
  }
16283
16695
 
16284
16696
  var reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
16285
16697
 
16286
16698
  if (reservedTest(word, this.inModule)) {
16287
- this.raise(startLoc, ErrorMessages.UnexpectedReservedWord, word);
16699
+ this.raise(ErrorMessages.UnexpectedReservedWord, {
16700
+ at: startLoc
16701
+ }, word);
16288
16702
  }
16289
16703
  }
16290
16704
 
@@ -16300,10 +16714,12 @@ class ExpressionParser extends LValParser {
16300
16714
 
16301
16715
  parseAwait(startPos, startLoc) {
16302
16716
  var node = this.startNodeAt(startPos, startLoc);
16303
- this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.AwaitExpressionFormalParameter);
16717
+ this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.AwaitExpressionFormalParameter);
16304
16718
 
16305
16719
  if (this.eat(51)) {
16306
- this.raise(node.start, ErrorMessages.ObsoleteAwaitStar);
16720
+ this.raise(ErrorMessages.ObsoleteAwaitStar, {
16721
+ node
16722
+ });
16307
16723
  }
16308
16724
 
16309
16725
  if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
@@ -16331,7 +16747,7 @@ class ExpressionParser extends LValParser {
16331
16747
 
16332
16748
  parseYield() {
16333
16749
  var node = this.startNode();
16334
- this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.YieldInParameter);
16750
+ this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.YieldInParameter);
16335
16751
  this.next();
16336
16752
  var delegating = false;
16337
16753
  var argument = null;
@@ -16360,22 +16776,18 @@ class ExpressionParser extends LValParser {
16360
16776
  return this.finishNode(node, "YieldExpression");
16361
16777
  }
16362
16778
 
16363
- checkPipelineAtInfixOperator(left, leftStartPos) {
16779
+ checkPipelineAtInfixOperator(left, leftStartLoc) {
16364
16780
  if (this.hasPlugin(["pipelineOperator", {
16365
16781
  proposal: "smart"
16366
16782
  }])) {
16367
16783
  if (left.type === "SequenceExpression") {
16368
- this.raise(leftStartPos, ErrorMessages.PipelineHeadSequenceExpression);
16784
+ this.raise(ErrorMessages.PipelineHeadSequenceExpression, {
16785
+ at: leftStartLoc
16786
+ });
16369
16787
  }
16370
16788
  }
16371
16789
  }
16372
16790
 
16373
- checkHackPipeBodyEarlyErrors(startPos) {
16374
- if (!this.topicReferenceWasUsedInCurrentContext()) {
16375
- this.raise(startPos, ErrorMessages.PipeTopicUnused);
16376
- }
16377
- }
16378
-
16379
16791
  parseSmartPipelineBodyInStyle(childExpr, startPos, startLoc) {
16380
16792
  var bodyNode = this.startNodeAt(startPos, startLoc);
16381
16793
 
@@ -16383,7 +16795,7 @@ class ExpressionParser extends LValParser {
16383
16795
  bodyNode.callee = childExpr;
16384
16796
  return this.finishNode(bodyNode, "PipelineBareFunction");
16385
16797
  } else {
16386
- this.checkSmartPipeTopicBodyEarlyErrors(startPos);
16798
+ this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
16387
16799
  bodyNode.expression = childExpr;
16388
16800
  return this.finishNode(bodyNode, "PipelineTopicExpression");
16389
16801
  }
@@ -16402,11 +16814,17 @@ class ExpressionParser extends LValParser {
16402
16814
  }
16403
16815
  }
16404
16816
 
16405
- checkSmartPipeTopicBodyEarlyErrors(startPos) {
16817
+ checkSmartPipeTopicBodyEarlyErrors(startLoc) {
16406
16818
  if (this.match(19)) {
16407
- throw this.raise(this.state.start, ErrorMessages.PipelineBodyNoArrow);
16408
- } else if (!this.topicReferenceWasUsedInCurrentContext()) {
16409
- this.raise(startPos, ErrorMessages.PipelineTopicUnused);
16819
+ throw this.raise(ErrorMessages.PipelineBodyNoArrow, {
16820
+ at: this.state.startLoc
16821
+ });
16822
+ }
16823
+
16824
+ if (!this.topicReferenceWasUsedInCurrentContext()) {
16825
+ this.raise(ErrorMessages.PipelineTopicUnused, {
16826
+ at: startLoc
16827
+ });
16410
16828
  }
16411
16829
  }
16412
16830
 
@@ -16686,9 +17104,10 @@ class StatementParser extends ExpressionParser {
16686
17104
  this.parseBlockBody(program, true, true, end);
16687
17105
 
16688
17106
  if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
16689
- for (var [name] of Array.from(this.scope.undefinedExports)) {
16690
- var pos = this.scope.undefinedExports.get(name);
16691
- this.raise(pos, ErrorMessages.ModuleExportUndefined, name);
17107
+ for (var [name, loc] of Array.from(this.scope.undefinedExports)) {
17108
+ this.raise(ErrorMessages.ModuleExportUndefined, {
17109
+ at: loc
17110
+ }, name);
16692
17111
  }
16693
17112
  }
16694
17113
 
@@ -16797,9 +17216,13 @@ class StatementParser extends ExpressionParser {
16797
17216
 
16798
17217
  if (context) {
16799
17218
  if (this.state.strict) {
16800
- this.raise(this.state.start, ErrorMessages.StrictFunction);
17219
+ this.raise(ErrorMessages.StrictFunction, {
17220
+ at: this.state.startLoc
17221
+ });
16801
17222
  } else if (context !== "if" && context !== "label") {
16802
- this.raise(this.state.start, ErrorMessages.SloppyFunction);
17223
+ this.raise(ErrorMessages.SloppyFunction, {
17224
+ at: this.state.startLoc
17225
+ });
16803
17226
  }
16804
17227
  }
16805
17228
 
@@ -16829,7 +17252,9 @@ class StatementParser extends ExpressionParser {
16829
17252
  kind = kind || this.state.value;
16830
17253
 
16831
17254
  if (context && kind !== "var") {
16832
- this.raise(this.state.start, ErrorMessages.UnexpectedLexicalDeclaration);
17255
+ this.raise(ErrorMessages.UnexpectedLexicalDeclaration, {
17256
+ at: this.state.startLoc
17257
+ });
16833
17258
  }
16834
17259
 
16835
17260
  return this.parseVarStatement(node, kind);
@@ -16858,7 +17283,9 @@ class StatementParser extends ExpressionParser {
16858
17283
  case 78:
16859
17284
  {
16860
17285
  if (!this.options.allowImportExportEverywhere && !topLevel) {
16861
- this.raise(this.state.start, ErrorMessages.UnexpectedImportExport);
17286
+ this.raise(ErrorMessages.UnexpectedImportExport, {
17287
+ at: this.state.startLoc
17288
+ });
16862
17289
  }
16863
17290
 
16864
17291
  this.next();
@@ -16886,7 +17313,9 @@ class StatementParser extends ExpressionParser {
16886
17313
  {
16887
17314
  if (this.isAsyncFunction()) {
16888
17315
  if (context) {
16889
- this.raise(this.state.start, ErrorMessages.AsyncFunctionInSingleStatementContext);
17316
+ this.raise(ErrorMessages.AsyncFunctionInSingleStatementContext, {
17317
+ at: this.state.startLoc
17318
+ });
16890
17319
  }
16891
17320
 
16892
17321
  this.next();
@@ -16907,7 +17336,9 @@ class StatementParser extends ExpressionParser {
16907
17336
 
16908
17337
  assertModuleNodeAllowed(node) {
16909
17338
  if (!this.options.allowImportExportEverywhere && !this.inModule) {
16910
- this.raise(node.start, SourceTypeModuleErrorMessages.ImportOutsideModule);
17339
+ this.raise(SourceTypeModuleErrorMessages.ImportOutsideModule, {
17340
+ node
17341
+ });
16911
17342
  }
16912
17343
  }
16913
17344
 
@@ -16939,10 +17370,14 @@ class StatementParser extends ExpressionParser {
16939
17370
  }
16940
17371
 
16941
17372
  if (this.hasPlugin("decorators") && !this.getPluginOption("decorators", "decoratorsBeforeExport")) {
16942
- this.raise(this.state.start, ErrorMessages.DecoratorExportClass);
17373
+ this.raise(ErrorMessages.DecoratorExportClass, {
17374
+ at: this.state.startLoc
17375
+ });
16943
17376
  }
16944
17377
  } else if (!this.canHaveLeadingDecorator()) {
16945
- throw this.raise(this.state.start, ErrorMessages.UnexpectedLeadingDecorator);
17378
+ throw this.raise(ErrorMessages.UnexpectedLeadingDecorator, {
17379
+ at: this.state.startLoc
17380
+ });
16946
17381
  }
16947
17382
  }
16948
17383
 
@@ -17021,7 +17456,9 @@ class StatementParser extends ExpressionParser {
17021
17456
  }
17022
17457
 
17023
17458
  if (i === this.state.labels.length) {
17024
- this.raise(node.start, ErrorMessages.IllegalBreakContinue, isBreak ? "break" : "continue");
17459
+ this.raise(ErrorMessages.IllegalBreakContinue, {
17460
+ node
17461
+ }, isBreak ? "break" : "continue");
17025
17462
  }
17026
17463
  }
17027
17464
 
@@ -17052,17 +17489,17 @@ class StatementParser extends ExpressionParser {
17052
17489
  parseForStatement(node) {
17053
17490
  this.next();
17054
17491
  this.state.labels.push(loopLabel);
17055
- var awaitAt = -1;
17492
+ var awaitAt = null;
17056
17493
 
17057
17494
  if (this.isAwaitAllowed() && this.eatContextual(92)) {
17058
- awaitAt = this.state.lastTokStart;
17495
+ awaitAt = this.state.lastTokStartLoc;
17059
17496
  }
17060
17497
 
17061
17498
  this.scope.enter(SCOPE_OTHER);
17062
17499
  this.expect(10);
17063
17500
 
17064
17501
  if (this.match(13)) {
17065
- if (awaitAt > -1) {
17502
+ if (awaitAt !== null) {
17066
17503
  this.unexpected(awaitAt);
17067
17504
  }
17068
17505
 
@@ -17084,7 +17521,7 @@ class StatementParser extends ExpressionParser {
17084
17521
  return this.parseForIn(node, _init, awaitAt);
17085
17522
  }
17086
17523
 
17087
- if (awaitAt > -1) {
17524
+ if (awaitAt !== null) {
17088
17525
  this.unexpected(awaitAt);
17089
17526
  }
17090
17527
 
@@ -17098,9 +17535,15 @@ class StatementParser extends ExpressionParser {
17098
17535
 
17099
17536
  if (isForOf) {
17100
17537
  if (startsWithLet) {
17101
- this.raise(init.start, ErrorMessages.ForOfLet);
17102
- } else if (awaitAt === -1 && startsWithAsync && init.type === "Identifier") {
17103
- this.raise(init.start, ErrorMessages.ForOfAsync);
17538
+ this.raise(ErrorMessages.ForOfLet, {
17539
+ node: init
17540
+ });
17541
+ }
17542
+
17543
+ if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
17544
+ this.raise(ErrorMessages.ForOfAsync, {
17545
+ node: init
17546
+ });
17104
17547
  }
17105
17548
  }
17106
17549
 
@@ -17113,7 +17556,7 @@ class StatementParser extends ExpressionParser {
17113
17556
  this.checkExpressionErrors(refExpressionErrors, true);
17114
17557
  }
17115
17558
 
17116
- if (awaitAt > -1) {
17559
+ if (awaitAt !== null) {
17117
17560
  this.unexpected(awaitAt);
17118
17561
  }
17119
17562
 
@@ -17135,7 +17578,9 @@ class StatementParser extends ExpressionParser {
17135
17578
 
17136
17579
  parseReturnStatement(node) {
17137
17580
  if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
17138
- this.raise(this.state.start, ErrorMessages.IllegalReturn);
17581
+ this.raise(ErrorMessages.IllegalReturn, {
17582
+ at: this.state.startLoc
17583
+ });
17139
17584
  }
17140
17585
 
17141
17586
  this.next();
@@ -17171,7 +17616,9 @@ class StatementParser extends ExpressionParser {
17171
17616
  cur.test = this.parseExpression();
17172
17617
  } else {
17173
17618
  if (sawDefault) {
17174
- this.raise(this.state.lastTokStart, ErrorMessages.MultipleDefaultsInSwitch);
17619
+ this.raise(ErrorMessages.MultipleDefaultsInSwitch, {
17620
+ at: this.state.lastTokStartLoc
17621
+ });
17175
17622
  }
17176
17623
 
17177
17624
  sawDefault = true;
@@ -17199,7 +17646,9 @@ class StatementParser extends ExpressionParser {
17199
17646
  this.next();
17200
17647
 
17201
17648
  if (this.hasPrecedingLineBreak()) {
17202
- this.raise(this.state.lastTokEnd, ErrorMessages.NewlineAfterThrow);
17649
+ this.raise(ErrorMessages.NewlineAfterThrow, {
17650
+ at: this.state.lastTokEndLoc
17651
+ });
17203
17652
  }
17204
17653
 
17205
17654
  node.argument = this.parseExpression();
@@ -17241,7 +17690,9 @@ class StatementParser extends ExpressionParser {
17241
17690
  node.finalizer = this.eat(63) ? this.parseBlock() : null;
17242
17691
 
17243
17692
  if (!node.handler && !node.finalizer) {
17244
- this.raise(node.start, ErrorMessages.NoCatchOrFinally);
17693
+ this.raise(ErrorMessages.NoCatchOrFinally, {
17694
+ node
17695
+ });
17245
17696
  }
17246
17697
 
17247
17698
  return this.finishNode(node, "TryStatement");
@@ -17265,7 +17716,9 @@ class StatementParser extends ExpressionParser {
17265
17716
 
17266
17717
  parseWithStatement(node) {
17267
17718
  if (this.state.strict) {
17268
- this.raise(this.state.start, ErrorMessages.StrictWith);
17719
+ this.raise(ErrorMessages.StrictWith, {
17720
+ at: this.state.startLoc
17721
+ });
17269
17722
  }
17270
17723
 
17271
17724
  this.next();
@@ -17282,7 +17735,9 @@ class StatementParser extends ExpressionParser {
17282
17735
  parseLabeledStatement(node, maybeName, expr, context) {
17283
17736
  for (var label of this.state.labels) {
17284
17737
  if (label.name === maybeName) {
17285
- this.raise(expr.start, ErrorMessages.LabelRedeclaration, maybeName);
17738
+ this.raise(ErrorMessages.LabelRedeclaration, {
17739
+ node: expr
17740
+ }, maybeName);
17286
17741
  }
17287
17742
  }
17288
17743
 
@@ -17408,15 +17863,21 @@ class StatementParser extends ExpressionParser {
17408
17863
  this.next();
17409
17864
 
17410
17865
  if (isForIn) {
17411
- if (awaitAt > -1) this.unexpected(awaitAt);
17866
+ if (awaitAt !== null) this.unexpected(awaitAt);
17412
17867
  } else {
17413
- node.await = awaitAt > -1;
17868
+ node.await = awaitAt !== null;
17414
17869
  }
17415
17870
 
17416
17871
  if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
17417
- this.raise(init.start, ErrorMessages.ForInOfLoopInitializer, isForIn ? "for-in" : "for-of");
17418
- } else if (init.type === "AssignmentPattern") {
17419
- this.raise(init.start, ErrorMessages.InvalidLhs, "for-loop");
17872
+ this.raise(ErrorMessages.ForInOfLoopInitializer, {
17873
+ node: init
17874
+ }, isForIn ? "for-in" : "for-of");
17875
+ }
17876
+
17877
+ if (init.type === "AssignmentPattern") {
17878
+ this.raise(ErrorMessages.InvalidLhs, {
17879
+ node: init
17880
+ }, "for-loop");
17420
17881
  }
17421
17882
 
17422
17883
  node.left = init;
@@ -17442,10 +17903,14 @@ class StatementParser extends ExpressionParser {
17442
17903
  } else {
17443
17904
  if (kind === "const" && !(this.match(54) || this.isContextual(97))) {
17444
17905
  if (!isTypescript) {
17445
- this.raise(this.state.lastTokEnd, ErrorMessages.DeclarationMissingInitializer, "Const declarations");
17906
+ this.raise(ErrorMessages.DeclarationMissingInitializer, {
17907
+ at: this.state.lastTokEndLoc
17908
+ }, "Const declarations");
17446
17909
  }
17447
17910
  } else if (decl.id.type !== "Identifier" && !(isFor && (this.match(54) || this.isContextual(97)))) {
17448
- this.raise(this.state.lastTokEnd, ErrorMessages.DeclarationMissingInitializer, "Complex binding patterns");
17911
+ this.raise(ErrorMessages.DeclarationMissingInitializer, {
17912
+ at: this.state.lastTokEndLoc
17913
+ }, "Complex binding patterns");
17449
17914
  }
17450
17915
 
17451
17916
  decl.init = null;
@@ -17472,7 +17937,9 @@ class StatementParser extends ExpressionParser {
17472
17937
  this.initFunction(node, isAsync);
17473
17938
 
17474
17939
  if (this.match(51) && isHangingStatement) {
17475
- this.raise(this.state.start, ErrorMessages.GeneratorInSingleStatementContext);
17940
+ this.raise(ErrorMessages.GeneratorInSingleStatementContext, {
17941
+ at: this.state.startLoc
17942
+ });
17476
17943
  }
17477
17944
 
17478
17945
  node.generator = this.eat(51);
@@ -17518,7 +17985,7 @@ class StatementParser extends ExpressionParser {
17518
17985
 
17519
17986
  registerFunctionStatementId(node) {
17520
17987
  if (!node.id) return;
17521
- 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);
17988
+ 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);
17522
17989
  }
17523
17990
 
17524
17991
  parseClass(node, isStatement, optionalId) {
@@ -17558,7 +18025,9 @@ class StatementParser extends ExpressionParser {
17558
18025
  while (!this.match(8)) {
17559
18026
  if (this.eat(13)) {
17560
18027
  if (decorators.length > 0) {
17561
- throw this.raise(this.state.lastTokEnd, ErrorMessages.DecoratorSemicolon);
18028
+ throw this.raise(ErrorMessages.DecoratorSemicolon, {
18029
+ at: this.state.lastTokEndLoc
18030
+ });
17562
18031
  }
17563
18032
 
17564
18033
  continue;
@@ -17580,7 +18049,9 @@ class StatementParser extends ExpressionParser {
17580
18049
  this.parseClassMember(classBody, member, state);
17581
18050
 
17582
18051
  if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
17583
- this.raise(member.start, ErrorMessages.DecoratorConstructor);
18052
+ this.raise(ErrorMessages.DecoratorConstructor, {
18053
+ node: member
18054
+ });
17584
18055
  }
17585
18056
  }
17586
18057
  });
@@ -17588,7 +18059,9 @@ class StatementParser extends ExpressionParser {
17588
18059
  this.next();
17589
18060
 
17590
18061
  if (decorators.length) {
17591
- throw this.raise(this.state.start, ErrorMessages.TrailingDecorator);
18062
+ throw this.raise(ErrorMessages.TrailingDecorator, {
18063
+ at: this.state.startLoc
18064
+ });
17592
18065
  }
17593
18066
 
17594
18067
  this.classScope.exit();
@@ -17657,7 +18130,9 @@ class StatementParser extends ExpressionParser {
17657
18130
  }
17658
18131
 
17659
18132
  if (this.isNonstaticConstructor(publicMethod)) {
17660
- this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsGenerator);
18133
+ this.raise(ErrorMessages.ConstructorIsGenerator, {
18134
+ node: publicMethod.key
18135
+ });
17661
18136
  }
17662
18137
 
17663
18138
  this.pushClassMethod(classBody, publicMethod, true, false, false, false);
@@ -17667,7 +18142,7 @@ class StatementParser extends ExpressionParser {
17667
18142
  var isContextual = tokenIsIdentifier(this.state.type) && !this.state.containsEsc;
17668
18143
  var isPrivate = this.match(130);
17669
18144
  var key = this.parseClassElementName(member);
17670
- var maybeQuestionTokenStart = this.state.start;
18145
+ var maybeQuestionTokenStartLoc = this.state.startLoc;
17671
18146
  this.parsePostMemberNameModifiers(publicMember);
17672
18147
 
17673
18148
  if (this.isClassMethod()) {
@@ -17685,11 +18160,15 @@ class StatementParser extends ExpressionParser {
17685
18160
  publicMethod.kind = "constructor";
17686
18161
 
17687
18162
  if (state.hadConstructor && !this.hasPlugin("typescript")) {
17688
- this.raise(key.start, ErrorMessages.DuplicateConstructor);
18163
+ this.raise(ErrorMessages.DuplicateConstructor, {
18164
+ node: key
18165
+ });
17689
18166
  }
17690
18167
 
17691
18168
  if (isConstructor && this.hasPlugin("typescript") && member.override) {
17692
- this.raise(key.start, ErrorMessages.OverrideOnConstructor);
18169
+ this.raise(ErrorMessages.OverrideOnConstructor, {
18170
+ node: key
18171
+ });
17693
18172
  }
17694
18173
 
17695
18174
  state.hadConstructor = true;
@@ -17708,7 +18187,7 @@ class StatementParser extends ExpressionParser {
17708
18187
  var isGenerator = this.eat(51);
17709
18188
 
17710
18189
  if (publicMember.optional) {
17711
- this.unexpected(maybeQuestionTokenStart);
18190
+ this.unexpected(maybeQuestionTokenStartLoc);
17712
18191
  }
17713
18192
 
17714
18193
  method.kind = "method";
@@ -17722,7 +18201,9 @@ class StatementParser extends ExpressionParser {
17722
18201
  this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
17723
18202
  } else {
17724
18203
  if (this.isNonstaticConstructor(publicMethod)) {
17725
- this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsAsync);
18204
+ this.raise(ErrorMessages.ConstructorIsAsync, {
18205
+ node: publicMethod.key
18206
+ });
17726
18207
  }
17727
18208
 
17728
18209
  this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
@@ -17739,7 +18220,9 @@ class StatementParser extends ExpressionParser {
17739
18220
  this.pushClassPrivateMethod(classBody, privateMethod, false, false);
17740
18221
  } else {
17741
18222
  if (this.isNonstaticConstructor(publicMethod)) {
17742
- this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsAccessor);
18223
+ this.raise(ErrorMessages.ConstructorIsAccessor, {
18224
+ node: publicMethod.key
18225
+ });
17743
18226
  }
17744
18227
 
17745
18228
  this.pushClassMethod(classBody, publicMethod, false, false, false, false);
@@ -17760,17 +18243,20 @@ class StatementParser extends ExpressionParser {
17760
18243
  parseClassElementName(member) {
17761
18244
  var {
17762
18245
  type,
17763
- value,
17764
- start
18246
+ value
17765
18247
  } = this.state;
17766
18248
 
17767
18249
  if ((type === 124 || type === 125) && member.static && value === "prototype") {
17768
- this.raise(start, ErrorMessages.StaticPrototype);
18250
+ this.raise(ErrorMessages.StaticPrototype, {
18251
+ at: this.state.startLoc
18252
+ });
17769
18253
  }
17770
18254
 
17771
18255
  if (type === 130) {
17772
18256
  if (value === "constructor") {
17773
- this.raise(start, ErrorMessages.ConstructorClassPrivateField);
18257
+ this.raise(ErrorMessages.ConstructorClassPrivateField, {
18258
+ at: this.state.startLoc
18259
+ });
17774
18260
  }
17775
18261
 
17776
18262
  var key = this.parsePrivateName();
@@ -17796,13 +18282,17 @@ class StatementParser extends ExpressionParser {
17796
18282
  classBody.body.push(this.finishNode(member, "StaticBlock"));
17797
18283
 
17798
18284
  if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
17799
- this.raise(member.start, ErrorMessages.DecoratorStaticBlock);
18285
+ this.raise(ErrorMessages.DecoratorStaticBlock, {
18286
+ node: member
18287
+ });
17800
18288
  }
17801
18289
  }
17802
18290
 
17803
18291
  pushClassProperty(classBody, prop) {
17804
18292
  if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) {
17805
- this.raise(prop.key.start, ErrorMessages.ConstructorClassField);
18293
+ this.raise(ErrorMessages.ConstructorClassField, {
18294
+ node: prop.key
18295
+ });
17806
18296
  }
17807
18297
 
17808
18298
  classBody.body.push(this.parseClassProperty(prop));
@@ -17811,7 +18301,7 @@ class StatementParser extends ExpressionParser {
17811
18301
  pushClassPrivateProperty(classBody, prop) {
17812
18302
  var node = this.parseClassPrivateProperty(prop);
17813
18303
  classBody.body.push(node);
17814
- this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.start);
18304
+ this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.loc.start);
17815
18305
  }
17816
18306
 
17817
18307
  pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
@@ -17826,7 +18316,7 @@ class StatementParser extends ExpressionParser {
17826
18316
  }
17827
18317
 
17828
18318
  declareClassPrivateMethodInScope(node, kind) {
17829
- this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.start);
18319
+ this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
17830
18320
  }
17831
18321
 
17832
18322
  parsePostMemberNameModifiers(methodOrProp) {}
@@ -17866,7 +18356,9 @@ class StatementParser extends ExpressionParser {
17866
18356
  if (optionalId || !isStatement) {
17867
18357
  node.id = null;
17868
18358
  } else {
17869
- this.unexpected(null, ErrorMessages.MissingClassName);
18359
+ throw this.raise(ErrorMessages.MissingClassName, {
18360
+ at: this.state.startLoc
18361
+ });
17870
18362
  }
17871
18363
  }
17872
18364
  }
@@ -17999,22 +18491,32 @@ class StatementParser extends ExpressionParser {
17999
18491
  }
18000
18492
 
18001
18493
  return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync);
18002
- } else if (this.match(76)) {
18494
+ }
18495
+
18496
+ if (this.match(76)) {
18003
18497
  return this.parseClass(expr, true, true);
18004
- } else if (this.match(26)) {
18498
+ }
18499
+
18500
+ if (this.match(26)) {
18005
18501
  if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) {
18006
- this.raise(this.state.start, ErrorMessages.DecoratorBeforeExport);
18502
+ this.raise(ErrorMessages.DecoratorBeforeExport, {
18503
+ at: this.state.startLoc
18504
+ });
18007
18505
  }
18008
18506
 
18009
18507
  this.parseDecorators(false);
18010
18508
  return this.parseClass(expr, true, true);
18011
- } else if (this.match(71) || this.match(70) || this.isLet()) {
18012
- throw this.raise(this.state.start, ErrorMessages.UnsupportedDefaultExport);
18013
- } else {
18014
- var res = this.parseMaybeAssignAllowIn();
18015
- this.semicolon();
18016
- return res;
18017
18509
  }
18510
+
18511
+ if (this.match(71) || this.match(70) || this.isLet()) {
18512
+ throw this.raise(ErrorMessages.UnsupportedDefaultExport, {
18513
+ at: this.state.startLoc
18514
+ });
18515
+ }
18516
+
18517
+ var res = this.parseMaybeAssignAllowIn();
18518
+ this.semicolon();
18519
+ return res;
18018
18520
  }
18019
18521
 
18020
18522
  parseExportDeclaration(node) {
@@ -18086,10 +18588,12 @@ class StatementParser extends ExpressionParser {
18086
18588
 
18087
18589
  if (this.hasPlugin("decorators")) {
18088
18590
  if (this.getPluginOption("decorators", "decoratorsBeforeExport")) {
18089
- this.unexpected(this.state.start, ErrorMessages.DecoratorBeforeExport);
18090
- } else {
18091
- return true;
18591
+ throw this.raise(ErrorMessages.DecoratorBeforeExport, {
18592
+ at: this.state.startLoc
18593
+ });
18092
18594
  }
18595
+
18596
+ return true;
18093
18597
  }
18094
18598
  }
18095
18599
 
@@ -18107,7 +18611,9 @@ class StatementParser extends ExpressionParser {
18107
18611
  var declaration = node.declaration;
18108
18612
 
18109
18613
  if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
18110
- this.raise(declaration.start, ErrorMessages.ExportDefaultFromAsIdentifier);
18614
+ this.raise(ErrorMessages.ExportDefaultFromAsIdentifier, {
18615
+ node: declaration
18616
+ });
18111
18617
  }
18112
18618
  }
18113
18619
  } else if (node.specifiers && node.specifiers.length) {
@@ -18124,9 +18630,11 @@ class StatementParser extends ExpressionParser {
18124
18630
  } = specifier;
18125
18631
 
18126
18632
  if (local.type !== "Identifier") {
18127
- this.raise(specifier.start, ErrorMessages.ExportBindingIsString, local.value, exportedName);
18633
+ this.raise(ErrorMessages.ExportBindingIsString, {
18634
+ node: specifier
18635
+ }, local.value, exportedName);
18128
18636
  } else {
18129
- this.checkReservedWord(local.name, local.start, true, false);
18637
+ this.checkReservedWord(local.name, local.loc.start, true, false);
18130
18638
  this.scope.checkLocalExport(local);
18131
18639
  }
18132
18640
  }
@@ -18147,7 +18655,9 @@ class StatementParser extends ExpressionParser {
18147
18655
  var currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
18148
18656
 
18149
18657
  if (currentContextDecorators.length) {
18150
- throw this.raise(node.start, ErrorMessages.UnsupportedDecoratorExport);
18658
+ throw this.raise(ErrorMessages.UnsupportedDecoratorExport, {
18659
+ node
18660
+ });
18151
18661
  }
18152
18662
  }
18153
18663
 
@@ -18175,7 +18685,9 @@ class StatementParser extends ExpressionParser {
18175
18685
 
18176
18686
  checkDuplicateExports(node, name) {
18177
18687
  if (this.exportedIdentifiers.has(name)) {
18178
- this.raise(node.start, name === "default" ? ErrorMessages.DuplicateDefaultExport : ErrorMessages.DuplicateExport, name);
18688
+ this.raise(name === "default" ? ErrorMessages.DuplicateDefaultExport : ErrorMessages.DuplicateExport, {
18689
+ node
18690
+ }, name);
18179
18691
  }
18180
18692
 
18181
18693
  this.exportedIdentifiers.add(name);
@@ -18222,7 +18734,9 @@ class StatementParser extends ExpressionParser {
18222
18734
  var surrogate = result.value.match(loneSurrogate);
18223
18735
 
18224
18736
  if (surrogate) {
18225
- this.raise(result.start, ErrorMessages.ModuleExportNameHasLoneSurrogate, surrogate[0].charCodeAt(0).toString(16));
18737
+ this.raise(ErrorMessages.ModuleExportNameHasLoneSurrogate, {
18738
+ node: result
18739
+ }, surrogate[0].charCodeAt(0).toString(16));
18226
18740
  }
18227
18741
 
18228
18742
  return result;
@@ -18287,7 +18801,9 @@ class StatementParser extends ExpressionParser {
18287
18801
  var keyName = this.state.value;
18288
18802
 
18289
18803
  if (attrNames.has(keyName)) {
18290
- this.raise(this.state.start, ErrorMessages.ModuleAttributesWithDuplicateKeys, keyName);
18804
+ this.raise(ErrorMessages.ModuleAttributesWithDuplicateKeys, {
18805
+ at: this.state.startLoc
18806
+ }, keyName);
18291
18807
  }
18292
18808
 
18293
18809
  attrNames.add(keyName);
@@ -18301,7 +18817,9 @@ class StatementParser extends ExpressionParser {
18301
18817
  this.expect(14);
18302
18818
 
18303
18819
  if (!this.match(125)) {
18304
- throw this.unexpected(this.state.start, ErrorMessages.ModuleAttributeInvalidValue);
18820
+ throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, {
18821
+ at: this.state.startLoc
18822
+ });
18305
18823
  }
18306
18824
 
18307
18825
  node.value = this.parseStringLiteral(this.state.value);
@@ -18329,18 +18847,24 @@ class StatementParser extends ExpressionParser {
18329
18847
  node.key = this.parseIdentifier(true);
18330
18848
 
18331
18849
  if (node.key.name !== "type") {
18332
- this.raise(node.key.start, ErrorMessages.ModuleAttributeDifferentFromType, node.key.name);
18850
+ this.raise(ErrorMessages.ModuleAttributeDifferentFromType, {
18851
+ node: node.key
18852
+ }, node.key.name);
18333
18853
  }
18334
18854
 
18335
18855
  if (attributes.has(node.key.name)) {
18336
- this.raise(node.key.start, ErrorMessages.ModuleAttributesWithDuplicateKeys, node.key.name);
18856
+ this.raise(ErrorMessages.ModuleAttributesWithDuplicateKeys, {
18857
+ node: node.key
18858
+ }, node.key.name);
18337
18859
  }
18338
18860
 
18339
18861
  attributes.add(node.key.name);
18340
18862
  this.expect(14);
18341
18863
 
18342
18864
  if (!this.match(125)) {
18343
- throw this.unexpected(this.state.start, ErrorMessages.ModuleAttributeInvalidValue);
18865
+ throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, {
18866
+ at: this.state.startLoc
18867
+ });
18344
18868
  }
18345
18869
 
18346
18870
  node.value = this.parseStringLiteral(this.state.value);
@@ -18396,7 +18920,9 @@ class StatementParser extends ExpressionParser {
18396
18920
  first = false;
18397
18921
  } else {
18398
18922
  if (this.eat(14)) {
18399
- throw this.raise(this.state.start, ErrorMessages.DestructureNamedImport);
18923
+ throw this.raise(ErrorMessages.DestructureNamedImport, {
18924
+ at: this.state.startLoc
18925
+ });
18400
18926
  }
18401
18927
 
18402
18928
  this.expect(12);
@@ -18421,10 +18947,12 @@ class StatementParser extends ExpressionParser {
18421
18947
  } = specifier;
18422
18948
 
18423
18949
  if (importedIsString) {
18424
- throw this.raise(specifier.start, ErrorMessages.ImportBindingIsString, imported.value);
18950
+ throw this.raise(ErrorMessages.ImportBindingIsString, {
18951
+ node: specifier
18952
+ }, imported.value);
18425
18953
  }
18426
18954
 
18427
- this.checkReservedWord(imported.name, specifier.start, true, true);
18955
+ this.checkReservedWord(imported.name, specifier.loc.start, true, true);
18428
18956
 
18429
18957
  if (!specifier.local) {
18430
18958
  specifier.local = cloneIdentifier(imported);