Skip to content

Fix task miscompiling ResumableStateMachine<_> of another instantiation - #20959

Merged
abonie merged 3 commits into
dotnet:mainfrom
majocha:fix-resumable-template-instantiation
Nov 10, 2026
Merged

abonie merged 3 commits into
dotnet:mainfrom
majocha:fix-resumable-template-instantiation

Conversation

@majocha

@majocha majocha commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #20958

A statically compiled state machine replaced every ResumableStateMachine<_> in its body with its own generated struct. The replacement now applies only at the template's own instantiation, so fields and locals of other instantiations keep their type and field references.

A value of exactly the template's instantiation, e.g. a ResumableStateMachine<TaskStateMachineData<int>> field read inside a task<int>, still can't be told apart from the machine and is still replaced.

🤖 Generated with Claude Code

…uct type

A statically compiled resumable state machine replaced every
ResumableStateMachine<_> in its body with its own generated struct, so
fields and locals of other instantiations were miscompiled
(InvalidProgramException or reads of the wrong field). Apply the
replacement only when the type arguments match the template's.

Fixes dotnet#20958
@majocha
majocha marked this pull request as draft November 9, 2026 17:03
@majocha
majocha marked this pull request as ready for review November 9, 2026 23:19
@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Nov 10, 2026
@abonie
abonie merged commit 59c7477 into dotnet:main Nov 10, 2026
55 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in F# Compiler and Tooling Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

task { } miscompiles access to a ResumableStateMachine<_> of another instantiation

2 participants