I am working on a compiler using System.Reflection.Emit , and I am getting JIT constraint errors that I cannot understand. The problem arises in my implementation of function descriptors. That is, generating code for
function foo() { } f = foo; f();
Due to parameters independent of me, the language is dynamically entered, so I cannot know how many arguments f will be expected at compile time. To counter this, instead of emitting a Ldftn for foo , I generate a new λfoo method that takes an array of arguments given in the call expression and λfoo the eval stack for foo . Is this allowed in the CLR?
Now I get the error message "JIT encountered an internal constraint" (or "CLR found an invalid program" if I save the assembly and run it instead of recalling it from memory) with a stack showing it happening in λfoo . This is the IL that I generate.
.method private instance class [MylibInterop]MylibInterop.MylibValue 'λfoo'(class [MylibInterop]MylibInterop.MylibValue[] A_1) cil managed {
cthom06
source share