@mojir/lits 2.1.2 → 2.1.3

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.
@@ -98,9 +98,15 @@ function getCodeMarker(sourceCodeInfo) {
98
98
  }
99
99
 
100
100
  function getLitsErrorMessage(message, sourceCodeInfo) {
101
- var filePathLine = (sourceCodeInfo === null || sourceCodeInfo === void 0 ? void 0 : sourceCodeInfo.filePath) ? "\n".concat(sourceCodeInfo.filePath) : '';
102
- var codeLine = (sourceCodeInfo === null || sourceCodeInfo === void 0 ? void 0 : sourceCodeInfo.code) ? "\n".concat(sourceCodeInfo.code) : '';
103
- var codeMarker = sourceCodeInfo && codeLine ? "\n".concat(getCodeMarker(sourceCodeInfo)) : '';
101
+ if (!sourceCodeInfo) {
102
+ return message;
103
+ }
104
+ var location = "".concat(sourceCodeInfo.position.line, ":").concat(sourceCodeInfo.position.column);
105
+ var filePathLine = sourceCodeInfo.filePath
106
+ ? "\n".concat(sourceCodeInfo.filePath, ":").concat(location)
107
+ : "\nLocation ".concat(location);
108
+ var codeLine = "\n".concat(sourceCodeInfo.code);
109
+ var codeMarker = "\n".concat(getCodeMarker(sourceCodeInfo));
104
110
  return "".concat(message).concat(filePathLine).concat(codeLine).concat(codeMarker);
105
111
  }
106
112
  var RecurSignal = /** @class */ (function (_super) {
@@ -235,6 +241,7 @@ var functionTypes = [
235
241
  'SomePred',
236
242
  'Fnull',
237
243
  'Builtin',
244
+ 'SpecialBuiltin',
238
245
  'NativeJsFunction',
239
246
  ];
240
247
  var functionTypeSet = new Set(functionTypes);
@@ -406,7 +413,7 @@ function findUnresolvedSymbolsInNode(node, contextStack, builtin, evaluateNode)
406
413
  return findUnresolvedSymbolsInNode(node[1], contextStack, builtin, evaluateNode);
407
414
  /* v8 ignore next 2 */
408
415
  default:
409
- throw new Error("Unhandled node type: ".concat(nodeType));
416
+ throw new LitsError("Unhandled node type: ".concat(nodeType), node[2]);
410
417
  }
411
418
  }
412
419
 
@@ -3771,6 +3778,26 @@ var andSpecialExpression = {
3771
3778
  }
3772
3779
  return value;
3773
3780
  },
3781
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
3782
+ var e_2, _a;
3783
+ var value = true;
3784
+ try {
3785
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
3786
+ var param = params_1_1.value;
3787
+ value = asAny(param, sourceCodeInfo);
3788
+ if (!value)
3789
+ break;
3790
+ }
3791
+ }
3792
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3793
+ finally {
3794
+ try {
3795
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
3796
+ }
3797
+ finally { if (e_2) throw e_2.error; }
3798
+ }
3799
+ return value;
3800
+ },
3774
3801
  getUndefinedSymbols: function (node, contextStack, _a) {
3775
3802
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
3776
3803
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4015,7 +4042,7 @@ var defSpecialExpression = {
4015
4042
  var value = bindingNode[1][1];
4016
4043
  var bindingValue = evaluateNode(value, contextStack);
4017
4044
  var values = evalueateBindingNodeValues(target, bindingValue, function (Node) { return evaluateNode(Node, contextStack); });
4018
- contextStack.exportValues(values);
4045
+ contextStack.exportValues(values, target[2]);
4019
4046
  return null;
4020
4047
  },
4021
4048
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -4027,7 +4054,7 @@ var defSpecialExpression = {
4027
4054
  walkDefaults(target, function (defaultNode) {
4028
4055
  addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode));
4029
4056
  });
4030
- contextStack.addValues(getAllBindingTargetNames(target));
4057
+ contextStack.addValues(getAllBindingTargetNames(target), target[2]);
4031
4058
  return bindingResult;
4032
4059
  },
4033
4060
  };
@@ -4145,14 +4172,14 @@ var functionSpecialExpression = {
4145
4172
  _b.name = functionSymbol[1],
4146
4173
  _b.evaluatedfunction = evaluatedFunction,
4147
4174
  _b);
4148
- contextStack.addValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c));
4175
+ contextStack.addValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
4149
4176
  return null;
