Skip to content

Circular struct reference still causing TypeLoadException #115451

@hopperpl

Description

@hopperpl

Description

This is somewhat a duplicate of ...

#85134
#6924

... which state that is should be fixed with .NET 8 but the code below crashes with 9.0.4

Is this an oversight? Is this a known issue?

The TypeLoadException thrown is so information-less and it took me some time to track it down. I would really appreciate it if TypeLoadException could give some hint or clue about what went wrong and if it's just printing the word "circular", "missing", "mismatch" or something. Or the JIT compiler just prints a line via OutputDebugString. At least something more than 🤷.

Reproduction Steps

using System.Collections.Immutable;

_ = Crash.Me; 

public struct Crash
{
  public static readonly ImmutableArray<Crash> Me;
}

Expected behavior

throw new TypeLoadException("circular reference of type 'Crash' detected which is not supported")

or

no issue anymore, works fine since NET 8

Actual behavior

throw new TypeLoadException() + 🤷

Regression?

no regression

Known Workarounds

ImmutableArray<T> --> T[] works just fine

Configuration

.NET 9.0.4

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions