WIP Rename the fatal form of assert to `vat.assert`
MODIFY
packages/endo/src/lockdown.js
packages/endo/src/lockdown.js
@@ -5,3 +5,7 @@ import "ses";
lockdown({
errorTaming: "unsafe"
});
+
+// Even on non-v8, we tame the start compartment's Error constructor so
+// this assignment is not rejected, even if it does nothing.
+Error.stackTraceLimit = Infinity;

RENAME
packages/ses/src/error/confirm.js
packages/ses/src/error/vat-assert.js
@@ -17,20 +17,21 @@ if (typeof abandon === 'function') {
raise = reason => {
// Check `console` each time `raise` is called.
if (typeof console === 'object' && typeof console.error === 'function') {
- console.error('Failed to confirm because:', reason);
+ console.error('Failed because:', reason);
}
abandon(1);
};
}
-/*
- * @type {Assert | undefined}
+/**
+ * @type {Partial<{assert: Assert}>}
*
* When run in the start compartment, this sniffs to see if there are known
* forms of host-provided functions for immediately terminating the enclosing
* Unit of Preemptive Termination. If so, we initialize the exported
- * `confirm` object to be like `assert`. But rather than throwing the error,
- * `confirm` logs the error to the current `console`, if any, and terminating
+ * `vat` object with its own `assert`, which is like the global `assert`.
+ * But rather than throwing the error as global `assert` does,
+ * `vat.assert` logs the error to the current `console`, if any, and terminates
* this unit of computation.
*
* See https://github.com/tc39/proposal-oom-fails-fast for the meaning of a
@@ -39,6 +40,9 @@ if (typeof abandon === 'function') {
* corrupted state. We preemptively terminate it in order to abandon that
* corrupted state.
*/
-const confirm = raise ? makeAssert(raise) : undefined;
-freeze(confirm);
-export { confirm };
+const vat = {};
+if (raise) {
+ vat.assert = makeAssert(raise);
+}
+freeze(vat);
+export { vat };

DELETE
packages/ses/test/error/confirm-show-failure.js
-// This file does not end in ".test.js" because it is not useful as a test
-// file. Rather, its purpose is just to run it to see what a `confirm`
-// failure looks like.
-
-import '../../ses.js';
-import { confirm } from '../../src/error/confirm.js';
-
-lockdown();
-
-confirm.equal(3, 4);

ADD
packages/ses/test/error/vat-show-failure.js
+// This file does not end in ".test.js" because it is not useful as a test
+// file. Rather, its purpose is just to run it to see what a `vat.assert`
+// failure looks like.
+
+import '../../ses.js';
+import { vat } from '../../src/error/vat-assert.js';
+
+lockdown();
+
+vat.assert.equal(3, 4);

WIP Rename the fatal form of assert to `vat.assert` (#495)