You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement dynamic versions of the resumable code #246
In rare scenarios, for instance, where the resumable code is invoked in a top-level function, the compiler may not be able to compile the resumable code statically. For these cases, we need a dynamic version of the resumable code (which exists, but currently simply raises an exception).
I've implemented the dynamic resumable code path for this issue. A draft PR has been submitted:
Branch: repo-assist/feat-dynamic-246-2026-04-07
What was implemented
TaskSeqDynamicInfo<'T> — a concrete ResumptionDynamicInfo subclass that drives the resumption function and handles yield/await/completion via MoveNext, mirroring the logic in the static MoveNextMethodImpl.
TaskSeqDynamic<'T> — a reference-type IAsyncEnumerable<'T> that stores the initial ResumptionFunc instead of a compiler-generated struct, with proper clone-on-re-enumerate support.
TaskSeqBuilder.Runelse branch — now creates a TaskSeqDynamic<'T> instead of raising NotImplementedException.
taskSeqDynamic CE builder — inherits TaskSeqBuilder with no overrides; in compiled code it is identical to taskSeq, in FSI it takes the dynamic path automatically.
Root cause insight
Storing the compiler-generated machine struct in a base-type field (as was attempted in the commented-out code) loses the specialized IAsyncStateMachine.MoveNext implementation, causing a NullReferenceException. The correct FSI approach is to set ResumptionDynamicInfo on the ResumableStateMachine struct field and let moveNextRef call through to MoveNextDynamic — which the ResumableStateMachine's IAsyncStateMachine.MoveNext handles automatically.
Test results
5093 tests pass (24 new + 5069 existing), 0 failures.
Activity
github-actions commentedon Mar 8, 2026
dsyme commentedon Mar 14, 2026
/repo-assist Have a crack at implementing the dynamic versions of resumable code, including very extensive tests.
feat: implement dynamic resumable code for taskSeq/taskSeqDynamic, fixes
github-actions commentedon Apr 7, 2026
🤖 This is an automated response from Repo Assist.
I've implemented the dynamic resumable code path for this issue. A draft PR has been submitted:
Branch:
repo-assist/feat-dynamic-246-2026-04-07What was implemented
TaskSeqDynamicInfo<'T>— a concreteResumptionDynamicInfosubclass that drives the resumption function and handles yield/await/completion viaMoveNext, mirroring the logic in the staticMoveNextMethodImpl.TaskSeqDynamic<'T>— a reference-typeIAsyncEnumerable<'T>that stores the initialResumptionFuncinstead of a compiler-generated struct, with proper clone-on-re-enumerate support.TaskSeqBuilder.Runelsebranch — now creates aTaskSeqDynamic<'T>instead of raisingNotImplementedException.taskSeqDynamicCE builder — inheritsTaskSeqBuilderwith no overrides; in compiled code it is identical totaskSeq, in FSI it takes the dynamic path automatically.Root cause insight
Storing the compiler-generated machine struct in a base-type field (as was attempted in the commented-out code) loses the specialized
IAsyncStateMachine.MoveNextimplementation, causing aNullReferenceException. The correct FSI approach is to setResumptionDynamicInfoon theResumableStateMachinestruct field and letmoveNextRefcall through toMoveNextDynamic— which theResumableStateMachine'sIAsyncStateMachine.MoveNexthandles automatically.Test results
5093 tests pass (24 new + 5069 existing), 0 failures.
Merge pull request #380 from fsprojects/repo-assist/feat-dynamic-246-…