mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
- The ratified rename rider (world-unification §7 lane 5): "DOM" collided with the browser DOM and, post-lane-1, the structure is no longer a document tree. Comments and doc prose now say "the checked-dynamic tree" for the noun and "dyn" adjectivally; runtime symbol names (scr_dyn_*), the error.domClone libCall, and the real web DOMException family are unchanged. - The few user-facing strings carrying the nickname move with it (the structuredClone cyclic message, the dc subscriber/publish fences, two emitter ICE texts); diagnostics snapshots regenerated (96 pass). One private compiler constant (DOM_PROTO_METHOD_NAMES -> DYN_PROTO_METHOD_NAMES) rides along. - Mechanical sweep, 142 files, comments/prose only — no behavior change.
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
// `throw` of CHECKED-DYNAMIC values in JS files: the dyn node rides the
|
|
// exception cell BY REFERENCE — a caught dyn is the same node every other
|
|
// holder sees (assert.strictEqual against the original error answers
|
|
// true, the error-identity cache), scalar dyn throws re-materialize their
|
|
// values, and a rethrough try/finally keeps the payload intact.
|
|
'use strict';
|
|
const assert = require('assert');
|
|
|
|
function take(e) { throw e; }
|
|
|
|
const boom = new Error('boom');
|
|
try {
|
|
take(boom);
|
|
} catch (err) {
|
|
console.log('caught', err.name, err.message);
|
|
assert.strictEqual(err, boom); // one error object, one dyn identity
|
|
console.log('identity ok');
|
|
}
|
|
|
|
// Scalar dyn payloads come back as their values.
|
|
try {
|
|
take('plain string');
|
|
} catch (err) {
|
|
console.log('caught string:', err);
|
|
}
|
|
try {
|
|
take(42);
|
|
} catch (err) {
|
|
console.log('caught number:', err);
|
|
}
|
|
|
|
// A rethrow through finally keeps the same payload.
|
|
function relay(e) {
|
|
try {
|
|
take(e);
|
|
} finally {
|
|
console.log('finally ran');
|
|
}
|
|
}
|
|
try {
|
|
relay(boom);
|
|
} catch (err) {
|
|
assert.strictEqual(err, boom);
|
|
console.log('relay identity ok');
|
|
}
|