diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-09-06 09:50:47 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-09-06 23:31:29 +0800 |
commit | 319ec340934480eeb044c8c4e35e0471998bd733 (patch) | |
tree | 2950e0e326ceb853340bd94d80fee32ddb5e53d5 /libsolidity/analysis | |
parent | 453490cb61002622fadddf5838d29a8483f364ae (diff) | |
download | dexon-solidity-319ec340934480eeb044c8c4e35e0471998bd733.tar.gz dexon-solidity-319ec340934480eeb044c8c4e35e0471998bd733.tar.zst dexon-solidity-319ec340934480eeb044c8c4e35e0471998bd733.zip |
Reject constant constructors
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index fc1b1f59..41a5d39e 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -75,8 +75,12 @@ bool TypeChecker::visit(ContractDefinition const& _contract) checkContractAbstractConstructors(_contract); FunctionDefinition const* function = _contract.constructor(); - if (function && !function->returnParameters().empty()) - typeError(function->returnParameterList()->location(), "Non-empty \"returns\" directive for constructor."); + if (function) { + if (!function->returnParameters().empty()) + typeError(function->returnParameterList()->location(), "Non-empty \"returns\" directive for constructor."); + if (function->isDeclaredConst()) + typeError(function->location(), "Constructor cannot be defined as constant."); + } FunctionDefinition const* fallbackFunction = nullptr; for (FunctionDefinition const* function: _contract.definedFunctions()) |