aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-08-26 05:53:03 +0800
committerchriseth <c@ethdev.com>2016-08-30 21:31:50 +0800
commit4bfe09897e3346038b95eb10d74dd0d8c9a8f40e (patch)
tree795ec36c69ef1b946d2e34ec39cad82c174b1d0b /libsolidity
parentcf974fd103dbb56313eee40ce9ffe4d03d6c1b04 (diff)
downloaddexon-solidity-4bfe09897e3346038b95eb10d74dd0d8c9a8f40e.tar.gz
dexon-solidity-4bfe09897e3346038b95eb10d74dd0d8c9a8f40e.tar.zst
dexon-solidity-4bfe09897e3346038b95eb10d74dd0d8c9a8f40e.zip
Make fallback function throw by default.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp2
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp5
2 files changed, 3 insertions, 4 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 235fcabd..bc03da01 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -92,6 +92,8 @@ bool TypeChecker::visit(ContractDefinition const& _contract)
else
{
fallbackFunction = function;
+ if (_contract.isLibrary())
+ typeError(fallbackFunction->location(), "Libraries cannot have fallback functions.");
if (!fallbackFunction->parameters().empty())
typeError(fallbackFunction->parameterList().location(), "Fallback function cannot take parameters.");
if (!fallbackFunction->returnParameters().empty())
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 715852be..9d77ccdc 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -247,11 +247,8 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
m_context << returnTag;
appendReturnValuePacker(FunctionType(*fallback).returnParameterTypes(), _contract.isLibrary());
}
- else if (_contract.isLibrary())
- // Reject invalid library calls and ether sent to a library.
- m_context.appendJumpTo(m_context.errorTag());
else
- m_context << Instruction::STOP; // function not found
+ m_context.appendJumpTo(m_context.errorTag());
for (auto const& it: interfaceFunctions)
{