Skip to content

Compiler stack overflow on self-referential nullable union with updated-memory-safety-rules #85762

Description

@akoeplinger

Repro:

public union NullableNat(bool, NullableNat?);

Compile as a library with /langversion:preview /nullable:enable /features:updated-memory-safety-rules and .NET 11 reference assemblies.

Compiler 5.12.0-1.26463.105 succeeds. Compiler 5.12.0-1.26471.108 stack-overflows; the latter succeeds without the feature flag.

The recursive stack goes through SourceMemberContainerTypeSymbol.AddSynthesizedTypeMembersIfNecessary, Binder.BindType, and Binder.ReportDiagnosticsIfUnsafeMemberAccess / checkTypeArgumentWithConstructorConstraint, which accesses InstanceConstructors while union members are being synthesized.

This blocks dotnet/runtime#134394. CI build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1609539. The constraint-check changes in #84888 appear relevant. The same failure reproduces locally on macOS arm64 compiling System.Text.Json.Tests.

Expected: Successful compilation without disabling updated memory-safety checks.

Note

This issue was generated by GitHub Copilot.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions