tla-ts 0.0.3-dev.6a30eee → 0.0.3-dev.6ac5593

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.
Files changed (55) hide show
  1. package/README.md +5 -1
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.cts +70 -22
  4. package/dist/index.d.ts +70 -22
  5. package/dist/index.js +1 -1
  6. package/dist/parallel-worker.cjs +1 -1
  7. package/dist/parallel-worker.js +2 -2
  8. package/dist/parallel.cjs +1 -1
  9. package/dist/parallel.js +2 -2
  10. package/dist/run-cli.cjs +20 -18
  11. package/dist/run-cli.js +22 -20
  12. package/dist/transfer.cjs +41 -15
  13. package/dist/transfer.js +41 -15
  14. package/package.json +1 -1
  15. package/src/ast.ts +121 -4
  16. package/src/builtins.ts +9 -3
  17. package/src/check.ts +480 -106
  18. package/src/cli-options.ts +11 -5
  19. package/src/codegen.ts +15 -22
  20. package/src/config.ts +224 -170
  21. package/src/dependencies.ts +2 -2
  22. package/src/environment.ts +410 -130
  23. package/src/errors.ts +104 -3
  24. package/src/evaluate.ts +402 -182
  25. package/src/exit-codes.ts +21 -14
  26. package/src/fingerprints.ts +2 -1
  27. package/src/instances.ts +17 -16
  28. package/src/levels.ts +185 -44
  29. package/src/live-check.ts +132 -70
  30. package/src/liveness.ts +118 -24
  31. package/src/parallel-worker.ts +2 -2
  32. package/src/parallel.ts +5 -2
  33. package/src/parser.ts +172 -53
  34. package/src/resolve.ts +1378 -420
  35. package/src/run-cli.ts +106 -18
  36. package/src/runtime.ts +2 -0
  37. package/src/sany-lexer.ts +615 -0
  38. package/src/sany-parse-error.ts +3143 -0
  39. package/src/spec-description.ts +19 -8
  40. package/src/standard-modules.ts +54 -45
  41. package/src/standard-ranges.ts +116 -0
  42. package/src/state-graph.ts +157 -0
  43. package/src/subexpressions.ts +231 -171
  44. package/src/substitution-levels.ts +38 -17
  45. package/src/successors.ts +177 -37
  46. package/src/symmetry.ts +109 -41
  47. package/src/tableau.ts +51 -24
  48. package/src/tlc-ext.ts +29 -12
  49. package/src/tlc-module.ts +14 -33
  50. package/src/tlc-modules.ts +4 -0
  51. package/src/tlc-order.ts +8 -4
  52. package/src/tlc-random.ts +9 -6
  53. package/src/tlc-summary.ts +20 -5
  54. package/src/value-sources.ts +29 -0
  55. package/src/values.ts +242 -61
package/src/parser.ts CHANGED
@@ -22,7 +22,7 @@ import type {
22
22
  StepBody,
23
23
  UseOrHide,
24
24
  } from "./ast";
25
- import { TlaSyntaxError } from "./errors";
25
+ import { createSanyError, formatRange, TlaSyntaxError } from "./errors";
26
26
  import { getNumeralValue, tokenize, type Token } from "./lexer";
27
27
 
