Skip to content

No error for ref fields in non-ref structs #62596

@Sergio0694

Description

@Sergio0694

Version Used: VS 17.3.0 Preview 3.0, .NET 7.0.100-preview.6.22352.1

Steps to Reproduce:

  1. Paste the following code (sharplab):
struct Foo
{
    public ref int Bar;
}
  1. Observe no compile error is produced (a TypeLoadException is instead thrown at runtime)

Expected Behavior:

This should result in some build error about a non-byref-like type having a byref field.

Actual Behavior:

The code produces no build error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions