mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +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)
23 lines
741 B
TypeScript
23 lines
741 B
TypeScript
// Float results flow through loop BOUNDS (i < limit * 0.5), mixed int/float ternary arms, and union payloads vs float literals — no integer truncation anywhere.
|
|
function steps(limit: number): number {
|
|
let total = 0;
|
|
for (let i = 0; i < limit * 0.5; i++) {
|
|
total += 1;
|
|
}
|
|
return total;
|
|
}
|
|
type Msg = { readonly kind: "set"; readonly value: number } | { readonly kind: "half" };
|
|
function level(msg: Msg): number {
|
|
return msg.kind === "set" ? msg.value : 0.5;
|
|
}
|
|
function pick(flag: boolean): number {
|
|
const n = flag ? 1 : 2.5;
|
|
return n * 2;
|
|
}
|
|
console.log(steps(7));
|
|
console.log(steps(1));
|
|
console.log(level({ kind: "half" }));
|
|
console.log(level({ kind: "set", value: 3 }));
|
|
console.log(pick(true));
|
|
console.log(pick(false));
|