aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/SolidityParser.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-04-21 21:58:06 +0800
committerchriseth <c@ethdev.com>2015-04-21 21:58:06 +0800
commite65b9825d6e40d4d949b3b37246d03dde608d197 (patch)
treeaa925e580587cc030fe3f15f6c432786b465eb43 /libsolidity/SolidityParser.cpp
parent02121683f5f43cb3c547521fb4a2642f637f246f (diff)
parentddbaa99056b10052f0539a0afdffab53cc941dab (diff)
downloaddexon-solidity-e65b9825d6e40d4d949b3b37246d03dde608d197.tar.gz
dexon-solidity-e65b9825d6e40d4d949b3b37246d03dde608d197.tar.zst
dexon-solidity-e65b9825d6e40d4d949b3b37246d03dde608d197.zip
Merge pull request #1634 from chriseth/sol_overloadingFunctions
Function overloading.
Diffstat (limited to 'libsolidity/SolidityParser.cpp')
-rw-r--r--libsolidity/SolidityParser.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/libsolidity/SolidityParser.cpp b/libsolidity/SolidityParser.cpp
index ad17c40a..cad0e1f2 100644
--- a/libsolidity/SolidityParser.cpp
+++ b/libsolidity/SolidityParser.cpp
@@ -134,6 +134,31 @@ BOOST_AUTO_TEST_CASE(missing_argument_in_named_args)
BOOST_CHECK_THROW(parseText(text), ParserError);
}
+BOOST_AUTO_TEST_CASE(two_exact_functions)
+{
+ char const* text = R"(
+ contract test {
+ function fun(uint a) returns(uint r) { return a; }
+ function fun(uint a) returns(uint r) { return a; }
+ }
+ )";
+ // with support of overloaded functions, during parsing,
+ // we can't determine whether they match exactly, however
+ // it will throw DeclarationError in following stage.
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
+BOOST_AUTO_TEST_CASE(overloaded_functions)
+{
+ char const* text = R"(
+ contract test {
+ function fun(uint a) returns(uint r) { return a; }
+ function fun(uint a, uint b) returns(uint r) { return a + b; }
+ }
+ )";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
BOOST_AUTO_TEST_CASE(function_natspec_documentation)
{
ASTPointer<ContractDefinition> contract;