Move mapping key checks to ReferencesResolver and make them fatal.

This commit is contained in:
Daniel Kirchner
2020-02-11 13:35:23 +01:00
parent 5214cb0e76
commit 9c3151748e
5 changed files with 35 additions and 30 deletions
-24
View File
@@ -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