Skip to content

Preserve constructor behavior and ordered matches during fusion - #627

Merged
LPTK merged 5 commits into
hkust-taco:hkmc2from
LPTK:codex/pr575-constructor-safety
Nov 10, 2026
Merged

LPTK merged 5 commits into
hkust-taco:hkmc2from
LPTK:codex/pr575-constructor-safety

Conversation

@LPTK

@LPTK LPTK commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

[GPT-6 Astra]

Constructor elimination and fusion can currently drop superclass effects, substitute the original argument after a constructor changes its field, crash on optional-field layouts, or select an incorrect match arm. Check the current IR constructor and its superclass chain before skipping construction, validate the parameter-to-field mapping before field fusion, and share an ordered producer-aware branch decision between fusion eligibility and rewriting.

Default-branch closures retain producer-specific field layouts. Regressions cover the four failures above, tuple/Array/Object matching, differing default-branch arities, lifted captures, and safe elimination of pure constructors.

This is E21–E23 from #575: 170 changed Scala lines across three files, plus regressions and regenerated goldens. It targets current hkmc2 independently of #575 and the other extraction PRs.

If integrating after #575, remove its E21–E23 :fixmes in slop/Erasure.mls and slop/strictres/OptionalBinding.mls. The deforestation follow-up #624 has additional E21–E23 markers to reconcile if it has also landed. Preserve the assertions and regenerate shared goldens.

@ychenfo

ychenfo commented Nov 9, 2026

Copy link
Copy Markdown
Member

Looks good to me, thanks!

@LPTK
LPTK merged commit 54bd6de into hkust-taco:hkmc2 Nov 10, 2026
1 check passed
@LPTK
LPTK deleted the codex/pr575-constructor-safety branch November 10, 2026 05:29
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.

3 participants