ReviewOS

home-lang/home

fix(ts): display awaited targets in async return diagnostics

#478
Closed chris opened this 8 days ago ·
8 days ago

Found while independently validating #474 under #473/#416. With the primitive-return fix, Home now correctly rejects invalid async returns with TS2322, but diagnostic text still uses the syntactic Promise<t> annotation instead of the awaited target T. For example, async function direct(value: number): Promise<string> { return value; } should say number is not assignable to string (both pinned TS 6.0.3 and native TS 7.0.2); Home says number is not assignable to Promise<string>. This also affects expression-bodied async arrows (present before #474), PromiseLike/Promise-return operands, and unknown sources. A local numeric constant return may retain its literal name where TypeScript widens it. Correct annotation-based diagnostic naming to use the actual checked awaited target, preserving ordinary generic/alias return names and diagnostic locations. Add exact-message regressions, including aliases and nested promises, and do not claim byte-for-byte parity from diagnostic-count checks. Keep async outside the benchmark until the remaining #475/#476 correctness controls pass.

8 days ago

Fixed on main by 41c866a (fix(ts): display awaited async return targets (#478)).

Root cause: async return assignability already checked the Awaited<r> body target, but the generic return diagnostic formatter unconditionally reused the syntactic annotation R. Promise<string> therefore overrode the checked string target in TS2322 prose. The fix bypasses that syntax override only while checking async bodies, leaving synchronous generic and alias diagnostics unchanged.

Exact TS 6.0.3 differential coverage now matches for direct values, Promise<number>, PromiseLike<number>, unknown, Promise<text>, an aliased Promise, nested Promises, and an expression-bodied async arrow: 7x Type 'number' is not assignable to type 'string'. and 1x Type 'unknown' is not assignable to type 'string'., with seven return-statement anchors and one expression-body identifier anchor.

Validation:

  • guarded zig build home-tsc: pass
  • focused async diagnostic regression: pass
  • complete ts_checker suite (4,371 tests after this addition): pass
  • rebuilt Home CLI vs pinned TypeScript 6.0.3 eight-case oracle: exact messages and anchors
  • zig fmt --check and git diff --check: pass
  • fixed process-tree ceiling: 3,840 MB; all heavy work serialized

The unchanged frozen Zod core graph and a focused real Zod parse shard exceeded the debug binary's 360s and 180s wall-clock bounds without a memory-bound failure. Those runs are recorded as inconclusive and are not used for a timing or production-parity claim. Async remains excluded from benchmark claims until #475/#476 correctness work lands.

Sign in to comment on this issue.