Skip to content

[Mono] aot build error when a delegate return struct by reference #67734

@gemSender

Description

@gemSender

code:

using System;
namespace Test
{
  public struct Handle
  {
    public long value;
  }
  public class TestClass
  {
    public Handle h1;
    public Handle h2;
    public Handle h3;
  }
  public class Program
  {
    public delegate ref Handle HandleGetter(TestClass obj);
    public static void MainEntry(string[] args)
    {
       TestClass obj = new TestClass();
       HandleGetter g1 = (o) => ref o.h1;
       HandleGetter g2 = (o) => ref o.h2;
       HandleGetter g3 = (o) => ref o.h3;
       ref var h1 = ref g1(obj); 
       ref var h2 = ref g2(obj); 
       ref var h3 = ref g3(obj);
       h1.value = 1;
       h2.value = 2;
       h3.value = 3;
       Console.WriteLine(obj.h1.value + obj.h2.value + obj.h3.value); 
    }
  }
}

compile error :
Unable to compile method '(wrapper delegate-invoke) Test.Handle& :invoke_Handle&_TestClass (Test.TestClass)' due to: 'Invalid IL code in (wrapper delegate-invoke) :invoke_Handle&_TestClass (Test.TestClass): IL_0079: stloc.s 5

assembly: type: member:(null)'.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions