aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp24
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp81
2 files changed, 105 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 73dd7d22..f3d0fde3 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -10051,6 +10051,30 @@ BOOST_AUTO_TEST_CASE(delegatecall_return_value)
BOOST_CHECK(callContractFunction("get_delegated()") == encodeArgs(u256(1)));
}
+BOOST_AUTO_TEST_CASE(function_types_sig)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (bytes4) {
+ return this.f.sig;
+ }
+ function g() returns (bytes4) {
+ function () external returns (bytes4) fun = this.f;
+ return fun.sig;
+ }
+ function h() returns (bytes4) {
+ function () external returns (bytes4) fun = this.f;
+ var funvar = fun;
+ return funvar.sig;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == fromHex("0x26121ff0"));
+ BOOST_CHECK(callContractFunction("g()") == fromHex("0x26121ff0"));
+ BOOST_CHECK(callContractFunction("h()") == fromHex("0x26121ff0"));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 1fbc55a2..6576634f 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -6285,6 +6285,87 @@ BOOST_AUTO_TEST_CASE(modifiers_access_storage_pointer)
CHECK_SUCCESS_NO_WARNINGS(text);
}
+BOOST_AUTO_TEST_CASE(function_types_sig)
+{
+ char const* text = R"(
+ contract C {
+ function f() returns (bytes4) {
+ return f.sig;
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Member \"sig\" not found");
+ text = R"(
+ contract C {
+ function g() internal {
+ }
+ function f() returns (bytes4) {
+ return g.sig;
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Member \"sig\" not found");
+ text = R"(
+ contract C {
+ function f() returns (bytes4) {
+ function () g;
+ return g.sig;
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Member \"sig\" not found");
+ text = R"(
+ contract C {
+ function f() returns (bytes4) {
+ return this.f.sig;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ text = R"(
+ contract C {
+ function f() external returns (bytes4) {
+ return this.f.sig;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ text = R"(
+ contract C {
+ function h() external {
+ }
+ function f() external returns (bytes4) {
+ var g = this.h;
+ return g.sig;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ text = R"(
+ contract C {
+ function h() external {
+ }
+ function f() external returns (bytes4) {
+ function () external g = this.h;
+ return g.sig;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ text = R"(
+ contract C {
+ function h() external {
+ }
+ function f() external returns (bytes4) {
+ function () external g = this.h;
+ var i = g;
+ return i.sig;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+}
+
BOOST_AUTO_TEST_CASE(using_this_in_constructor)
{
char const* text = R"(