4150
4177
  },
4151
4178
  getUndefinedSymbols: function (node, contextStack, _a) {
4152
4179
  var _b, _c;
4153
4180
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4154
4181
  var functionName = node[1][1][1];
4155
- contextStack.addValues((_b = {}, _b[functionName] = true, _b));
4182
+ contextStack.addValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
4156
4183
  var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
4157
4184
  return getFunctionUnresolvedSymbols(node[1][2], contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
4158
4185
  },
@@ -4173,7 +4200,7 @@ var defnSpecialExpression = {
4173
4200
  _b.name = functionSymbol[1],
4174
4201
  _b.evaluatedfunction = evaluatedFunctionOverloades,
4175
4202
  _b);
4176
- contextStack.exportValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c));
4203
+ contextStack.exportValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
4177
4204
  return null;
4178
4205
  },
4179
4206
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -4181,7 +4208,7 @@ var defnSpecialExpression = {
4181
4208
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4182
4209
  var functionName = node[1][1][1];
4183
4210
  var fn = node[1][2];
4184
- contextStack.exportValues((_b = {}, _b[functionName] = true, _b));
4211
+ contextStack.exportValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
4185
4212
  var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
4186
4213
  return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
4187
4214
  },
@@ -4293,7 +4320,7 @@ var letSpecialExpression = {
4293
4320
  var value = bindingNode[1][1];
4294
4321
  var bindingValue = evaluateNode(value, contextStack);
4295
4322
  var values = evalueateBindingNodeValues(target, bindingValue, function (Node) { return evaluateNode(Node, contextStack); });
4296
- contextStack.addValues(values);
4323
+ contextStack.addValues(values, target[2]);
4297
4324
  return null;
4298
4325
  },
4299
4326
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -4305,7 +4332,7 @@ var letSpecialExpression = {
4305
4332
  walkDefaults(target, function (defaultNode) {
4306
4333
  addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode));
4307
4334
  });
4308
- contextStack.addValues(getAllBindingTargetNames(target));
4335
+ contextStack.addValues(getAllBindingTargetNames(target), target[2]);
4309
4336
  return bindingResult;
4310
4337
  },
4311
4338
  };
@@ -4576,6 +4603,26 @@ var orSpecialExpression = {
4576
4603
  }
4577
4604
  return value;
4578
4605
  },
4606
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4607
+ var e_2, _a;
4608
+ var value = false;
4609
+ try {
4610
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
4611
+ var param = params_1_1.value;
4612
+ value = asAny(param, sourceCodeInfo);
4613
+ if (value)
4614
+ break;
4615
+ }
4616
+ }
4617
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
4618
+ finally {
4619
+ try {
4620
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
4621
+ }
4622
+ finally { if (e_2) throw e_2.error; }
4623
+ }
4624
+ return value;
4625
+ },
4579
4626
  getUndefinedSymbols: function (node, contextStack, _a) {
4580
4627
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4581
4628
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4594,6 +4641,11 @@ var qqSpecialExpression = {
4594
4641
  var firstResult = evaluateNode(firstNode, contextStack);
4595
4642
  return firstResult !== null && firstResult !== void 0 ? firstResult : (secondNode ? evaluateNode(secondNode, contextStack) : null);
4596
4643
  },
4644
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4645
+ var firstParam = asAny(params[0], sourceCodeInfo);
4646
+ var secondParam = params[1] !== undefined ? asAny(params[1], sourceCodeInfo) : null;
4647
+ return firstParam !== null && firstParam !== void 0 ? firstParam : secondParam;
4648
+ },
4597
4649
  getUndefinedSymbols: function (node, contextStack, _a) {
4598
4650
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4599
4651
  return getUndefinedSymbols(node[1][1].filter(function (n) { return !!n; }), contextStack, builtin, evaluateNode);
@@ -4608,6 +4660,9 @@ var recurSpecialExpression = {
4608
4660
  var evaluatedParams = params.map(function (paramNode) { return evaluateNode(paramNode, contextStack); });
4609
4661
  throw new RecurSignal(evaluatedParams);
4610
4662
  },
4663
+ evaluateAsNormalExpression: function (params) {
4664
+ throw new RecurSignal(params);
4665
+ },
4611
4666
  getUndefinedSymbols: function (node, contextStack, _a) {
4612
4667
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4613
4668
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4623,6 +4678,12 @@ var throwSpecialExpression = {
4623
4678
  });
4624
4679
  throw new UserDefinedError(message, node[2]);
4625
4680
  },
