From ff7e45f41799ccc399ff0e4515d0cfa0dcfe00cd Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 8 Jul 2020 18:23:44 +0100 Subject: [PATCH] Add test cases for assigning builtins/bound functions to function types --- .../syntaxTests/functionTypes/assign_bound.sol | 15 +++++++++++++++ .../syntaxTests/functionTypes/assign_builtin.sol | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100644 test/libsolidity/syntaxTests/functionTypes/assign_bound.sol create mode 100644 test/libsolidity/syntaxTests/functionTypes/assign_builtin.sol diff --git a/test/libsolidity/syntaxTests/functionTypes/assign_bound.sol b/test/libsolidity/syntaxTests/functionTypes/assign_bound.sol new file mode 100644 index 000000000..eac080e53 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/assign_bound.sol @@ -0,0 +1,15 @@ +library L { + function foo(uint256 a, uint256 b) internal pure returns (uint256) { + return a + b; + } +} +contract C { + using L for uint256; + + function bar() public { + uint256 x; + function (uint256, uint256) internal pure returns (uint256) ptr = x.foo; + } +} +// ---- +// TypeError 9574: (209-280): Type function (uint256,uint256) pure returns (uint256) is not implicitly convertible to expected type function (uint256,uint256) pure returns (uint256). diff --git a/test/libsolidity/syntaxTests/functionTypes/assign_builtin.sol b/test/libsolidity/syntaxTests/functionTypes/assign_builtin.sol new file mode 100644 index 000000000..0fa43aa76 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/assign_builtin.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + function (uint) view returns (bytes32) _blockhash = blockhash; + } +} +// ---- +// TypeError 9574: (42-103): Type function (uint256) view returns (bytes32) is not implicitly convertible to expected type function (uint256) view returns (bytes32).