aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-11-28 05:24:00 +0800
committerchriseth <c@ethdev.com>2015-11-29 07:16:07 +0800
commitf9e52c9db1ef23000f5721a462aba3fa8d681749 (patch)
treed1b77769961618d027c794131949efe021fa4b49 /test
parent93b3237c6ae526d3ff5aa0d23d48319cf705baee (diff)
downloaddexon-solidity-f9e52c9db1ef23000f5721a462aba3fa8d681749.tar.gz
dexon-solidity-f9e52c9db1ef23000f5721a462aba3fa8d681749.tar.zst
dexon-solidity-f9e52c9db1ef23000f5721a462aba3fa8d681749.zip
Also check the object type for bound functions.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 19ee9440..73a9b660 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2628,6 +2628,51 @@ BOOST_AUTO_TEST_CASE(using_for_by_name)
BOOST_CHECK(success(text));
}
+BOOST_AUTO_TEST_CASE(using_for_mismatch)
+{
+ char const* text = R"(
+ library D { function double(bytes32 self) returns (uint) { return 2; } }
+ contract C {
+ using D for uint;
+ function f(uint a) returns (uint) {
+ return a.double();
+ }
+ }
+ )";
+ BOOST_CHECK(expectError(text) == Error::Type::TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(using_for_not_used)
+{
+ // This is an error because the function is only bound to uint.
+ // Had it been bound to *, it would have worked.
+ char const* text = R"(
+ library D { function double(uint self) returns (uint) { return 2; } }
+ contract C {
+ using D for uint;
+ function f(uint16 a) returns (uint) {
+ return a.double();
+ }
+ }
+ )";
+ BOOST_CHECK(expectError(text) == Error::Type::TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch)
+{
+ // Bound to a, but self type does not match.
+ char const* text = R"(
+ library D { function double(bytes32 self) returns (uint) { return 2; } }
+ contract C {
+ using D for *;
+ function f(uint a) returns (uint) {
+ return a.double();
+ }
+ }
+ )";
+ BOOST_CHECK(expectError(text) == Error::Type::TypeError);
+}
+
BOOST_AUTO_TEST_CASE(bound_function_in_var)
{
char const* text = R"(