[Repo Assist] Add YieldFromFinal overloads for F# 10 compatibility#310
Closed
github-actions[bot] wants to merge 2 commits intomainfrom
Closed
[Repo Assist] Add YieldFromFinal overloads for F# 10 compatibility#310github-actions[bot] wants to merge 2 commits intomainfrom
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
- Add YieldFromFinal(IAsyncEnumerable<'T>) in MediumPriority (= YieldFrom) - Add YieldFromFinal(seq<'T>) in MediumPriority (= YieldFrom) - Add YieldFromFinal for generic unit-returning task-likes in LowPriority - Add YieldFromFinal(Task<unit>) and YieldFromFinal(Async<unit>) in HighPriority - Update TaskSeqBuilder.fsi with matching signatures - Update release-notes.txt The F# 10 compiler (dotnet/fsharp#18804) calls YieldFromFinal instead of YieldFrom when yield! or do! appears in a tail-call position. These overloads ensure taskSeq compiles without errors under F# 10. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks
Contributor
|
Added the F# bug about YieldFromFinal here: dotnet/fsharp#19402 Closing as there's no point implementing this if it's not working properly |
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.
🤖 This is an automated PR from Repo Assist.
Closes #62
Summary
The F# 10 compiler (dotnet/fsharp#18804) introduces
YieldFromFinalas a new builder method. Whenyield!ordo!appears in a tail-call position within a computation expression, the compiler emits a call toYieldFromFinalinstead ofYieldFrom. Without these overloads,taskSeqexpressions would fail to compile under F# 10.This PR adds
YieldFromFinaloverloads to thetaskSeqbuilder mirroring the existing priority structure (LowPriority,MediumPriority,HighPriority).Changes
TaskSeqBuilder.fs/.fsiMediumPriorityYieldFromFinal(IAsyncEnumerable<'T>)YieldFromMediumPriorityYieldFromFinal(seq<'T>)YieldFromHighPriorityYieldFromFinal(Task(unit))Bind(task, fun () -> Zero())HighPriorityYieldFromFinal(Async(unit))Bind(computation, fun () -> Zero())LowPriorityYieldFromFinal(^TaskLike)[(NoEagerConstraintApplication)])The
HighPriorityandLowPriorityoverloads are needed because the F# 10 compiler also callsYieldFromFinalfordo!in tail position (e.g. the last expressiondo! someTask()in ataskSeq).Why not the full tailall transfer?
The tailall transfer optimization — where
YieldFromFinalpermanently hands off all futureMoveNextAsynccalls to the inner enumerator — was explored and reverted. The problem is that F# 10 also callsYieldFromFinalforyield!inside loop body lambdas (e.g.for c in source do yield! f c), whereyield! f cis tail-call within the loop bodyfun c -> .... Activating a tail transfer in that case would lose all but the last iteration's elements. There is no way atYieldFromFinalcall time to distinguish a genuine final tail call from a within-loop tail call.The tailall transfer optimization can be revisited in a future PR with a more targeted approach.
Test Status
✅ Build succeeded (
dotnet build src/FSharp.Control.TaskSeq.sln -c Release)✅ All tests passed: 3850 passed, 2 skipped, 0 failed (
dotnet testRelease)✅ Formatting checked with
dotnet fantomas .