4681
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4682
+ var message = asString(params[0], sourceCodeInfo, {
4683
+ nonEmpty: true,
4684
+ });
4685
+ throw new UserDefinedError(message, undefined);
4686
+ },
4626
4687
  getUndefinedSymbols: function (node, contextStack, _a) {
4627
4688
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4628
4689
  return getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode);
@@ -4690,6 +4751,24 @@ var arraySpecialExpression = {
4690
4751
  }
4691
4752
  return result;
4692
4753
  },
4754
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4755
+ var e_2, _a;
4756
+ var result = [];
4757
+ try {
4758
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
4759
+ var param = params_1_1.value;
4760
+ result.push(asAny(param, sourceCodeInfo));
4761
+ }
4762
+ }
4763
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
4764
+ finally {
4765
+ try {
4766
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
4767
+ }
4768
+ finally { if (e_2) throw e_2.error; }
4769
+ }
4770
+ return result;
4771
+ },
4693
4772
  getUndefinedSymbols: function (node, contextStack, _a) {
4694
4773
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4695
4774
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4721,6 +4800,16 @@ var objectSpecialExpression = {
4721
4800
  }
4722
4801
  return result;
4723
4802
  },
4803
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4804
+ var result = {};
4805
+ for (var i = 0; i < params.length; i += 2) {
4806
+ var key = params[i];
4807
+ var value = params[i + 1];
4808
+ assertString(key, sourceCodeInfo);
4809
+ result[key] = value !== null && value !== void 0 ? value : null;
4810
+ }
4811
+ return result;
4812
+ },
4724
4813
  getUndefinedSymbols: function (node, contextStack, _a) {
4725
4814
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4726
4815
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4964,6 +5053,16 @@ var functionExecutors = {
4964
5053
  var normalExpression = asNonUndefined(allNormalExpressions[fn.normalBuitinSymbolType], sourceCodeInfo);
4965
5054
  return normalExpression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction: executeFunction });
4966
5055
  },
5056
+ SpecialBuiltin: function (fn, params, sourceCodeInfo, contextStack, _a) {
5057
+ var executeFunction = _a.executeFunction;
5058
+ var specialExpression = asNonUndefined(specialExpressions[fn.specialBuiltinSymbolType], sourceCodeInfo);
5059
+ if (specialExpression.evaluateAsNormalExpression) {
5060
+ return specialExpression.evaluateAsNormalExpression(params, sourceCodeInfo, contextStack, { executeFunction: executeFunction });
5061
+ }
5062
+ else {
5063
+ throw new LitsError("Special builtin function ".concat(fn.specialBuiltinSymbolType, " is not supported as normal expression."), sourceCodeInfo);
5064
+ }
5065
+ },
4967
5066
  };
4968
5067
 
