Closed
Description
According to ECMA 335 (III.4.31) throw opcode pops exception object from stack, than discards any remaining values from stack leaving it empty. However, OpCodes.Throw
field tells that stack pop behaviour is Popref
, which suggests that it pops only one value from stack (possibly leaving it non-empty). Running PEVerify on assembly with following method:
.method public hidebysig
instance int32 Method (
object 'value'
) cil managed
{
// Method begins at RVA 0x2050
// Code size 31 (0x1f)
.maxstack 8
IL_0000: ldarg.1
IL_0001: isinst [mscorlib]System.String
IL_0006: dup
IL_0007: brtrue.s IL_0019
IL_0009: ldstr "Not a string"
IL_000e: ldstr "value"
IL_0013: newobj instance void [mscorlib]System.ArgumentException::.ctor(string, string)
IL_0018: throw
IL_0019: callvirt instance int32 [mscorlib]System.String::get_Length()
IL_001e: ret
} // end of method Class1::Method
gives no error, which conforms to ECMA docs.
So, it would be more consistent for throw
opcode to define stack pop as Varpop
rather than Popref