mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-16 05:00:59 +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.
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
// A function-local `const gb = []` in a JS file is tsc's EVOLVING array
|
|
// (inference starts at never[]) — never's f64 representation (the
|
|
// uninhabited stance) must not capture it, or a later dyn push
|
|
// ("expected number at $, got string") dynChecks strings into a number
|
|
// array. The empty literal routes to the JS dyn-array fallback instead:
|
|
// pushes of dyn values (JSON.parse results), strings, and numbers all
|
|
// land, and length/index/join read back through the keyed-dyn paths.
|
|
'use strict';
|
|
|
|
function viaDyn() {
|
|
const gb = [];
|
|
gb.push(JSON.parse('"s"'));
|
|
gb.push(JSON.parse('2'));
|
|
console.log('dyn:', gb.join('|'), gb.length, gb[0]);
|
|
}
|
|
viaDyn();
|
|
|
|
function viaNumbers() {
|
|
const ns = [];
|
|
for (let i = 0; i < 3; i++) ns.push(i * 10);
|
|
console.log('nums:', ns.join(','), ns.length, ns[2]);
|
|
}
|
|
viaNumbers();
|
|
|
|
// An ANNOTATED empty literal keeps its slot (the contextual type wins
|
|
// over the evolving inference) — jsdoc types the binding.
|
|
function viaAnnotated() {
|
|
/** @type {string[]} */
|
|
const ss = [];
|
|
ss.push('a');
|
|
ss.push('b');
|
|
console.log('ann:', ss.join('-'));
|
|
}
|
|
viaAnnotated();
|
|
|
|
// The mixed command tuple (test/common's pwdCommand shape): the inner
|
|
// empty literal taints the OUTER literal's own type with never[]
|
|
// ((string | never[])[]) — the whole value rides the checked-dynamic tree fallback
|
|
// instead of building a static (number[] | string)[] that fences at the
|
|
// union re-tag.
|
|
function viaMixedTuple() {
|
|
const cmd = ['pwd', []];
|
|
console.log('cmd:', cmd.length, cmd[1].length);
|
|
}
|
|
viaMixedTuple();
|
|
|
|
// The ternary form (the pwdCommand spelling): the dyn arm coerces into
|
|
// the ternary's union slot and the whole binding stays usable.
|
|
function viaTernary(win) {
|
|
const cmd = win ? ['cmd.exe', ['/d', '/c', 'cd']] : ['pwd', []];
|
|
console.log('tern:', cmd.length);
|
|
}
|
|
viaTernary(false);
|
|
viaTernary(true);
|