title: Help with InvalidProgramException (Invalid IL Code?)
body: <p>I'm getting a weird bug in an assembly exported with <code>System.Reflection.Emit</code> with mono.
  When attempting to run my assembly, I get an <code>InvalidProgramException</code>: Invalid IL code.</p>
  
  <p><code>monodis</code> gives me this CIL result(which is consistent with what I export with Emit):</p>
  
  <pre><code>.method public static hidebysig 
         default void f_main (class [Pine.Core]Pine.Core.Function A_0, class [Pine.Core]Pine.Core.ValueList A_1)  cil managed 
  {
      // Method begins at RVA 0x2144
      // Code size 26 (0x1a)
      .maxstack 4
      .locals init (
          class [Pine.Core]Pine.Core.Function V_0,
          class [Pine.Core]Pine.Core.IScope   V_1,
          class [Pine.Core]Pine.Core.ValueList    V_2,
          class [Pine.Core]Pine.Core.IScope   V_3)
      IL_0000:  ldarg.0 
      IL_0001:  stloc.0 
      IL_0002:  ldarg.1 
      IL_0003:  stloc.2 
      IL_0004:  ldloc.0 
      IL_0005:  ldftn instance class [Pine.Core]Pine.Core.IScope class [Pine.Core]Pine.Core.Function::get_Scope()
      IL_000b:  stloc.1 
      IL_000c:  ldloc.1 
      IL_000d:  newobj instance void class [Pine.Core]Pine.Core.BlockScope::'.ctor'(class [Pine.Core]Pine.Core.IScope)
      IL_0012:  stloc.3 
      IL_0013:  ldloc.2 
      IL_0014:  call instance void class [Pine.Core]Pine.Core.ValueList::Clear()
      IL_0019:  ret 
  } // end of method PineType::f_main
  </code></pre>
  
  <p>The error happens in <code>IL_000b: stloc.1</code>
  I have no idea why.</p>
  
  <p>I tried to replace the <code>stloc.1</code> by a pop instruction. When I do that the error happens in <code>IL_0019: ret</code></p>
  
  <p>I really don't know why this is behaving like this. Any ideas?</p>
  
  <p>Additional Information:</p>
  
  <ul>
  <li><code>IScope</code> is an interface</li>
  <li><code>BlockScope</code> implements <code>IScope</code></li>
  <li><code>Function</code> has a <code>public IScope Scope { get; private set; }</code></li>
  <li>I get this error with both Mono 2.6.7(Boehm, AMD64) and Mono 2.8(Boehm with typed GC and Parallel Mark, AMD64)</li>
  </ul>