ReviewOS

home-lang/home

fix(ts): preserve bigint results for arithmetic operators

#775
Closed glennmichael123 opened this 8 days ago ·
8 days ago

Parent: #548 · Tracker: #416

The unchanged Zod 4.5.2 core gate has one false TS2367 at core/checks.ts:194:52. Both operands of payload.value % (def.value as bigint) are bigint after the typeof branch and assertion, but Home types %, along with every non-add arithmetic expression, as number. The following equality against BigInt(0) therefore compares number to bigint.

Minimal strict ES2022 oracle:

declare const left: bigint;
declare const right: bigint;
const remainder: bigint = left % right;
const equal: boolean = remainder === BigInt(0);
const wrong: number = left % right;

TypeScript 6.0.3 and native TypeScript 7.0.2 emit only TS2322 on wrong. Current ReleaseFast Home instead emits TS2322 on remainder and accepts wrong.

Acceptance:

  • preserve bigint as the result of valid bigint arithmetic, including the arithmetic operator family covered by TypeScript semantics;
  • retain number results for numeric arithmetic and preserve invalid mixed-domain diagnostics;
  • exact three-engine positive/negative oracle parity;
  • remove only checks.ts:194:52 TS2367 from the unchanged Zod core identity set, with zero additions;
  • full checker suite and optimized guarded build pass;
  • no source-name, path, diagnostic, or benchmark special case.
8 days ago

Implemented in d1d9abb and documented in 54ad7e8 + 07c6dc4.

Evidence:

  • bigint arithmetic retains the bigint result domain; the permanent positive/negative checker oracle passes;
  • the unchanged Zod 4.5.2 core set drops only core/checks.ts:194:52 TS2367 from this issue, with no added identity;
  • combined #775/#776 gate is 8 -> 6 identities; final normalized SHA-256 is 64abd7817175b2885f805e3580a8ed0b74727e15f456dde3d85ba9ee3c528d19;
  • full checker and Program suites pass;
  • stripped ReleaseSafe home-tsc passed under the unchanged 3,840 MB guard at 2,603 MB peak.

No source/path/member/diagnostic special case, corpus edit, suppression, or raised memory ceiling.

Sign in to comment on this issue.