mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-24 06:14:01 +08:00
- Establishment/containment: miss-first ternary polarity, else-if head exits, bare-block vs alias guards, break/continue exit guards, post-loop re-tests, while-condition guards, born-narrowed declarations (2390-2396) - Kill routing: branch/switch-arm/reassignment-polarity kills at merges, and kills riding return/break/labeled-break/continue/throw edges (2397-2406) - Terminality: infinite-loop sealing and re-opening, loop-body returns, stacked and trailing-empty case labels, defaultless exhaustive switches (2407-2411) - do-while trailing tests under body guards, kills, continue, and break, plus spread-arm ternary lowering shapes, ?? null identity, float-lane bounds, IEEE remainder corners, and parameter null reassignment (2412-2423) - Order-parity baselines re-recorded for the new entries (pure addition)
22 lines
635 B
TypeScript
22 lines
635 B
TypeScript
// A switch arm reassigning a narrowed local to null kills the narrow past the switch; other arms keep using the narrow in-body.
|
|
type Msg = { readonly kind: "set"; readonly value: number } | { readonly kind: "clear" };
|
|
function f(q: number | null, msg: Msg): number {
|
|
let p: number | null = q;
|
|
if (p === null) return -1;
|
|
switch (msg.kind) {
|
|
case "set": {
|
|
p = p + msg.value;
|
|
break;
|
|
}
|
|
case "clear": {
|
|
p = null;
|
|
break;
|
|
}
|
|
}
|
|
if (p === null) return 0;
|
|
return p;
|
|
}
|
|
console.log(f(5, { kind: "set", value: 3 }));
|
|
console.log(f(5, { kind: "clear" }));
|
|
console.log(f(null, { kind: "clear" }));
|