mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow fallback function to return data.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
contract A {
|
||||
uint public x;
|
||||
fallback () external {
|
||||
if (x == 2) return;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// ()
|
||||
// x() -> 1
|
||||
// ()
|
||||
// x() -> 2
|
||||
// ()
|
||||
// x() -> 2
|
||||
// ()
|
||||
// x() -> 2
|
||||
@@ -0,0 +1,17 @@
|
||||
contract A {
|
||||
uint public x;
|
||||
fallback (bytes calldata _input) external returns (bytes memory) {
|
||||
x = _input.length;
|
||||
return "";
|
||||
}
|
||||
function f() public returns (bool, bytes memory) {
|
||||
(bool success, bytes memory retval) = address(this).call("abc");
|
||||
return (success, retval);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// f() -> 0x01, 0x40, 0x00
|
||||
// x() -> 3
|
||||
@@ -0,0 +1,16 @@
|
||||
contract A {
|
||||
bytes public x;
|
||||
fallback (bytes calldata _input) external returns (bytes memory) {
|
||||
x = _input;
|
||||
return "";
|
||||
}
|
||||
function f() public returns (bool, bytes memory) {
|
||||
(bool success, bytes memory retval) = address(this).call("abc");
|
||||
return (success, retval);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// f() -> 0x01, 0x40, 0x00
|
||||
// x() -> 0x20, 3, "abc"
|
||||
@@ -0,0 +1,14 @@
|
||||
contract A {
|
||||
fallback (bytes calldata _input) external returns (bytes memory) {
|
||||
return _input;
|
||||
}
|
||||
function f() public returns (bool, bytes memory) {
|
||||
(bool success, bytes memory retval) = address(this).call("abc");
|
||||
return (success, retval);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// f() -> 0x01, 0x40, 0x03, 0x6162630000000000000000000000000000000000000000000000000000000000
|
||||
Reference in New Issue
Block a user