Repository navigation
fix(js/ts/python): preserve JS/TS generic unit arguments and Python unit continuations - #5037
Merged
Merged
Conversation
dbrattli
marked this pull request as ready for review
October 3, 2026 20:13
Contributor
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
MangelMaxime
force-pushed
the
fix/python-unit-continuations
branch
from
October 10, 2026 16:36
70d776b to
58597af
Compare
This was referenced Oct 11, 2026
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.
Why
The JavaScript and TypeScript compiler drops unit arguments when calling local generic functions, generating
fromValue()instead offromValue(undefined). Call-site types are specialized to unit, so using them to erase arguments loses the function's declared generic parameter. This affects the shared JS/TS code generator and causes TypeScript compilation to fail with TS2554. Generic functions must receive their unit value while ordinaryunit -> unitcallbacks retain their zero-argument convention.Python has two related unit continuation failures.
Async.FromContinuations(fun (ok, _, _) -> ok ())invokes a runtime success continuation without its required value. A unit continuation inside a tail-recursive function can also put a captured callback in its first default parameter, which the runtime'sNoneargument overwrites. Both failures reproduce by executing generated Python.How
any. GeneratefromValue(undefined)for a generic factory and keepcallback()for an ordinary unit callback.FromContinuationsruntime adapter and select it at the replacement boundary, preserving the existing generic API and ordinary unit call semantics.__unit.Validation
on_successmissingvalue, and a callback overwritten withNone). They pass with the compiler/runtime fixes../build.sh test typescriptreproduces TS2554 atAsyncTests.ts(134,34)forfromValue(). After:./build.sh test typescript --force-fable-librarypasses TypeScript compilation and all 2,884 generated tests using TypeScript 7.0.2. Generated code passesundefinedto the factory and alias, and invokes ordinary unit callbacks without arguments../build.sh test javascript --force-fable-librarypasses 2,937 .NET, 3,107 JS, 3,132 Temporal JS, React 26 tests/19 snapshots, and Adaptive 1 test../build.sh test python --type-check --skip-fable-library-corepasses 2,399 .NET and 2,489 Python tests. Generated Pyright matches the existing baseline of 34 errors/45 warnings; the async regression module and changed Python adapter have 0 errors/0 warnings. Existing abandoned-event-loop warnings remain observable with the published runtime as well../build.sh test beampasses 2,712 .NET and 2,746 BEAM tests, plus entry-point checks. Repository-wide Fantomas andgit diff --checkpass.