Skip to content

Combination ref struct and ref parameter causes type constraint IL verification errors #1328

Description

@mikernet

Description

Combination of ref struct and ref parameters causes validation to fail for the code below. Making BinaryReader a normal non-ref struct or making the parameters non-ref causes the validation error to go away.

Reproduction Steps

Sharplab link

ref struct BinaryReader {}

static class IntProcessor
{
    public static void Read(ref BinaryReader reader)
    {
    }
}

public static class Program {
    public static void Main() {
        BinaryReader reader = new();
        IntProcessor.Read(ref reader);
    }
}

Configuration

.NET 8.0.0

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions