Format | Assembly Format | Description |
---|---|---|
2A | ret |
Return from method, possibly with a value. |
retVal on callee evaluation stack (not always present) → …, retVal on caller evaluation stack (not always present)
Return from the current method. The return type, if any, of the current method determines the type of value to be fetched from the top of the stack and copied onto the stack of the method that called the current method. The evaluation stack for the current method shall be empty except for the value to be returned.
The ret
instruction cannot be used to transfer control out of a try, filter, catch, or finally block. From within a try or catch, use the leave
instruction with a destination of a ret
instruction that is outside all enclosing exception blocks. Because the filter and finally blocks are logically part of exception handling, not the method in which their code is embedded, correctly generated CIL does not perform a method return from within a filter or finally. See Partition I.
None.
Correct CIL obeys the control constraints describe above.
Verification requires that the type of retVal is verifier-assignable-to the declared return type of the current method. [Note: as the operation is stack-to-stack no representation changes occur. end note]