Merge pull request #8977 from ethereum/mapping-type-error

Error when Mapping type in (non-local) storage is assigned to
This commit is contained in:
chriseth
2020-05-19 16:52:54 +02:00
committed by GitHub
5 changed files with 55 additions and 1 deletions
+9 -1
View File
@@ -453,7 +453,15 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
if (contractType->contractDefinition().isLibrary())
m_errorReporter.typeError(1273_error, _variable.location(), "The type of a variable cannot be a library.");
if (_variable.value())
expectType(*_variable.value(), *varType);
{
if (_variable.isStateVariable() && dynamic_cast<MappingType const*>(varType))
{
m_errorReporter.typeError(6280_error, _variable.location(), "Mappings cannot be assigned to.");
_variable.value()->accept(*this);
}
else
expectType(*_variable.value(), *varType);
}
if (_variable.isConstant())
{
if (!_variable.type()->isValueType())