Repository navigation
Preserve callable signatures through IR transformations - #600
Merged
Merged
Conversation
Give generated functions physical signatures and freshen lifted, specialized, and eta-expanded definitions when their parameter lists change. Preserve complete result descriptors for parameter-only rewrites, and give capture wrappers their own direct result. A generator forwarding wrapper must not wrap the iterator a second time. Publish deforestation branch and continuation signatures after captures are known, type nullary closure temporaries, and preserve the enclosing return boundary when fusion replaces a return with a call. Keep the unsupported unboxed closure-result case as an explicit regression. Extract B04 (E13, E25-E26, E28) from hkust-taco#575. E12 constructor typing is deferred to the optimizer-safety batch because it exposes unsafe optional-field fusion. Validation: Metals; ctest and cwtest; focused eta, DPE and signature suites; hkmc2AllTests/test (1,161 tests). Also checked capturing, eta and handler cases with the separate IR-representation checker temporarily applied. Reviewed the complete diff and committed regenerated golden outputs.
# Conflicts: # hkmc2/shared/src/test/mlscript/basics/MultiParamListClasses.mls
Remove the async annotation from lifted forwarding wrappers so their direct-result signatures match their behavior. Preserve the remaining function for curried async calls. Add simple and curried capture regressions with runtime expectations and typed IR snapshots. Both fail before the fix and pass afterward. Validation: Metals compilation; ctest; sdtest CallableSignatures; hkmc2AllTests/test (1,162 tests).
LPTK
commented
Oct 30, 2026
LPTK
left a comment
Contributor
Author
There was a problem hiding this comment.
LGTM now except for these more minor points.
Contributor
Author
|
Once again, some smelly designs were averted. Simplicity must be fought for again and again... Trying to maintain signature info separately from the construction of function definitions was silly, as it required keeping two distant things in sync with thoughts and prayers. FYI @ychenfo. |
LPTK
pushed a commit
to LPTK/mlscript
that referenced
this pull request
Oct 30, 2026
Integrate hkust-taco#599 and hkust-taco#600 while preserving inferred erasure and representation-changing deforestation. Reconcile shared function signatures with retyped and refreshed bindings, retain inferred wrapper regressions, and adapt the cast-comment fixtures to inference and cast elimination. Update the extraction plan and include regenerated golden outputs. Validation: Metals hkmc2JVM compilation and hkmc2AllTests/test (1,172 tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[GPT-6 Astra]
Compiler rewrites could leave a function symbol's erased signature describing its old parameter lists or result convention. This keeps signatures consistent through function generation, capture lifting, eta expansion, dead-parameter elimination, specialization, and tail-call optimization.
FunDefn.Signature. The privateFunDefnconstructor initializes an unset symbol or checks that it shares the same erasure object;copyenforces the same rule. Body-only rewrites reuse the signature. Copies refresh parameter and definition symbols together, and calling-convention changes use fresh symbols with updated references.f(x, y?, ...xs, z)lowers tof(x, ...args);y,xs, andzbecome local variables initialized fromargs. The erased signature must list onlyxas a fixed parameter; it previously listed bothxandy.Adds runtime and typed-IR regressions for simple and curried async capture wrappers, generator wrappers, nested specialization, recursive and forward calls, binding refresh during tail-call conversion, and optional/variadic captures. The unsupported unboxed result of an indirect deforestation call remains an explicit
:fixme.Ports the callable-signature changes from #575 (B04: E13, E25–E26, E28).
Validation: Metals compilation and
hkmc2AllTests/test— 1,163 tests passed, including the compile-test prerequisites and JS/Wasm regressions. Golden outputs are updated and committed; the complete PR diff was checked for accidental whitespace changes.