From 19e9e8b550ecbfb019204dde50a061412fa18184 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 18 Nov 2020 20:09:39 +0100 Subject: [PATCH] Some more tests. --- .../fallback/fallback_override.sol | 19 ++++++++++++++++ .../fallback/fallback_override2.sol | 18 +++++++++++++++ .../fallback/fallback_override_multi.sol | 22 +++++++++++++++++++ .../fallback/fallback_wrong_data_location.sol | 13 +++++++++++ .../fallback/inheritance_multi_base.sol | 20 +++++++++++++++++ 5 files changed, 92 insertions(+) create mode 100644 test/libsolidity/semanticTests/fallback/fallback_override.sol create mode 100644 test/libsolidity/semanticTests/fallback/fallback_override2.sol create mode 100644 test/libsolidity/semanticTests/fallback/fallback_override_multi.sol create mode 100644 test/libsolidity/syntaxTests/fallback/fallback_wrong_data_location.sol create mode 100644 test/libsolidity/syntaxTests/fallback/inheritance_multi_base.sol diff --git a/test/libsolidity/semanticTests/fallback/fallback_override.sol b/test/libsolidity/semanticTests/fallback/fallback_override.sol new file mode 100644 index 000000000..c1099e151 --- /dev/null +++ b/test/libsolidity/semanticTests/fallback/fallback_override.sol @@ -0,0 +1,19 @@ +contract A { + fallback (bytes calldata _input) virtual external returns (bytes memory) { + return _input; + } +} +contract B is A { + fallback (bytes calldata _input) override external returns (bytes memory) { + return "xyz"; + } + function f() public returns (bool, bytes memory) { + (bool success, bytes memory retval) = address(this).call("abc"); + return (success, retval); + } +} +// ==== +// EVMVersion: >=byzantium +// compileViaYul: also +// ---- +// f() -> 0x01, 0x40, 0x03, 0x78797a0000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/fallback/fallback_override2.sol b/test/libsolidity/semanticTests/fallback/fallback_override2.sol new file mode 100644 index 000000000..e92163476 --- /dev/null +++ b/test/libsolidity/semanticTests/fallback/fallback_override2.sol @@ -0,0 +1,18 @@ +contract A { + fallback (bytes calldata _input) virtual external returns (bytes memory) { + return _input; + } +} +contract B is A { + fallback () override external { + } + function f() public returns (bool, bytes memory) { + (bool success, bytes memory retval) = address(this).call("abc"); + return (success, retval); + } +} +// ==== +// EVMVersion: >=byzantium +// compileViaYul: also +// ---- +// f() -> 1, 0x40, 0x00 diff --git a/test/libsolidity/semanticTests/fallback/fallback_override_multi.sol b/test/libsolidity/semanticTests/fallback/fallback_override_multi.sol new file mode 100644 index 000000000..1e2b3a630 --- /dev/null +++ b/test/libsolidity/semanticTests/fallback/fallback_override_multi.sol @@ -0,0 +1,22 @@ +contract A { + fallback (bytes calldata _input) virtual external returns (bytes memory) { + return _input; + } +} +contract B { + fallback (bytes calldata _input) virtual external returns (bytes memory) { + return "xyz"; + } +} +contract C is B, A { + fallback () external override (B, A) {} + function f() public returns (bool, bytes memory) { + (bool success, bytes memory retval) = address(this).call("abc"); + return (success, retval); + } +} +// ==== +// EVMVersion: >=byzantium +// compileViaYul: also +// ---- +// f() -> 0x01, 0x40, 0x00 diff --git a/test/libsolidity/syntaxTests/fallback/fallback_wrong_data_location.sol b/test/libsolidity/syntaxTests/fallback/fallback_wrong_data_location.sol new file mode 100644 index 000000000..5ddefdf3d --- /dev/null +++ b/test/libsolidity/syntaxTests/fallback/fallback_wrong_data_location.sol @@ -0,0 +1,13 @@ +contract D { + fallback(bytes memory) external returns (bytes memory) {} +} +contract E { + fallback(bytes memory) external returns (bytes calldata) {} +} +contract F { + fallback(bytes calldata) external returns (bytes calldata) {} +} +// ---- +// TypeError 5570: (57-71): Fallback function either has to have the signature "fallback()" or "fallback(bytes calldata) returns (bytes memory)". +// TypeError 5570: (134-150): Fallback function either has to have the signature "fallback()" or "fallback(bytes calldata) returns (bytes memory)". +// TypeError 5570: (215-231): Fallback function either has to have the signature "fallback()" or "fallback(bytes calldata) returns (bytes memory)". diff --git a/test/libsolidity/syntaxTests/fallback/inheritance_multi_base.sol b/test/libsolidity/syntaxTests/fallback/inheritance_multi_base.sol new file mode 100644 index 000000000..330ff156c --- /dev/null +++ b/test/libsolidity/syntaxTests/fallback/inheritance_multi_base.sol @@ -0,0 +1,20 @@ +contract A { + fallback (bytes calldata _input) external returns (bytes memory) { + return _input; + } +} +contract B { + fallback (bytes calldata _input) external returns (bytes memory) { + return "xyz"; + } +} +contract C is B, A { + function f() public returns (bool, bytes memory) { + (bool success, bytes memory retval) = address(this).call("abc"); + return (success, retval); + } +} +// ==== +// EVMVersion: >=byzantium +// ---- +// TypeError 6480: (229-420): Derived contract must override function "". Two or more base classes define function with same name and parameter types.