diff options
author | chriseth <c@ethdev.com> | 2017-03-04 01:44:35 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-03-06 21:27:18 +0800 |
commit | c126edc6ea1c7af4d0a43e9d36a958f157d9b35c (patch) | |
tree | aefefbd256e31078333fa404e30caf976ab1ea77 | |
parent | 960b5fa032b0b948bb44876615e3e8c53a043325 (diff) | |
download | dexon-solidity-c126edc6ea1c7af4d0a43e9d36a958f157d9b35c.tar.gz dexon-solidity-c126edc6ea1c7af4d0a43e9d36a958f157d9b35c.tar.zst dexon-solidity-c126edc6ea1c7af4d0a43e9d36a958f157d9b35c.zip |
Disallow uninitialized mapping variables.
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 7 |
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; } |