F# codegen: AsyncMode-aware abort + terminal IResult endpoint (GH-2969)#2982
Merged
Conversation
…H-2969) A route-bound endpoint whose handler returns IResult is AsyncMode.ReturnFromLastNode (the IResult's ExecuteAsync IS the method's returned Task, no task { } block). In that mode every branch of the body must itself be a Task — so the route-guard's abort can't be `()`, it must be Task.CompletedTask. - FSharpEmitHelpers.AbortExpression(method): `()` in a task { } body or a synchronous-Task method (None, where the machinery appends a trailing CompletedTask), but Task.CompletedTask for ReturnFromLastNode. WriteAbortGuard and ReadHttpFrame's route-value 404 guards now use it instead of a bare `()`. - Fixture: GET /fsharp/result/{id} returns IResult with a route value, exercising the ReturnFromLastNode abort (a missing id yields Task.CompletedTask). The terminal IResult is executed directly (matches the C# path; no MaybeEnd guard). MaybeEndWithResultFrame F# emit is intentionally deferred: that frame is added by ResultContinuationPolicy during a full MapWolverineEndpoints compile, which the no-host ChainFor fixture harness doesn't run — so it can't be exercised until the behavioural (host-based) harness lands. Documented inline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 1, 2026
Merged
This was referenced Jun 4, 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.
A route-bound endpoint whose handler returns
IResultcompiles toAsyncMode.ReturnFromLastNode— theIResult'sExecuteAsyncis the method's returnedTask, with notask { }block. In that mode every branch of the body must itself be aTask, so the route-guard's abort can't be()— it must beTask.CompletedTask. This PR makes the abort expression AsyncMode-aware and adds the endpoint that exercises it.Changes
FSharpEmitHelpers.AbortExpression(method)—()inside atask { }body or a synchronous-Taskmethod (None, where the machinery appends a trailingCompletedTask), butTask.CompletedTaskforReturnFromLastNode.WriteAbortGuardandReadHttpFrame's route-value 404 guards now use it instead of a bare().GET /fsharp/result/{id}returnsIResultwith a route value, exercising theReturnFromLastNodeabort (a missingidyieldsTask.CompletedTask). The terminalIResultis executed directly — matching the C# path (noMaybeEndguard for a terminal result).Generated F#
Deferred
MaybeEndWithResultFrameF# emit (theWolverineContinueshort-circuit for intermediate IResults) is intentionally not done here: that frame is added byResultContinuationPolicyduring a fullMapWolverineEndpointscompile, which the no-hostChainForfixture harness doesn't run — so it can't be exercised until the behavioural (host-based) harness lands. Documented inline.Verification
GET /fsharp/result/{id}renders + compiles.wolverine.slnxRelease regression — 0 warnings, 0 errors.Part of #2969.
🤖 Generated with Claude Code