-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Milestone
Description
Consider the following code:
static class Program
{
static void Main()
{
var m = new M();
}
}
struct N<T> { }
struct M { public N<M> E; }This code will compile with C# 6.0 and is legal according to the CLI spec. The type definition is recursive but the layout of the struct is not because the field involved here is an empty struct. The CLR is unable to handle this though and fails at runtime with a TypeLoadException:
'M:Program.Main' failed: Could not load type 'M' from assembly 'ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'M' from assembly 'ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Program.Main()
See also #5479
jnm2, BjarkeCK, kekekeks, ForNeVeR, addabis and 90 more