Fix documentation about revert data.

This commit is contained in:
chriseth 2020-12-03 18:02:51 +01:00
parent 27e44b85e3
commit 61fd76cb27
2 changed files with 22 additions and 3 deletions

View File

@ -896,12 +896,11 @@ the ``dup`` and ``swap`` instructions as well as ``jump`` instructions, labels a
.. note::
The ``call*`` instructions use the ``out`` and ``outsize`` parameters to define an area in memory where
the return data is placed. This area is written to depending on how many bytes the called contract returns.
the return or failure data is placed. This area is written to depending on how many bytes the called contract returns.
If it returns more data, only the first ``outsize`` bytes are written. You can access the rest of the data
using the ``returndatacopy`` opcode. If it returns less data, then the remaining bytes are not touched at all.
You need to use the ``returndatasize`` opcode to check which part of this memory area contains the return data.
The remaining bytes will retain their values as of before the call. If the call fails (it returns ``0``),
nothing is written to that area, but you can still retrieve the failure data using ``returndatacopy``.
The remaining bytes will retain their values as of before the call.
In some internal dialects, there are additional functions:

View File

@ -0,0 +1,20 @@
contract C {
fallback() external {
revert("abc");
}
function f() public returns (uint s, uint r) {
address x = address(this);
assembly {
mstore(0, 7)
s := call(sub(0, 1), x, 0, 0, 0, 0, 32)
r := mload(0)
}
}
}
// ====
// compileViaYul: also
// EVMVersion: >=byzantium
// ----
// f() -> 0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000