mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move hash collisions checks.
This commit is contained in:
parent
6d1644e55c
commit
4f992298c6
@ -43,6 +43,7 @@ bool ContractLevelChecker::check(ContractDefinition const& _contract)
|
||||
checkConstructor(_contract);
|
||||
checkFallbackFunction(_contract);
|
||||
checkExternalTypeClashes(_contract);
|
||||
checkHashCollisions(_contract);
|
||||
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
}
|
||||
@ -420,3 +421,18 @@ void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _c
|
||||
"Function overload clash during conversion to external types for arguments."
|
||||
);
|
||||
}
|
||||
|
||||
void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contract)
|
||||
{
|
||||
set<FixedHash<4>> hashes;
|
||||
for (auto const& it: _contract.interfaceFunctionList())
|
||||
{
|
||||
FixedHash<4> const& hash = it.first;
|
||||
if (hashes.count(hash))
|
||||
m_errorReporter.typeError(
|
||||
_contract.location(),
|
||||
string("Function signature hash collision for ") + it.second->externalSignature()
|
||||
);
|
||||
hashes.insert(hash);
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,8 @@ private:
|
||||
/// Checks that different functions with external visibility end up having different
|
||||
/// external argument types (i.e. different signature).
|
||||
void checkExternalTypeClashes(ContractDefinition const& _contract);
|
||||
/// Checks for hash collisions in external function signatures.
|
||||
void checkHashCollisions(ContractDefinition const& _contract);
|
||||
|
||||
langutil::ErrorReporter& m_errorReporter;
|
||||
};
|
||||
|
@ -93,19 +93,6 @@ bool TypeChecker::visit(ContractDefinition const& _contract)
|
||||
for (auto const& n: _contract.subNodes())
|
||||
n->accept(*this);
|
||||
|
||||
// check for hash collisions in function signatures
|
||||
set<FixedHash<4>> hashes;
|
||||
for (auto const& it: _contract.interfaceFunctionList())
|
||||
{
|
||||
FixedHash<4> const& hash = it.first;
|
||||
if (hashes.count(hash))
|
||||
m_errorReporter.typeError(
|
||||
_contract.location(),
|
||||
string("Function signature hash collision for ") + it.second->externalSignature()
|
||||
);
|
||||
hashes.insert(hash);
|
||||
}
|
||||
|
||||
if (_contract.isLibrary())
|
||||
checkLibraryRequirements(_contract);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user