aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-03-06 22:05:58 +0800
committerGitHub <noreply@github.com>2017-03-06 22:05:58 +0800
commit2fcccb97d393cfc6eb5120029d1ec2d6526c0bd0 (patch)
treec90805051b690b04c36bb0db87f86998f55c0aa3 /test/libsolidity
parent573b885337aca75a025c08eea80bb109041e669e (diff)
parentc126edc6ea1c7af4d0a43e9d36a958f157d9b35c (diff)
downloaddexon-solidity-2fcccb97d393cfc6eb5120029d1ec2d6526c0bd0.tar.gz
dexon-solidity-2fcccb97d393cfc6eb5120029d1ec2d6526c0bd0.tar.zst
dexon-solidity-2fcccb97d393cfc6eb5120029d1ec2d6526c0bd0.zip
Merge pull request #1737 from ethereum/localmappings
Disallow uninitialized mapping variables.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 3b137572..02d81d14 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2501,6 +2501,30 @@ BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable)
CHECK_ERROR(sourceCode, TypeError, "");
}
+BOOST_AUTO_TEST_CASE(uninitialized_mapping_variable)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() {
+ mapping(uint => uint) x;
+ }
+ }
+ )";
+ CHECK_ERROR(sourceCode, TypeError, "Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable");
+}
+
+BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() {
+ mapping(uint => uint)[] x;
+ }
+ }
+ )";
+ CHECK_WARNING(sourceCode, "Uninitialized storage pointer");
+}
+
BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers)
{
char const* sourceCode = R"(