mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +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)
34 lines
931 B
TypeScript
34 lines
931 B
TypeScript
// Unlabeled break stages a kill at the inner loop's exit; a labeled break stages it past the OUTER loop — the outer body read between them differs.
|
|
function nested(grid: readonly number[], cols: number): number {
|
|
let p: number | null = 5;
|
|
if (p === null) return -1;
|
|
let sum = 0;
|
|
for (const r of grid) {
|
|
for (const c of grid) {
|
|
if (c > cols) { p = null; break; }
|
|
sum += p;
|
|
}
|
|
if (p === null) break;
|
|
sum += p;
|
|
}
|
|
return sum;
|
|
}
|
|
function labeled(grid: readonly number[], cols: number): number {
|
|
let p: number | null = 5;
|
|
if (p === null) return -1;
|
|
let sum = 0;
|
|
outer: for (const r of grid) {
|
|
for (const c of grid) {
|
|
if (c > cols) { p = null; break outer; }
|
|
sum += p;
|
|
}
|
|
sum += p;
|
|
}
|
|
if (p === null) return -2;
|
|
return sum + p;
|
|
}
|
|
console.log(nested([1, 2], 3));
|
|
console.log(nested([1, 4], 3));
|
|
console.log(labeled([1, 2], 3));
|
|
console.log(labeled([1, 4], 3));
|