28
28
  interface InfixOperator {
@@ -315,6 +315,7 @@ const parse = (source: string, isTlapm: boolean): Module => {
315
315
  const proofScopes: Set<string>[] = [];
316
316
  // A fact may cite an operator of a parameterized instance without the instance's arguments.
317
317
  const factStart = { index: -1 };
318
+ // SANY reports a location in a nested module as one in the module of its file.
318
319
  const openModules: Module[] = [];
319
320
 
320
321
  const isRecursiveName = (name: string) => recursiveScopes[recursiveScopes.length - 1].has(name);
@@ -329,15 +330,14 @@ const parse = (source: string, isTlapm: boolean): Module => {
329
330
  const tokenEnds: SourceLocation[] = [];
330
331
  const tokenRanges: SourceRange[] = [];
331
332
 
332
- const getRange = (startIndex: number) => {
333
- const endIndex = cursor.index - 1;
333
+ const getRange = (startIndex: number, endIndex = cursor.index - 1) => {
334
334
  const cached = startIndex === endIndex ? tokenRanges[startIndex] : undefined;
335
335
  if (cached) return cached;
336
336
  const last = tokens[endIndex];
337
337
  tokenStarts[startIndex] ??= getLocation(tokens[startIndex]);
338
338
  tokenEnds[endIndex] ??= { line: last.line, column: last.endColumn };
339
339
  const range = {
340
- module: openModules[openModules.length - 1].name,
340
+ module: openModules[0].name,
341
341
  start: tokenStarts[startIndex],
342
342
  end: tokenEnds[endIndex],
343
343
  };
@@ -472,6 +472,16 @@ const parse = (source: string, isTlapm: boolean): Module => {
472
472
  return token.text;
473
473
  };
474
474
 
475
+ const expectName = () => {
476
+ const start = cursor.index;
477
+ return { name: expectIdentifier(), range: getRange(start) };
478
+ };
479
+
480
+ const getNames = (names: { name: string; range: SourceRange }[]) => ({
481
+ names: names.map((item) => item.name),
482
+ ranges: names.map((item) => item.range),
483
+ });
484
+
475
485
  const withoutOffside = <Result>(parse: () => Result) => {
476
486
  cursor.offsideColumns.push(NO_OFFSIDE);
477
487
  const result = parse();
@@ -514,10 +524,13 @@ const parse = (source: string, isTlapm: boolean): Module => {
514
524
  };
515
525
 
516
526
  const parsePattern = (): BoundPattern => {
517
- if (!accept("<<")) return { kind: "Name", name: expectIdentifier() };
518
- const names = parseSeparated(expectIdentifier);
527
+ if (!accept("<<")) {
528
+ const named = expectName();
529
+ return { kind: "Name", name: named.name, ranges: [named.range] };
530
+ }
531
+ const names = getNames(parseSeparated(expectName));
519
532
  expect(">>");
520
- return { kind: "Tuple", names };
533
+ return { kind: "Tuple", names: names.names, ranges: names.ranges };
521
534
  };
522
535
 
523
536
  const parseBounds = () =>
@@ -623,19 +636,38 @@ const parse = (source: string, isTlapm: boolean): Module => {
623
636
  if (isAt("LAMBDA")) {
624
637
  const start = cursor.index;
625
638
  advance();
626
- const params = parseSeparated(expectIdentifier);
639
+ const params = getNames(parseSeparated(expectName));
627
640
  expect(":");
628
641
  const body = parseExpression();
629
- return withRange({ kind: "Lambda", params, body, location: getLocation(token) }, start);
642
+ return withRange(
643
+ {
644
+ kind: "Lambda",
645
+ params: params.names,
646
+ paramRanges: params.ranges,
647
+ body,
648
+ location: getLocation(token),
649
+ },
650
+ start,
651
+ );
630
652
  }
631
- return parseExpression();
653
+ const argument = parseExpression();
654
+ // SANY reads an argument that only names an operator of a parameterized instance, such as
655
+ // I!Op, as that operator, which takes the arguments of the instance too.
656
+ if (argument.kind === "Identifier") missingArguments.delete(argument);
657
+ return argument;
632
658
  };
633
659
 
660
+ const missingArguments = new Map<Expression, { location: string; message: string }>();
661
+
662
+ const lastArguments: { range: SourceRange | undefined } = { range: undefined };
663
+
634
664
  const parseArguments = () =>
635
665
  withoutOffside(() => {
666
+ const start = cursor.index;
636
667
  expect("(");
637
668
  const args = parseSeparated(parseArgument);
638
669
  expect(")");
670
+ lastArguments.range = getRange(start);
639
671
  return args;
640
672
  });
641
673
 
@@ -662,9 +694,12 @@ const parse = (source: string, isTlapm: boolean): Module => {
662
694
  if (peek().kind === "Identifier" && (isAt("|->", 1) || isAt(":", 1))) {
663
695
  const kind = isAt("|->", 1) ? "Record" : "RecordSet";
664
696
  const fields = parseSeparated(() => {
697
+ const fieldStart = cursor.index;
698
+ const fieldLocation = getLocation(peek());
665
699
  const name = expectIdentifier();
700
+ fieldLocation.range = getRange(fieldStart);
666
701
  expect(kind === "Record" ? "|->" : ":");
667
- return { name, value: parseExpression() };
702
+ return { name, value: parseExpression(), location: fieldLocation };
668
703
  });
669
704
  expect("]");
670
705
  return { kind, fields, location };
@@ -763,12 +798,13 @@ const parse = (source: string, isTlapm: boolean): Module => {
763
798
  expect(":");
764
799
  return { kind, bounds, body: parseExpression(), location };
765
800
  }
766
- const names = parseSeparated(expectIdentifier);
801
+ const names = getNames(parseSeparated(expectName));
767
802
  expect(":");
768
803
  return {
769
804
  kind: "UnboundedQuantifier",
770
805
  quantifier: start.text === "\\A" || start.text === "\\AA" ? "Forall" : "Exists",
771
- names,
806
+ names: names.names,
807
+ nameRanges: names.ranges,
772
808
  body: parseExpression(),
773
809
  isTemporal,
774
810
  location,
@@ -823,7 +859,8 @@ const parse = (source: string, isTlapm: boolean): Module => {
823
859
  };
824
860
 
825
861
  const parsePrimary = (): Expression => {
826
- const isFactStart = cursor.index === factStart.index;
862
+ const start = cursor.index;
863
+ const isFactStart = start === factStart.index;
827
864
  const token = advance();
828
865
  const location = getLocation(token);
829
866
  if (isTlapm && token.kind === "Keyword" && token.text === "LAMBDA") {
@@ -847,47 +884,92 @@ const parse = (source: string, isTlapm: boolean): Module => {
847
884
  if (token.kind === "Identifier" || isStep) {
848
885
  const name = isStep ? (getStepName(token) ?? token.text) : token.text;
849
886
  if (isLabelAhead()) {
850
- const params = accept("(") ? parseSeparated(expectIdentifier) : [];
851
- if (params.length > 0) expect(")");
887
+ const params = getNames(accept("(") ? parseSeparated(expectName) : []);
888
+ if (params.names.length > 0) expect(")");
852
889
  expect("::");
853
- return { kind: "Label", name, params, body: parseExpression(), location };
890
+ return {
891
+ kind: "Label",
892
+ name,
893
+ params: params.names,
894
+ paramRanges: params.ranges,
895
+ body: parseExpression(),
896
+ location,
897
+ };
854
898
  }
855
899
  const hasArguments = isAt("(");
856
900
  const args = hasArguments ? parseArguments() : [];
901
+ const argumentRanges = [hasArguments ? lastArguments.range : undefined];
857
902
  if (!isSelectorAhead()) {
858
903
  return hasArguments
859
- ? { kind: "Apply", operator: name, args, location }
904
+ ? { kind: "Apply", operator: name, args, argumentsRange: lastArguments.range, location }
860
905
  : { kind: "Identifier", name, location };
861
906
  }
862
907
  const instance = openModules
863
908
  .flatMap((module) => module.instances)
864
909
  .find((candidate) => candidate.name === name);
865
- if (instance && !isFactStart && !isTlapm && instance.params.length !== args.length) {
910
+ const isMissingArguments =
911
+ instance !== undefined &&
912
+ !isFactStart &&
913
+ !isTlapm &&
914
+ instance.params.length !== args.length;
915
+ if (isMissingArguments && args.length > 0) {
866
916
  throw createError(
867
917
  `The operator ${name} requires ${instance.params.length} arguments`,
868
918
  token,
869
919
  );
870
920
  }
871
921
  const selectors: Selector[] = [{ kind: "Name", name, args }];
922
+ const selectorRanges = [getRange(start, start)];
872
923
  while (isSelectorAhead()) {
873
924
  advance();
925
+ selectorRanges.push(getRange(cursor.index, cursor.index));
926
+ lastArguments.range = undefined;
874
927
  selectors.push(parseSelector());
928
+ argumentRanges.push(lastArguments.range);
875
929
  }
876
930
  const names = selectors.flatMap((selector) =>
877
931
  selector.kind === "Name" ? [selector.name] : [],
878
932
  );
879
- if (names.length < selectors.length) return { kind: "Subexpression", selectors, location };
880
933
  const operator = names.join("!");
881
934
  const qualifiedArgs = selectors.flatMap((selector) =>
882
935
  "args" in selector ? selector.args : [],
883
936
  );
884
- if (qualifiedArgs.length === 0) return { kind: "Identifier", name: operator, location };
885
937
  const argumentCounts = selectors.map((selector) =>
886
938
  "args" in selector ? selector.args.length : 0,
887
939
  );
888
- return argumentCounts.slice(0, -1).some((count) => count > 0)
889
- ? { kind: "Apply", operator, args: qualifiedArgs, argumentCounts, location }
890
- : { kind: "Apply", operator, args: qualifiedArgs, location };
940
+ const argumentsRange = argumentRanges.findLast((range) => range !== undefined);
941
+ const reference: Expression =
942
+ names.length < selectors.length
943
+ ? { kind: "Subexpression", selectors, selectorRanges, argumentRanges, location }
944
+ : qualifiedArgs.length === 0
945
+ ? { kind: "Identifier", name: operator, selectorRanges, location }
946
+ : argumentCounts.slice(0, -1).some((count) => count > 0)
947
+ ? {
948
+ kind: "Apply",
949
+ operator,
950
+ args: qualifiedArgs,
951
+ argumentCounts,
952
+ argumentsRange,
953
+ selectorRanges,
954
+ argumentRanges,
955
+ location,
956
+ }
957
+ : {
958
+ kind: "Apply",
959
+ operator,
960
+ args: qualifiedArgs,
961
+ argumentsRange,
962
+ selectorRanges,
963
+ argumentRanges,
964
+ location,
965
+ };
966
+ if (isMissingArguments) {
967
+ missingArguments.set(reference, {
968
+ location: formatRange(getRange(start)),
969
+ message: `The operator ${name} requires ${instance.params.length} arguments.`,
970
+ });
971
+ }
972
+ return reference;
891
973
  }
892
974
  if (token.kind === "Operator" && isOperatorName(token.text) && isAt("("))
893
975
  return { kind: "Apply", operator: token.text, args: parseArguments(), location };
@@ -1099,7 +1181,7 @@ const parse = (source: string, isTlapm: boolean): Module => {
1099
1181
  const body = parseExpression();
1100
1182
  const last = tokens[cursor.index - 1];
1101
1183
  const end = { line: last.line, column: last.endColumn };
1102
- return { body, bodyRange: { module: openModules[openModules.length - 1].name, start, end } };
1184
+ return { body, bodyRange: { module: openModules[0].name, start, end } };
1103
1185
  };
1104
1186
 
1105
1187
  const parseDefinition = (isLocal: boolean): Definition | Instance => {
@@ -1107,6 +1189,16 @@ const parse = (source: string, isTlapm: boolean): Module => {
1107
1189
  return withRange(parseDefinitionUnit(isLocal), start);
1108
1190
  };
1109
1191
 
1192
+ const toParam = (named: { name: string; range: SourceRange }): OperatorParam => ({
1193
+ name: named.name,
1194
+ arity: 0,
1195
+ location: {
1196
+ line: named.range.start.line,
1197
+ column: named.range.start.column,
1198
+ range: named.range,
1199
+ },
1200
+ });
1201
+
1110
1202
  const parseDefinitionUnit = (isLocal: boolean): Definition | Instance => {
1111
1203
  const token = peek();
1112
1204
  const location = getLocation(token);
@@ -1126,24 +1218,22 @@ const parse = (source: string, isTlapm: boolean): Module => {
1126
1218
  peek(2).kind === "Identifier" &&
1127
1219
  isAt("==", 3)
1128
1220
  ) {
1129
- const left = expectIdentifier();
1221
+ const left = expectName();
1130
1222
  const operator = advance().text;
1131
- const right = expectIdentifier();
1223
+ const right = expectName();
1132
1224
  expect("==");
1133
- return parseOperator(operator, [
1134
- { name: left, arity: 0 },
1135
- { name: right, arity: 0 },
1136
- ]);
1225
+ return parseOperator(operator, [toParam(left), toParam(right)]);
1137
1226
  }
1138
1227
  const isPrefixDefinition = token.kind === "Operator" && token.text === "-.";
1139
1228
  const isPostfixDefinition =
1140
1229
  token.kind === "Identifier" && POSTFIX_OPERATORS.has(peek(1).text) && isAt("==", 2);
1141
1230
  if (isPrefixDefinition || isPostfixDefinition) {
1142
1231
  const operator = isPrefixDefinition ? token.text : peek(1).text;
1143
- cursor.index += isPrefixDefinition ? 1 : 2;
1144
- const param = isPrefixDefinition ? expectIdentifier() : token.text;
1232
+ if (isPrefixDefinition) advance();
1233
+ const param = expectName();
1234
+ if (isPostfixDefinition) advance();
1145
1235
  expect("==");
1146
- return parseOperator(operator, [{ name: param, arity: 0 }]);
1236
+ return parseOperator(operator, [toParam(param)]);
1147
1237
  }
1148
1238
  const name = expectIdentifier();
1149
1239
  if (accept("[")) {
@@ -1181,9 +1271,11 @@ const parse = (source: string, isTlapm: boolean): Module => {
1181
1271
  const module = expectIdentifier();
1182
1272
  const substitutions = accept("WITH")
1183
1273
  ? parseSeparated(() => {
1274
+ const targetStart = cursor.index;
1184
1275
  const target = advance().text;
1276
+ const nameRange = getRange(targetStart);
1185
1277
  expect("<-");
1186
- return { name: target, expression: parseArgument() };
1278
+ return { name: target, nameRange, expression: parseArgument() };
1187
1279
  })
1188
1280
  : [];
1189
1281
  return {
@@ -1199,6 +1291,11 @@ const parse = (source: string, isTlapm: boolean): Module => {
1199
1291
  };
1200
1292
 
1201
1293
  const parseDeclaration = (): Declaration => {
1294
+ const start = cursor.index;
1295
+ return withRange(parseDeclarationUnit(), start);
1296
+ };
1297
+
1298
+ const parseDeclarationUnit = (): Declaration => {
1202
1299
  const location = getLocation(peek());
1203
1300
  if (isAt("_") && peek(1).kind === "Operator") {
1204
1301
  advance();
@@ -1423,11 +1520,14 @@ const parse = (source: string, isTlapm: boolean): Module => {
1423
1520
  location: getLocation(keyword),
1424
1521
  };
1425
1522
  const invalid =
1426
- use.kind === "Hide" && !isTlapm ? use.facts.find((fact) => !isHideFact(fact)) : undefined;
1427
- if (invalid) {
1428
- throw createError(
1429
- "The only expression allowed as a fact in a HIDE is the name of a theorem, assumption, or step",
1430
- invalid.location,
1523
+ use.kind === "Hide" && !isTlapm ? use.facts.filter((fact) => !isHideFact(fact)) : [];
1524
+ if (invalid.length > 0) {
1525
+ throw createSanyError(
1526
+ invalid.map((fact) => ({
1527
+ location: formatRange(fact.location.range ?? getRange(start)),
1528
+ message:
1529
+ "The only expression allowed as a fact in a HIDE is \nthe name of a theorem, assumption, or step.",
1530
+ })),
1431
1531
  );
1432
1532
  }
1433
1533
  return withRange(use, start);
@@ -1443,10 +1543,18 @@ const parse = (source: string, isTlapm: boolean): Module => {
1443
1543
  }
1444
1544
  if (level !== undefined) advance();
1445
1545
  if (level === "Variable") {
1446
- const name = expectIdentifier();
1447
- declareProofSymbol(name);
1546
+ const named = expectName();
1547
+ declareProofSymbol(named.name);
1448
1548
  return withRange(
1449
- { kind: "NewSymbol", name, arity: 0, level, set: undefined, location },
1549
+ {
1550
+ kind: "NewSymbol",
1551
+ name: named.name,
1552
+ arity: 0,
1553
+ level,
1554
+ set: undefined,
1555
+ nameRange: named.range,
1556
+ location,
1557
+ },
1450
1558
  start,
1451
1559
  );
1452
1560
  }
@@ -1464,6 +1572,7 @@ const parse = (source: string, isTlapm: boolean): Module => {
1464
1572
  arity: declaration.arity,
1465
1573
  level: level ?? "Constant",
1466
1574
  set: isBounded ? parseExpression() : undefined,
1575
+ nameRange: declaration.location.range,
1467
1576
  location,
1468
1577
  },
1469
1578
  start,
@@ -1506,7 +1615,8 @@ const parse = (source: string, isTlapm: boolean): Module => {
1506
1615
  const token = peek();
1507
1616
  if (isAt("USE") || isAt("HIDE")) return parseUseOrHide();
1508
1617
  if (isAt("INSTANCE")) {
1509
- return withRange(parseInstance(undefined, [], false, getLocation(token)), cursor.index);
1618
+ const start = cursor.index;
1619
+ return withRange(parseInstance(undefined, [], false, getLocation(token)), start);
1510
1620
  }
1511
1621
  if (isAt("DEFINE") || isDefinitionStart()) {
1512
1622
  const start = cursor.index;
@@ -1519,21 +1629,27 @@ const parse = (source: string, isTlapm: boolean): Module => {
1519
1629
  if (accept("HAVE")) return { kind: "Have", expression: parseExpression() };
1520
1630
  if (accept("TAKE")) {
1521
1631
  const isBounded = isBoundAhead();
1522
- const names = isBounded ? [] : parseSeparated(expectIdentifier);
1632
+ const names = getNames(isBounded ? [] : parseSeparated(expectName));
1523
1633
  const bounds = isBounded ? parseBounds() : [];
1524
- declareProofSymbols(names, bounds);
1525
- return { kind: "Take", names, bounds };
1634
+ declareProofSymbols(names.names, bounds);
1635
+ return { kind: "Take", names: names.names, nameRanges: names.ranges, bounds };
1526
1636
  }
1527
1637
  if (accept("WITNESS")) {
1528
1638
  return { kind: "Witness", expressions: parseSeparated(() => parseExpression()) };
1529
1639
  }
1530
1640
  if (accept("PICK")) {
1531
1641
  const isNames = isNameListAhead(":");
1532
- const names = isNames ? parseSeparated(expectIdentifier) : [];
1642
+ const names = getNames(isNames ? parseSeparated(expectName) : []);
1533
1643
  const bounds = isNames ? [] : parseBounds();
1534
- declareProofSymbols(names, bounds);
1644
+ declareProofSymbols(names.names, bounds);
1535
1645
  expect(":");
1536
- return { kind: "Pick", names, bounds, body: parseExpression() };
1646
+ return {
1647
+ kind: "Pick",
1648
+ names: names.names,
1649
+ nameRanges: names.ranges,
1650
+ bounds,
1651
+ body: parseExpression(),
1652
+ };
1537
1653
  }
1538
1654
  if (accept("CASE")) return { kind: "Case", expression: parseExpression() };
1539
1655
  return {
@@ -1563,10 +1679,12 @@ const parse = (source: string, isTlapm: boolean): Module => {
1563
1679
  const parseStep = (): ProofStep => {
1564
1680
  const start = cursor.index;
1565
1681
  const step = parseStepStart(isAt("QED", 1));
1682
+ const statementStart = cursor.index;
1566
1683
  const scope = new Set<string>();
1567
1684
  proofScopes.push(scope);
1568
1685
  const body: StepBody = accept("QED") ? { kind: "Qed" } : parseStepBody();
1569
1686
  const head = getRange(start);
1687
+ const statement = getRange(statementStart);
1570
1688
  const hasProof = isProofStart(peek());
1571
1689
  if (hasProof && !PROVABLE_STEPS.has(body.kind)) {
1572
1690
  throw createError("Proof of a step that does not take a proof");
@@ -1574,7 +1692,7 @@ const parse = (source: string, isTlapm: boolean): Module => {
1574
1692
  const proof = hasProof ? parseProof() : undefined;
1575
1693
  proofScopes.pop();
1576
1694
  if (body.kind !== "Assert" || body.isSuffices) scope.forEach(declareProofSymbol);
1577
- return withRange({ ...step, body, head, proof }, start);
1695
+ return withRange({ ...step, body, head, statement, proof }, start);
1578
1696
  };
1579
1697
 
1580
1698
  const parseProofBody = (): Proof => {
@@ -1700,11 +1818,12 @@ const parse = (source: string, isTlapm: boolean): Module => {
1700
1818
  if (token.kind === "ModuleEnd" || token.kind === "End") {
1701
1819
  if (token.kind === "ModuleEnd") {
1702
1820
  location.range = {
1703
- module: name,
1821
+ module: openModules[0].name,
1704
1822
  start: { line: location.line, column: location.column },
1705
1823
  end: { line: token.line, column: token.endColumn },
1706
1824
  };
1707
1825
  }
1826
+ if (missingArguments.size > 0) throw createSanyError([...missingArguments.values()]);
1708
1827
  openModules.pop();
1709
1828
  recursiveScopes.pop();
1710
1829
  return module;
@@ -1786,7 +1905,7 @@ const parse = (source: string, isTlapm: boolean): Module => {
1786
1905
  );
1787
1906
  continue;
1788
1907
  }
1789
- addDefinitionUnit(module, parseDefinition(true));
1908
+ addDefinitionUnit(module, withRange(parseDefinitionUnit(true), tokenIndex));
1790
1909
  continue;
1791
1910
  }
1792
1911
  }