ReviewOS

home-lang/home

fix(ts): preserve nested array-rest binding types on reassignment

#695
Closed chris opened this 9 days ago ·
9 days ago

Discovered by the required full Zig aggregate during #693 / #66 verification on main baseline f575a8d0d. No TypeScript checker, binder, HIR, or conformance source changed in that runtime batch.

zig build test --summary all -j2 -Doptimize=ReleaseFast reports 1,418 passes / 1 failure in the TypeScript conformance artifact. The failing existing test is conformance: objectRestAssignment passes clean in packages/ts_conformance/src/ts_conformance.zig.

The standalone zig-out/bin/home-tsc --noEmit --target es2015 /tmp/object-rest.ts reproduction also rejects the existing fixture:

// @strict: false
// @target: es2015
let ka: any;
let nested: { ki };
let other: number;
let rest: { };
let complex: { x: { ka, ki }, y: number };
({x: { ka, ...nested }, y: other, ...rest} = complex);

let overEmit: { a: { ka: string, x: string }[], b: { z: string, ki: string, ku: string }, ke: string, ko: string };

var { a: [{ ...nested2 }, ...y], b: { z, ...c }, ...rest2 } = overEmit;
({ a: [{ ...nested2 }, ...y], b: { z, ...c }, ...rest2 } = overEmit);

Home reports TS2739 at the second ...y: Type '{ ka: string; x: string; }[]' is missing the following properties from type '{ ka: string; x: string; }': ka, x.

Investigate the declaration/binding type of the nested array-rest target and its later assignment relation. The rest target must retain its array type; do not silence the diagnostic or weaken the existing conformance assertion. Verify both valid reassignment and a negative control with incompatible element types, then rerun the existing object-rest conformance coverage and the affected checker gate.

9 days ago

Fixed in e148e06c1, pushed to origin/main as Chris Breuer without coauthors.

The root cause was recordBindingPatternFlowFromSource overwriting an array-rest target with one element's type. It now records arrayRestSourceType before descending into the target, preserving arrays and tuple tails. The existing regression now requires zero diagnostics (its old TS2322-only assertion missed TS2739); new negative tests verify wrong element types and reversed tuple order remain errors.

Focused checker artifact: 4/4. Complete unchanged TypeScript conformance artifact: 1,419/1,419, including objectRestAssignment. The original standalone home-tsc --noEmit --target es2015 reproduction exits zero with no diagnostics. Optimized build: 46/46. No conformance fixture or diagnostic expectation was weakened. #66 has the current publication; the interrupted full aggregate and other parity gaps remain incomplete.

Sign in to comment on this issue.