fix(beam): implement Async.AwaitTask#4819
Merged
Merged
Conversation
`Async.AwaitTask` compiled to `fable_async:await_task/1`, which did not exist — the call built cleanly and failed at runtime with `undef`. On the Beam a Task and an Async share one representation (the `task` CE is compiled onto the async builder), so the conversion is the identity. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Async.AwaitTaskcompiled tofable_async:await_task/1, which does not exist in the Beam runtime library. The call built cleanly and failed at runtime withundef:This comes from the catch-all at the end of
asyncsinsrc/Fable.Transforms/Beam/Replacements.fs, which passes any unmappedAsyncmember through tofable_asyncunder its derived name, assuming a matching function exists.Fix
Implemented
await_task/1as the identity. On the Beam aTaskand anAsyncshare one representation — thetaskCE is compiled onto the async builder — so there is nothing to convert. The crash dump above confirms it: the argument is already afable_async_builderfun.Added two tests in
tests/Beam/TaskTests.fs: direct, and inside anasyncCE withlet!.Scope
Other
Asyncmembers reachable through the same catch-all (Choice,OnCancel,TryCancelled,CancelDefaultToken,DefaultCancellationToken,SwitchToThreadPool) are not Beam-specific gaps —src/fable-library-ts/Async.tsandfable_library/async_.pydon't implement them either, and all three targets use the same catch-all shape.AwaitTaskwas the one member where Beam was genuinely behind: JS maps it explicitly toawaitPromiseand Python hasawait_taskin its runtime.Deliberately left out of this PR:
fable_async:*calls against the runtime's exports. Good idea and cheap, but it has its own design questions (which targets, where in the build, how to handle the intentional gaps that would immediately light up red) — worth doing deliberately rather than bundling here.Verification
Full Beam suite green: 2635 Erlang tests pass / 0 fail; .NET side 2616/2616. Both new tests pass.
🤖 Generated with Claude Code