Skip to content

Retype fused values and prove representation casts - #624

Closed
LPTK wants to merge 1 commit into
hkust-taco:codex/pr575-inference-basefrom
LPTK:codex/pr575-deforestation-retyping
Closed

LPTK wants to merge 1 commit into
hkust-taco:codex/pr575-inference-basefrom
LPTK:codex/pr575-deforestation-retyping

Conversation

@LPTK

@LPTK LPTK commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

[GPT-6 Astra]

Deforestation can replace a nominal object with a closure or a field value. Keeping the old physical slot types then produces errors such as using Function where a recursive result still expects AA. This change retypes parameters, locals, captured values, results, specialized instances and their callers together.

Cast proofs consider every incoming producer, including copied and recursive schemes. Unknown or incompatible producers invalidate the proof; a proved cast disappears only when fusion changes its operand's representation. Regression coverage includes monomorphic and polymorphic forwarding, recursion, mixed fused/unfused producers, captures, storage and effectful non-returning paths.

This extracts E29–E30 from #575: 421 changed Scala lines across nine files, plus regression inputs and regenerated goldens. The constructor/match and storage defects tracked as E21–E24 retain targeted :fixmes and their original assertions; #627 and #628 address them.

Merge after #575. The temporary base codex/pr575-inference-base mirrors the reduced #575 at f74e393f5, keeping this review limited to the extraction. After #575 merges, integrate updated hkmc2 into this branch and retarget the PR to hkmc2; this also reconciles ancestry if #575 is squash-merged. Reconcile the fixmes if the constructor/storage fixes have already landed. This PR does not depend on the mutable-record syntax follow-up #625.

Extract E29–E30 on the reduced inference branch. Retype parameters, locals, captures, results and instance copies together with caller coercions. Preserve casts unless all producers prove them safe and fusion changes the representation.

Validation: Metals compilation and hkmc2AllTests/test (1,295 tests); golden outputs included.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants