mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move mapping key checks to ReferencesResolver and make them fatal.
This commit is contained in:
@@ -2876,30 +2876,6 @@ void TypeChecker::endVisit(Literal const& _literal)
|
||||
_literal.annotation().isPure = true;
|
||||
}
|
||||
|
||||
bool TypeChecker::visit(Mapping const& _mapping)
|
||||
{
|
||||
if (auto const* keyType = dynamic_cast<UserDefinedTypeName const*>(&_mapping.keyType()))
|
||||
{
|
||||
if (auto const* contractType = dynamic_cast<ContractType const*>(keyType->annotation().type))
|
||||
{
|
||||
if (contractType->contractDefinition().isLibrary())
|
||||
m_errorReporter.typeError(
|
||||
keyType->location(),
|
||||
"Library types cannot be used as mapping keys."
|
||||
);
|
||||
}
|
||||
else if (keyType->annotation().type->category() != Type::Category::Enum)
|
||||
m_errorReporter.typeError(
|
||||
keyType->location(),
|
||||
"Only elementary types, contract types or enums are allowed as mapping keys."
|
||||
);
|
||||
}
|
||||
else
|
||||
solAssert(dynamic_cast<ElementaryTypeName const*>(&_mapping.keyType()), "");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TypeChecker::contractDependenciesAreCyclic(
|
||||
ContractDefinition const& _contract,
|
||||
std::set<ContractDefinition const*> const& _seenContracts
|
||||
|
||||
Reference in New Issue
Block a user