Beef icon indicating copy to clipboard operation
Beef copied to clipboard

[IDE][Crash][Comptime] Accessing protected fields using [Friend] attribute directly from typeof(T) causes IDE to crash

Open kallisto56 opened this issue 2 years ago • 0 comments

Hi there,

Code like typeof(Program).[Friend]mTypeCode causes IDE to crash, if that is used in comptime. Declaring a variable that will hold the Type first, does not trigger a crash. It only crashes when the combination of typeof(T) and Friend is used on protected fields.

namespace bug.ComptimeTypeofProgram;

using System;
using System.Reflection;

[Foo]
class Program
{
   static void Main ()
   {
      // Works fine
      //TypeCode typeCode = typeof(Program).[Friend]mTypeCode;
   }
}


struct FooAttribute : Attribute, IOnTypeInit
{
   void IOnTypeInit.OnTypeInit (Type type, Self* prev)
   {
      // Works fine
      //Type programType = typeof(Program);
      //TypeCode typeCode = programType.[Friend]mTypeCode;

      // Causes IDE to crash
      //TypeCode mTypeCode = typeof(Program).[Friend]mTypeCode;
      //TypeId mTypeId = typeof(Program).[Friend]mTypeId;
      //TypeFlags mTypeFlags = typeof(Program).[Friend]mTypeFlags;
      //int32 mSize = typeof(Program).[Friend]mSize;

      // Works fine
      //int32 mSize = typeof(Program).Size;
      //TypeId mTypeId = typeof(Program).TypeId;
      //TypeId mTypeId = typeof(Program).[Friend]TypeId;
   }
}

kallisto56 avatar Nov 03 '23 09:11 kallisto56