-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersBugFeature - Primary ConstructorsResolution-DuplicateThe described behavior is tracked in another issueThe described behavior is tracked in another issue
Milestone
Description
Version Used:
main branch
Steps to Reproduce:
The following struct compiles fine:
public ref struct WithRefField
{
public readonly ref readonly int X;
public WithRefField(ref int x)
{
X = ref x;
}
}
But it won't compiles in a primary constructor form:
public ref struct WithRefField(ref int x)
{
public readonly ref readonly int X = ref x;
}
Error CS9077 : Cannot return a parameter by reference 'x' through a ref parameter; it can only be returned in a return statement
Expected Behavior:
Both forms compile fine
Metadata
Metadata
Assignees
Labels
Area-CompilersBugFeature - Primary ConstructorsResolution-DuplicateThe described behavior is tracked in another issueThe described behavior is tracked in another issue