diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-10-15 02:30:04 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2016-10-19 17:41:04 +0800 |
commit | 003359a0b651b78809c37a3b0b96d0a7ff7131d6 (patch) | |
tree | 19fb6bcb2f78fb390f3a839a7763ff803bd3a167 /libsolidity/ast | |
parent | 8317eb03838975e5ef5890e68d9d4bc6a4f009eb (diff) | |
download | dexon-solidity-003359a0b651b78809c37a3b0b96d0a7ff7131d6.tar dexon-solidity-003359a0b651b78809c37a3b0b96d0a7ff7131d6.tar.gz dexon-solidity-003359a0b651b78809c37a3b0b96d0a7ff7131d6.tar.bz2 dexon-solidity-003359a0b651b78809c37a3b0b96d0a7ff7131d6.tar.lz dexon-solidity-003359a0b651b78809c37a3b0b96d0a7ff7131d6.tar.xz dexon-solidity-003359a0b651b78809c37a3b0b96d0a7ff7131d6.tar.zst dexon-solidity-003359a0b651b78809c37a3b0b96d0a7ff7131d6.zip |
Ensure that bound functions cannot be defined without self type
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/Types.cpp | 3 | ||||
-rw-r--r-- | libsolidity/ast/Types.h | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index edb0fbe4..5d3d4f1a 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -2069,6 +2069,9 @@ TypePointer FunctionType::copyAndSetGasOrValue(bool _setGas, bool _setValue) con FunctionTypePointer FunctionType::asMemberFunction(bool _inLibrary, bool _bound) const { + if (_bound && m_parameterTypes.empty()) + return FunctionTypePointer(); + TypePointers parameterTypes; for (auto const& t: m_parameterTypes) { diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index f65d25fb..3f94d11a 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -872,7 +872,12 @@ public: m_isConstant(_isConstant), m_isPayable(_isPayable), m_declaration(_declaration) - {} + { + solAssert( + !m_bound || !m_parameterTypes.empty(), + "Attempted construction of bound function without self type" + ); + } TypePointers parameterTypes() const; std::vector<std::string> parameterNames() const; @@ -940,8 +945,9 @@ public: /// removed and the location of reference types is changed from CallData to Memory. /// This is needed if external functions are called on other contracts, as they cannot return /// dynamic values. + /// Returns empty shared pointer on a failure. Namely, if a bound function has no parameters. /// @param _inLibrary if true, uses DelegateCall as location. - /// @param _bound if true, the argumenst are placed as `arg1.functionName(arg2, ..., argn)`. + /// @param _bound if true, the arguments are placed as `arg1.functionName(arg2, ..., argn)`. FunctionTypePointer asMemberFunction(bool _inLibrary, bool _bound = false) const; private: |