4969
5068
  function evaluate(ast, contextStack) {
@@ -5019,7 +5118,21 @@ function evaluateReservedSymbol(node) {
5019
5118
  function evaluateNormalExpression(node, contextStack) {
5020
5119
  var sourceCodeInfo = node[2];
5021
5120
  var paramNodes = node[1][1];
5022
- var params = paramNodes.map(function (paramNode) { return evaluateNode(paramNode, contextStack); });
5121
+ var params = [];
5122
+ paramNodes.forEach(function (paramNode) {
5123
+ if (isSpreadNode(paramNode)) {
5124
+ var spreadValue = evaluateNode(paramNode[1], contextStack);
5125
+ if (Array.isArray(spreadValue)) {
5126
+ params.push.apply(params, __spreadArray([], __read(spreadValue), false));
5127
+ }
5128
+ else {
5129
+ throw new LitsError("Spread operator requires an array, got ".concat(valueToString(paramNode)), paramNode[2]);
5130
+ }
5131
+ }
5132
+ else {
5133
+ params.push(evaluateNode(paramNode, contextStack));
5134
+ }
5135
+ });
5023
5136
  if (isNormalExpressionNodeWithName(node)) {
5024
5137
  var nameSymbol = node[1][0];
5025
5138
  if (isNormalBuiltinSymbolNode(nameSymbol)) {
@@ -5121,19 +5234,19 @@ var ContextStackImpl = /** @class */ (function () {
5121
5234
  var contexts = [{}, context];
5122
5235
  return new ContextStackImpl({ contexts: contexts });
5123
5236
  };
5124
- ContextStackImpl.prototype.exportValues = function (values) {
5237
+ ContextStackImpl.prototype.exportValues = function (values, sourceCodeInfo) {
5125
5238
  var e_1, _a;
5126
5239
  try {
5127
5240
  for (var _b = __values(Object.entries(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
5128
5241
  var _d = __read(_c.value, 2), name_1 = _d[0], value = _d[1];
5129
5242
  if (this.globalContext[name_1]) {
5130
- throw new Error("Cannot redefine exported value \"".concat(name_1, "\""));
5243
+ throw new LitsError("Cannot redefine exported value \"".concat(name_1, "\""), sourceCodeInfo);
5131
5244
  }
5132
5245
  if (specialExpressionKeys.includes(name_1)) {
5133
- throw new Error("Cannot shadow special expression \"".concat(name_1, "\""));
5246
+ throw new LitsError("Cannot shadow special expression \"".concat(name_1, "\""), sourceCodeInfo);
5134
5247
  }
5135
5248
  if (normalExpressionKeys.includes(name_1)) {
5136
- throw new Error("Cannot shadow builtin function \"".concat(name_1, "\""));
5249
+ throw new LitsError("Cannot shadow builtin function \"".concat(name_1, "\""), sourceCodeInfo);
5137
5250
  }
5138
5251
  this.globalContext[name_1] = { value: value };
5139
5252
  }
@@ -5145,22 +5258,22 @@ var ContextStackImpl = /** @class */ (function () {
5145
5258
  }
5146
5259
  finally { if (e_1) throw e_1.error; }
5147
5260
  }
5148
- this.addValues(values);
5261
+ this.addValues(values, sourceCodeInfo);
5149
5262
  };
5150
- ContextStackImpl.prototype.addValues = function (values) {
5263
+ ContextStackImpl.prototype.addValues = function (values, sourceCodeInfo) {
5151
5264
  var e_2, _a;
5152
5265
  var currentContext = this.contexts[0];
5153
5266
  try {
5154
5267
  for (var _b = __values(Object.entries(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
5155
5268
  var _d = __read(_c.value, 2), name_2 = _d[0], value = _d[1];
5156
5269
  if (currentContext[name_2]) {
5157
- throw new Error("Cannot redefine value \"".concat(name_2, "\""));
5270
+ throw new LitsError("Cannot redefine value \"".concat(name_2, "\""), sourceCodeInfo);
5158
5271
  }
5159
5272
  if (specialExpressionKeys.includes(name_2)) {
5160
- throw new Error("Cannot shadow special expression \"".concat(name_2, "\""));
5273
+ throw new LitsError("Cannot shadow special expression \"".concat(name_2, "\""), sourceCodeInfo);
5161
5274
  }
5162
5275
  if (normalExpressionKeys.includes(name_2)) {
5163
- throw new Error("Cannot shadow builtin function \"".concat(name_2, "\""));
5276
+ throw new LitsError("Cannot shadow builtin function \"".concat(name_2, "\""), sourceCodeInfo);
5164
5277
  }
5165
5278
  currentContext[name_2] = { value: toAny(value) };
5166
5279
  }
@@ -5240,18 +5353,36 @@ var ContextStackImpl = /** @class */ (function () {
5240
5353
  return null;
5241
5354
  };
5242
5355
  ContextStackImpl.prototype.evaluateSymbol = function (node) {
5243
- var _a;
5356
+ var _a, _b;
5244
5357
  if (isSpecialBuiltinSymbolNode(node)) {
5245
- throw new Error('Special builtin symbols should not be evaluated');
5358
+ var functionType = node[1];
5359
+ switch (functionType) {
5360
+ case specialExpressionTypes['&&']:
5361
+ case specialExpressionTypes['||']:
5362
+ case specialExpressionTypes.array:
5363
+ case specialExpressionTypes.object:
5364
+ case specialExpressionTypes['defined?']:
5365
+ case specialExpressionTypes.recur:
5366
+ case specialExpressionTypes.throw:
5367
+ case specialExpressionTypes['??']:
5368
+ return _a = {},
5369
+ _a[FUNCTION_SYMBOL] = true,
5370
+ _a.functionType = 'SpecialBuiltin',
5371
+ _a.specialBuiltinSymbolType = functionType,
5372
+ _a.sourceCodeInfo = node[2],
5373
+ _a;
5374
+ default:
5375
+ throw new LitsError("Unknown special builtin symbol type: ".concat(functionType), node[2]);
5376
+ }
5246
5377
  }
5247
5378
  if (isNormalBuiltinSymbolNode(node)) {
5248
5379
  var type = node[1];
5249
- return _a = {},
5250
- _a[FUNCTION_SYMBOL] = true,
5251
- _a.functionType = 'Builtin',
5252
- _a.normalBuitinSymbolType = type,
5253
- _a.sourceCodeInfo = node[2],
5254
- _a;
5380
+ return _b = {},
5381
+ _b[FUNCTION_SYMBOL] = true,
5382
+ _b.functionType = 'Builtin',
5383
+ _b.normalBuitinSymbolType = type,
5384
+ _b.sourceCodeInfo = node[2],
5385
+ _b;
5255
5386
  }
5256
5387
  var lookUpResult = this.lookUp(node);
5257
5388
  if (isContextEntry(lookUpResult))
@@ -5923,7 +6054,7 @@ function withSourceCodeInfo(node, sourceCodeInfo) {
5923
6054
  }
5924
6055
  return node;
5925
6056
  }
5926
- function getPrecedence(operatorSign) {
6057
+ function getPrecedence(operatorSign, sourceCodeInfo) {
5927
6058
  switch (operatorSign) {
5928
6059
  case '**': // exponentiation
5929
6060
  return exponentiationPrecedence;
@@ -5962,7 +6093,7 @@ function getPrecedence(operatorSign) {
5962
6093
  // leave room for binaryFunctionalOperatorPrecedence = 1
5963
6094
  /* v8 ignore next 2 */
5964
6095
  default:
5965
- throw new Error("Unknown binary operator: ".concat(operatorSign));
6096
+ throw new LitsError("Unknown binary operator: ".concat(operatorSign), sourceCodeInfo);
5966
6097
  }
5967
6098
  }
5968
6099
  function createNamedNormalExpressionNode(symbolNode, params, sourceCodeInfo) {
@@ -6095,7 +6226,7 @@ var Parser = /** @class */ (function () {
6095
6226
  while (!this.isAtExpressionEnd()) {
6096
6227
  if (isA_BinaryOperatorToken(operator)) {
6097
6228
  var name_1 = operator[1];
6098
- var newPrecedece = getPrecedence(name_1);
6229
+ var newPrecedece = getPrecedence(name_1, operator[2]);
6099
6230
  if (newPrecedece <= precedence
6100
6231
  // ** (exponentiation) is right associative
6101
6232
  && !(newPrecedece === exponentiationPrecedence && precedence === exponentiationPrecedence)) {
@@ -6175,7 +6306,7 @@ var Parser = /** @class */ (function () {
6175
6306
  this.advance();
6176
6307
  var expression = this.parseExpression();
6177
6308
  if (!isRParenToken(this.peek())) {
6178
- throw new Error('Expected closing parenthesis');
6309
+ throw new LitsError('Expected closing parenthesis', this.peek()[2]);
6179
6310
  }
6180
6311
  this.advance();
6181
6312
  return expression;
@@ -6297,7 +6428,13 @@ var Parser = /** @class */ (function () {
6297
6428
  this.advance();
6298
6429
  var params = [];
6299
6430
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
6300
- params.push(this.parseExpression());
6431
+ if (isOperatorToken(this.peek(), '...')) {
6432
+ this.advance();
6433
+ params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peek()[2]));
6434
+ }
6435
+ else {
6436
+ params.push(this.parseExpression());
6437
+ }
6301
6438
  var nextToken = this.peek();
6302
6439
  if (!isOperatorToken(nextToken, ',') && !isRParenToken(nextToken)) {
6303
6440
  throw new LitsError('Expected comma or closing parenthesis', this.peek()[2]);
@@ -6353,7 +6490,7 @@ var Parser = /** @class */ (function () {
6353
6490
  throw new LitsError("".concat(type, " is not allowed"), symbol[2]);
6354
6491
  /* v8 ignore next 2 */
6355
6492
  default:
6356
- throw new Error("Unknown special expression: ".concat(type));
6493
+ throw new LitsError("Unknown special expression: ".concat(type), symbol[2]);
6357
6494
  }
6358
6495
  }
6359
6496
  else if (isNormalBuiltinSymbolNode(symbol) || isNormalBuiltinSymbolNode(symbol)) {