Skip to content

Fix nested struct field assignment emission - #2826

Merged
DavidObando merged 6 commits into
mainfrom
fix/issue-2818
Jul 28, 2026
Merged

Fix nested struct field assignment emission#2826
DavidObando merged 6 commits into
mainfrom
fix/issue-2818

Conversation

@DavidObando

Copy link
Copy Markdown
Owner

Summary

  • emit expression-based value-type field receivers through managed addresses
  • plan spill locals for non-addressable struct rvalue receivers
  • add executing regressions for nested class-held structs and struct rvalues

Root cause

Expression-based field assignments always emitted receiver values before stfld. Nested struct receivers therefore used ldfld, pushing a copy where CLR requires a managed pointer. Routing through existing instance-receiver addressability logic emits ldflda for addressable field chains and ldloca for spilled rvalues.

Validation

  • dotnet test test/Compiler.Tests/Compiler.Tests.csproj --no-restore --filter FullyQualifiedName~FieldAssignmentEmitTests (10 passed)
  • related emitter regressions (47 passed)
  • dotnet test test/Compiler.Tests/Compiler.Tests.csproj --no-restore (3551 passed)

Closes #2818

@DavidObando
DavidObando merged commit 355f09b into main Jul 28, 2026
10 checks passed
@DavidObando
DavidObando deleted the fix/issue-2818 branch July 28, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting a field on a struct stored in a class throws InvalidProgramException

1 participant