Resumable state machines: Don't capture definitions by "builder@" prefix. EXPERIMENTAL#19482
Resumable state machines: Don't capture definitions by "builder@" prefix. EXPERIMENTAL#19482majocha wants to merge 2 commits intodotnet:mainfrom
Conversation
Refactored LowerStateMachines.fs to identify state machine binding variables using only "expand var" or member "this" checks, removing the "builder@" name prefix logic. Updated TaskGeneratedCode.fs to align the generated IL for Generic1InGeneric1<'T>.run with the new binding logic, introducing a TaskBuilder local and adjusting closure variable handling.
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
| .locals init (class [FSharp.Core]Microsoft.FSharp.Control.TaskBuilder V_0, | ||
| valuetype Test/Generic1InGeneric1`1/clo@7<!T,!!A> V_1, | ||
| valuetype Test/Generic1InGeneric1`1/clo@7<!T,!!A>& V_2) | ||
| IL_0000: call class [FSharp.Core]Microsoft.FSharp.Control.TaskBuilder [FSharp.Core]Microsoft.FSharp.Control.TaskBuilderModule::get_task() |
There was a problem hiding this comment.
this getter call is the only substantial change in the IL. It gets eliminated with "--optimize+"
AI says: Refactored LowerStateMachines.fs to identify state machine binding variables using only "expand var" or member "this" checks, removing the "builder@" name prefix logic. Updated TaskGeneratedCode.fs to align the generated IL for Generic1InGeneric1<'T>.run with the new binding logic, introducing a TaskBuilder local and adjusting closure variable handling.
Description
I don't yet have a good small repro.
Situations of mixed use of both resumable and standard computation expressions can in some rare cases result in:
on a non-resumable CE let binding.
It is not clear to me why there's a need to special case
builder@vals during state machine lowering. Some builders may not be resuamble and are erroneously added to ResumableCodeDefns.This is an experiment to eliminate the string prefix "builder@" logic to see if things still work.