tla-ts 0.0.3-dev.d34b19a → 0.0.3-dev.e5b05b9
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/README.md +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +71 -22
- package/dist/index.d.ts +71 -22
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +20 -17
- package/dist/run-cli.js +22 -19
- package/dist/transfer.cjs +45 -15
- package/dist/transfer.js +45 -15
- package/package.json +1 -1
- package/src/ast.ts +121 -4
- package/src/builtins.ts +9 -3
- package/src/check.ts +514 -99
- package/src/cli-options.ts +11 -5
- package/src/codegen.ts +15 -22
- package/src/config.ts +224 -170
- package/src/dependencies.ts +2 -2
- package/src/environment.ts +334 -96
- package/src/errors.ts +109 -3
- package/src/evaluate.ts +255 -159
- package/src/exit-codes.ts +39 -42
- package/src/fingerprints.ts +2 -1
- package/src/instances.ts +16 -15
- package/src/levels.ts +185 -44
- package/src/live-check.ts +772 -0
- package/src/liveness.ts +120 -543
- package/src/parallel-worker.ts +2 -2
- package/src/parallel.ts +20 -4
- package/src/parser.ts +182 -53
- package/src/resolve.ts +1302 -412
- package/src/run-cli.ts +115 -20
- package/src/runtime.ts +3 -1
- package/src/sany-lexer.ts +615 -0
- package/src/sany-parse-error.ts +3143 -0
- package/src/spec-description.ts +19 -8
- package/src/standard-modules.ts +54 -45
- package/src/standard-ranges.ts +116 -0
- package/src/state-graph.ts +157 -0
- package/src/subexpressions.ts +124 -159
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +183 -39
- package/src/symmetry.ts +16 -6
- package/src/tableau.ts +51 -24
- package/src/tlc-ext.ts +29 -12
- package/src/tlc-module.ts +14 -33
- package/src/tlc-modules.ts +4 -0
- package/src/tlc-order.ts +25 -7
- package/src/tlc-random.ts +9 -6
- package/src/tlc-summary.ts +20 -5
- package/src/value-sources.ts +29 -0
- package/src/values.ts +242 -61
package/src/errors.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SourceRange } from "./ast";
|
|
2
|
+
import { EXIT_STATUS, getExitCode } from "./exit-codes";
|
|
3
|
+
import type { Value } from "./values";
|
|
4
|
+
|
|
5
|
+
// How TLC reports a RuntimeException it did not expect, such as one raised while computing next
|
|
6
|
+
// states.
|
|
7
|
+
export const UNEXPECTED_EXCEPTION =
|
|
8
|
+
"TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a java.lang.RuntimeException\n: ";
|
|
9
|
+
|
|
10
|
+
// How TLC reports a Java StackOverflowError, which V8 raises as this RangeError.
|
|
11
|
+
export const STACK_OVERFLOW =
|
|
12
|
+
"This was a Java StackOverflowError. It was probably the result\nof an incorrect recursive function definition that caused TLC to enter\nan infinite loop when trying to compute the function or its application\nto an element in its putative domain.";
|
|
13
|
+
|
|
14
|
+
export const isStackOverflow = (error: unknown) =>
|
|
15
|
+
error instanceof RangeError && error.message === "Maximum call stack size exceeded";
|
|
2
16
|
|
|
3
17
|
export class TlaError extends Error {
|
|
4
18
|
constructor(message: string, cause?: unknown) {
|
|
@@ -14,16 +28,66 @@ export interface SyntaxFailure {
|
|
|
14
28
|
isEnd: boolean;
|
|
15
29
|
}
|
|
16
30
|
|
|
31
|
+
// An error SANY reports at a location, such as "In module M" or a range in a module.
|
|
32
|
+
export interface SanyError {
|
|
33
|
+
location: string;
|
|
34
|
+
message: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The errors SANY reports for a spec, and the warnings it prints before them. A fatal error stops it
|
|
38
|
+
// before semantic analysis. SANY's parser prints its message for a module it rejects before the
|
|
39
|
+
// report.
|
|
40
|
+
export interface SanyReport {
|
|
41
|
+
errors: SanyError[];
|
|
42
|
+
warnings: SanyError[];
|
|
43
|
+
isFatal: boolean;
|
|
44
|
+
parseError?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
17
47
|
export class TlaSyntaxError extends TlaError {
|
|
18
48
|
failure: SyntaxFailure | undefined;
|
|
49
|
+
sany: SanyReport | undefined;
|
|
19
50
|
|
|
20
|
-
constructor(message: string, cause?: unknown, failure?: SyntaxFailure) {
|
|
51
|
+
constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport) {
|
|
21
52
|
super(message, cause);
|
|
22
53
|
this.name = "TlaSyntaxError";
|
|
23
54
|
this.failure = failure;
|
|
55
|
+
this.sany = sany;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const createSanyError = (
|
|
60
|
+
errors: SanyError[],
|
|
61
|
+
isFatal = false,
|
|
62
|
+
parseError?: string,
|
|
63
|
+
warnings: SanyError[] = [],
|
|
64
|
+
) =>
|
|
65
|
+
new TlaSyntaxError(
|
|
66
|
+
errors.map((error) => `${error.location}\n\n${error.message}`).join("\n\n"),
|
|
67
|
+
undefined,
|
|
68
|
+
undefined,
|
|
69
|
+
{ errors, warnings, isFatal, parseError },
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// How SANY prints the warnings it reports, which do not stop TLC.
|
|
73
|
+
export const formatSanyWarnings = (warnings: SanyError[]) =>
|
|
74
|
+
`*** Warnings: ${warnings.length}\n\n${warnings.map((warning) => `${warning.location}\n\n${warning.message}\n\n\n`).join("\n")}`;
|
|
75
|
+
|
|
76
|
+
// SANY's message for a module its parser rejects, such as a "***Parse Error***" with the
|
|
77
|
+
// productions it was in.
|
|
78
|
+
export class TlaParseError extends TlaError {
|
|
79
|
+
constructor(message: string) {
|
|
80
|
+
super(message);
|
|
81
|
+
this.name = "TlaParseError";
|
|
24
82
|
}
|
|
25
83
|
}
|
|
26
84
|
|
|
85
|
+
export const formatRange = (range: SourceRange) =>
|
|
86
|
+
`line ${range.start.line}, col ${range.start.column} to line ${range.end.line}, col ${range.end.column} of module ${range.module}`;
|
|
87
|
+
|
|
88
|
+
export const createSemanticError = (message: string, range: SourceRange) =>
|
|
89
|
+
createSanyError([{ location: formatRange(range), message }]);
|
|
90
|
+
|
|
27
91
|
export class TlaConfigError extends TlaError {
|
|
28
92
|
constructor(message: string, cause?: unknown) {
|
|
29
93
|
super(message, cause);
|
|
@@ -41,10 +105,52 @@ export class TlaEvaluationError extends TlaError {
|
|
|
41
105
|
// An evaluation error that TLC raises as an EvalException from a standard module's Java code. It
|
|
42
106
|
// keeps the name TlaEvaluationError, and index.ts doesn't export it.
|
|
43
107
|
export class TlaModuleError extends TlaEvaluationError {
|
|
108
|
+
exitCode: number;
|
|
109
|
+
|
|
44
110
|
constructor(message: string, exitCode: number = EXIT_STATUS.error) {
|
|
45
111
|
super(message);
|
|
46
112
|
this.name = "TlaEvaluationError";
|
|
47
|
-
|
|
113
|
+
this.exitCode = exitCode;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// A variable that a partial state leaves without a value.
|
|
118
|
+
export class TlaUnassignedError extends TlaEvaluationError {
|
|
119
|
+
variable: string;
|
|
120
|
+
|
|
121
|
+
constructor(message: string, variable: string) {
|
|
122
|
+
super(message);
|
|
123
|
+
this.name = "TlaEvaluationError";
|
|
124
|
+
this.variable = variable;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// TLC reports a successor state that the next-state relation leaves incomplete as an error of its
|
|
129
|
+
// own, not as an exception. It keeps the name TlaEvaluationError, and index.ts doesn't export it.
|
|
130
|
+
export class TlaIncompleteStateError extends TlaEvaluationError {
|
|
131
|
+
state: (Value | undefined)[];
|
|
132
|
+
action: string | undefined;
|
|
133
|
+
missing: string[];
|
|
134
|
+
|
|
135
|
+
constructor(state: (Value | undefined)[], action: string | undefined, missing: string[]) {
|
|
136
|
+
super(
|
|
137
|
+
`Successor state is not completely specified by the next-state action. The following variable${missing.length > 1 ? "s are" : " is"} not defined: ${missing.join(", ")}.\n`,
|
|
138
|
+
);
|
|
139
|
+
this.name = "TlaEvaluationError";
|
|
140
|
+
this.state = state;
|
|
141
|
+
this.action = action;
|
|
142
|
+
this.missing = missing;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// TLC reports an initial state that the initial predicate leaves incomplete as an illegal state.
|
|
147
|
+
export class TlaIllegalStateError extends TlaEvaluationError {
|
|
148
|
+
state: (Value | undefined)[];
|
|
149
|
+
|
|
150
|
+
constructor(state: (Value | undefined)[]) {
|
|
151
|
+
super("current state is not a legal state");
|
|
152
|
+
this.name = "TlaEvaluationError";
|
|
153
|
+
this.state = state;
|
|
48
154
|
}
|
|
49
155
|
}
|
|
50
156
|
|