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
task { } miscompiles access to a ResumableStateMachine<_> of another instantiation #20958
Inside a statically compiled resumable state machine such as task { }, every value of type ResumableStateMachine<X> is compiled as if it were the state machine's own struct, even when X is not the machine's data type. The result is either InvalidProgramException or a read from the wrong memory.
Expected:3 Actual:NullReferenceException. A ResumableStateMachine<string> field read the same way fails with InvalidProgramException instead.
It reproduces with SDK 10.0.114 and current main in Debug and Release, and with SDK 10.0.403 in Release.
The cause is the template replacement in IlxGen.fs (GenNamedTyAppAux, GenRecdFieldRef). It matches on the type constructor only and ignores the type arguments, so this._machine.Data is emitted as a field of the task's generated struct.
This breaks TaskSeqDynamic<'T>.DisposeAsync in FSharp.Control.TaskSeq, which reads its ResumableStateMachine<TaskSeqStateMachineData<'T>> field inside a task.
Activity
Fix task miscompiling ResumableStateMachine<_> of another instantiati…