aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-03-04 01:44:35 +0800
committerchriseth <c@ethdev.com>2017-03-06 21:27:18 +0800
commitc126edc6ea1c7af4d0a43e9d36a958f157d9b35c (patch)
treeaefefbd256e31078333fa404e30caf976ab1ea77
parent960b5fa032b0b948bb44876615e3e8c53a043325 (diff)
downloaddexon-solidity-c126edc6ea1c7af4d0a43e9d36a958f157d9b35c.tar.gz
dexon-solidity-c126edc6ea1c7af4d0a43e9d36a958f157d9b35c.tar.zst
dexon-solidity-c126edc6ea1c7af4d0a43e9d36a958f157d9b35c.zip
Disallow uninitialized mapping variables.
-rw-r--r--libsolidity/analysis/TypeChecker.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index ff55ef1f..404ddf77 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -730,13 +730,16 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
if (auto ref = dynamic_cast<ReferenceType const*>(type(varDecl).get()))
{
if (ref->dataStoredIn(DataLocation::Storage))
- {
warning(
varDecl.location(),
"Uninitialized storage pointer. Did you mean '<type> memory " + varDecl.name() + "'?"
);
- }
}
+ else if (dynamic_cast<MappingType const*>(type(varDecl).get()))
+ typeError(
+ varDecl.location(),
+ "Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable."
+ );
varDecl.accept(*this);
return false;
}