tla-ts 0.0.3-dev.5e6ab4d → 0.0.3-dev.72cc0d2
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/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/transfer.cjs +18 -14
- package/dist/transfer.js +18 -14
- package/package.json +1 -1
- package/src/check.ts +8 -3
- package/src/errors.ts +5 -0
- package/src/evaluate.ts +3 -1
- package/src/parallel.ts +15 -2
- package/src/successors.ts +10 -6
package/package.json
CHANGED
package/src/check.ts
CHANGED
|
@@ -2,7 +2,13 @@ import type { Assumption, Definition, Expression, SourceLocation } from "./ast";
|
|
|
2
2
|
import { parseConfig, type ConfigValue, type ModelConfig } from "./config";
|
|
3
3
|
import { getReadVariables } from "./dependencies";
|
|
4
4
|
import { createEnvironment } from "./environment";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getErrorExitCode,
|
|
7
|
+
TlaConfigError,
|
|
8
|
+
TlaEvaluationError,
|
|
9
|
+
TlaModuleError,
|
|
10
|
+
UNEXPECTED_EXCEPTION,
|
|
11
|
+
} from "./errors";
|
|
6
12
|
import { EXIT_STATUS, setExitCode, setNextStatePhase, withLivenessExitCode } from "./exit-codes";
|
|
7
13
|
import {
|
|
8
14
|
describeRange,
|
|
@@ -828,8 +834,7 @@ export const createSearch = (
|
|
|
828
834
|
holdsLikeTlc(
|
|
829
835
|
constraint.expression,
|
|
830
836
|
getContext(environment, state, next),
|
|
831
|
-
(expression) =>
|
|
832
|
-
`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: ${getExpectedBoolean(expression, environment)}`,
|
|
837
|
+
(expression) => `${UNEXPECTED_EXCEPTION}${getExpectedBoolean(expression, environment)}`,
|
|
833
838
|
),
|
|
834
839
|
),
|
|
835
840
|
trackStatePossible:
|
package/src/errors.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { EXIT_STATUS, getExitCode, setModuleExitCode } from "./exit-codes";
|
|
2
2
|
|
|
3
|
+
// How TLC reports a RuntimeException it did not expect, such as one raised while computing next
|
|
4
|
+
// states.
|
|
5
|
+
export const UNEXPECTED_EXCEPTION =
|
|
6
|
+
"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: ";
|
|
7
|
+
|
|
3
8
|
export class TlaError extends Error {
|
|
4
9
|
constructor(message: string, cause?: unknown) {
|
|
5
10
|
super(message, { cause });
|
package/src/evaluate.ts
CHANGED
|
@@ -1757,7 +1757,9 @@ const compile = (expression: Expression, environment: Environment): Evaluator =>
|
|
|
1757
1757
|
if (expectBoolean(arm.condition(context), "a CASE guard")) return arm.body(context);
|
|
1758
1758
|
}
|
|
1759
1759
|
if (other) return other(context);
|
|
1760
|
-
throw new TlaEvaluationError(
|
|
1760
|
+
throw new TlaEvaluationError(
|
|
1761
|
+
`Attempted to evaluate a CASE with no conditions true.\n${describeRange(expression)}`,
|
|
1762
|
+
);
|
|
1761
1763
|
};
|
|
1762
1764
|
}
|
|
1763
1765
|
case "Let": {
|
package/src/parallel.ts
CHANGED
|
@@ -102,7 +102,17 @@ const spawnWorker = async (onMessage: (message: WorkerMessage) => void): Promise
|
|
|
102
102
|
|
|
103
103
|
export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
104
104
|
const config = typeof options.config === "string" ? parseConfig(options.config) : options.config;
|
|
105
|
-
const
|
|
105
|
+
const print = options.onPrint ?? console.log;
|
|
106
|
+
const printed = { count: 0 };
|
|
107
|
+
// The search on the calling thread prints what this one printed while it started, so it skips that.
|
|
108
|
+
const fallBack = () => {
|
|
109
|
+
const skipped = { count: printed.count };
|
|
110
|
+
return checkSequentially({
|
|
111
|
+
...options,
|
|
112
|
+
config,
|
|
113
|
+
onPrint: (text) => (skipped.count-- > 0 ? undefined : print(text)),
|
|
114
|
+
});
|
|
115
|
+
};
|
|
106
116
|
const count = options.workers ?? 1;
|
|
107
117
|
const isSequential =
|
|
108
118
|
count < 2 ||
|
|
@@ -129,7 +139,10 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
129
139
|
source: options.source,
|
|
130
140
|
loadModule,
|
|
131
141
|
loadClass,
|
|
132
|
-
print:
|
|
142
|
+
print: (text) => {
|
|
143
|
+
printed.count++;
|
|
144
|
+
print(text);
|
|
145
|
+
},
|
|
133
146
|
files: { readFile: options.readFile, writeFile: options.writeFile },
|
|
134
147
|
});
|
|
135
148
|
const environment = specification.environment;
|
package/src/successors.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Bound, Definition, Expression } from "./ast";
|
|
2
2
|
import { getReadVariables } from "./dependencies";
|
|
3
|
-
import { TlaEvaluationError } from "./errors";
|
|
3
|
+
import { TlaEvaluationError, UNEXPECTED_EXCEPTION } from "./errors";
|
|
4
4
|
import { EXIT_STATUS, setExitCode } from "./exit-codes";
|
|
5
5
|
import {
|
|
6
6
|
describeLocation,
|
|
7
|
+
describeRange,
|
|
7
8
|
bindArgument,
|
|
8
9
|
bindDefinitions,
|
|
9
10
|
bindOperatorArguments,
|
|
@@ -804,7 +805,9 @@ const compileAction = (
|
|
|
804
805
|
);
|
|
805
806
|
const body = arm?.body ?? other;
|
|
806
807
|
if (!body)
|
|
807
|
-
throw new TlaEvaluationError(
|
|
808
|
+
throw new TlaEvaluationError(
|
|
809
|
+
`${UNEXPECTED_EXCEPTION}In computing next states, TLC encountered a CASE with no conditions true.\n${describeRange(expression)}`,
|
|
810
|
+
);
|
|
808
811
|
body(run, scope, partial, action, isFixed, onComplete);
|
|
809
812
|
};
|
|
810
813
|
}
|
|
@@ -913,18 +916,19 @@ export const isEnabled = (expression: Expression, context: Context): boolean =>
|
|
|
913
916
|
);
|
|
914
917
|
}
|
|
915
918
|
const environment = context.environment;
|
|
916
|
-
const
|
|
919
|
+
const run: Run = { environment, isInit: false, current: state, isStopped: false };
|
|
920
|
+
// TLC stops computing ENABLED at the first successor, so it skips the rest of the action.
|
|
917
921
|
getRunner(expression, environment, false)(
|
|
918
|
-
|
|
922
|
+
run,
|
|
919
923
|
context.scope,
|
|
920
924
|
getEmptyState(environment),
|
|
921
925
|
undefined,
|
|
922
926
|
false,
|
|
923
927
|
() => {
|
|
924
|
-
|
|
928
|
+
run.isStopped = true;
|
|
925
929
|
},
|
|
926
930
|
);
|
|
927
|
-
return
|
|
931
|
+
return run.isStopped;
|
|
928
932
|
};
|
|
929
933
|
|
|
930
934
|
export const forEachInitialState = (
|