aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-08 21:53:44 +0800
committerGitHub <noreply@github.com>2017-08-08 21:53:44 +0800
commit41e724360fbba4aa434d88bd0dfcf1a3ec7ce695 (patch)
tree5a908888f2d0380653879f6673907e4ee6eca060
parentbea37e5682d83b11988e51a16848319a59c39dd3 (diff)
parent8df89c5d5b349bbf366eaf410b59a9c85c8832ad (diff)
downloaddexon-solidity-41e724360fbba4aa434d88bd0dfcf1a3ec7ce695.tar.gz
dexon-solidity-41e724360fbba4aa434d88bd0dfcf1a3ec7ce695.tar.zst
dexon-solidity-41e724360fbba4aa434d88bd0dfcf1a3ec7ce695.zip
Merge pull request #2697 from ethereum/unimplemented-inlined-library
Raise error when using unimplemented internal library functions.
-rw-r--r--Changelog.md3
-rw-r--r--libsolidity/analysis/TypeChecker.cpp2
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp22
3 files changed, 26 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md
index 8590f7b9..3484b369 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -7,8 +7,9 @@ Bugfixes:
* Code Generator: ``.delegatecall()`` should always return execution outcome.
* Code Generator: Provide "new account gas" for low-level ``callcode`` and ``delegatecall``.
* Type Checker: Constructors must be implemented if declared.
- * Type Checker: Do not mark overloaded functions as shadowing other functions.
* Type Checker: Disallow the ``.gas()`` modifier on ``ecrecover``, ``sha256`` and ``ripemd160``.
+ * Type Checker: Do not mark overloaded functions as shadowing other functions.
+ * Type Checker: Internal library functions must be implemented if declared.
### 0.4.14 (2017-07-31)
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index a9f5b931..6852c13d 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -518,6 +518,8 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
_function.body().accept(*this);
else if (_function.isConstructor())
m_errorReporter.typeError(_function.location(), "Constructor must be implemented if declared.");
+ else if (isLibraryFunction && _function.visibility() <= FunctionDefinition::Visibility::Internal)
+ m_errorReporter.typeError(_function.location(), "Internal library function must be implemented if declared.");
return false;
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index aaf1a449..2fbc6ac8 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -6536,6 +6536,28 @@ BOOST_AUTO_TEST_CASE(constructor_without_implementation)
CHECK_ERROR(text, TypeError, "Constructor must be implemented if declared.");
}
+BOOST_AUTO_TEST_CASE(library_function_without_implementation)
+{
+ char const* text = R"(
+ library L {
+ function f();
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ text = R"(
+ library L {
+ function f() internal;
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Internal library function must be implemented if declared.");
+ text = R"(
+ library L {
+ function f() private;
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Internal library function must be implemented if declared.");
+}
+
BOOST_AUTO_TEST_SUITE_END()
}