You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failure to consume returned value from method calls generates invalid code #338
StatementExpressions containing non-void method invocations generates code missing a Pop instruction.
For example, running the generated assembly from the cecilified code for the following snippet
M("X");voidM(strings)=>s.ToUpper();
results in runtime exception:
Unhandled exception. System.InvalidProgramException: Common Language Runtime detected an invalid program.
at Program.<<Main>$>g__M|0_0(String s)
at Program.<Main>$(String[] args)
[IL]: Error [ReturnVoid]: [/tmp/Foo/output.dll : Program::<<Main>$>g__M|0_0(string)][offset 0x00000006][found ref 'string'] Stack must be empty on return from a void function.
1 Error(s) Verifying /tmp/Foo/output.dll
indicating that a value from the stack was not consumed as expected.
Looking into the IL for function M() it become evident that it is missing a Pop instruction:
.methodassemblyhidebysigstaticvoid'<<Main>$>g__M|0_0' (
string s
) cilmanaged
{
// Method begins at RVA 0x2070// Header size: 12// Code size: 7 (0x7).maxstack1IL_0000: ldarg.0IL_0001: callvirtinstancestring[System.Runtime]System.String::ToUpper()
// MISSING POPIL_0006: ret
}
Activity
fix: generated assembly crash when expression bodied member fails to …
adrianoc commentedon Sep 27, 2026
fixed in vnext