mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-29 07:04:09 +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)
21 lines
648 B
TypeScript
21 lines
648 B
TypeScript
// A terminal guard inside a bare { } block narrows past the block; narrowing a block-local ALIAS narrows only the alias — the outer binding re-tests after the block.
|
|
interface P { readonly v: number; }
|
|
function blockGuard(p: P | null): number {
|
|
{ if (p === null) return -1; }
|
|
return p.v;
|
|
}
|
|
function aliasGuard(q: P | null): number {
|
|
{
|
|
const inner = q;
|
|
if (inner === null) return -1;
|
|
if (inner.v === 7) return 7;
|
|
}
|
|
if (q === null) return 0;
|
|
return q.v;
|
|
}
|
|
console.log(blockGuard({ v: 5 }));
|
|
console.log(blockGuard(null));
|
|
console.log(aliasGuard(null));
|
|
console.log(aliasGuard({ v: 7 }));
|
|
console.log(aliasGuard({ v: 5 }));
|