aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-08-03 22:22:03 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-08-03 22:22:03 +0800
commit1e4b5886d61328d951fc03dc88cfc3dd722a3a00 (patch)
tree15196aa2588e31f6d8bf135b9b4a7a7acb6263a7 /libsolidity
parentc0a169ca90b780d102442aca98d1c510dac47464 (diff)
downloaddexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.tar.gz
dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.tar.zst
dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.zip
Allow assignments to local variables of mapping types.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index f9604794..1d30881c 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1332,7 +1332,15 @@ void TypeChecker::checkExpressionAssignment(Type const& _type, Expression const&
checkExpressionAssignment(_type, *tupleExpression->components().front());
}
else if (_type.category() == Type::Category::Mapping)
- m_errorReporter.typeError(_expression.location(), "Mappings cannot be assigned to.");
+ {
+ bool isLocalOrReturn = false;
+ if (auto const* identifier = dynamic_cast<Identifier const*>(&_expression))
+ if (auto const *variableDeclaration = dynamic_cast<VariableDeclaration const*>(identifier->annotation().referencedDeclaration))
+ if (variableDeclaration->isLocalOrReturn())
+ isLocalOrReturn = true;
+ if (!isLocalOrReturn)
+ m_errorReporter.typeError(_expression.location(), "Mappings cannot be assigned to.");
+ }
}
bool TypeChecker::visit(Assignment const& _assignment)