aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-12-02 00:32:10 +0800
committerChristian <c@ethdev.com>2014-12-02 00:33:21 +0800
commit5cecf5699b4e5fa25770ebab350750731a0d430d (patch)
tree1333cfc2bd04e135614e0c7160831baf9ce96468
parent366514a72577d9e9b1c58fc768d084e73ef4f3a5 (diff)
downloaddexon-solidity-5cecf5699b4e5fa25770ebab350750731a0d430d.tar.gz
dexon-solidity-5cecf5699b4e5fa25770ebab350750731a0d430d.tar.zst
dexon-solidity-5cecf5699b4e5fa25770ebab350750731a0d430d.zip
Disallow assignments to structs and mappings.
-rw-r--r--solidityNameAndTypeResolution.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/solidityNameAndTypeResolution.cpp b/solidityNameAndTypeResolution.cpp
index a19e7450..8804c519 100644
--- a/solidityNameAndTypeResolution.cpp
+++ b/solidityNameAndTypeResolution.cpp
@@ -244,6 +244,36 @@ BOOST_AUTO_TEST_CASE(balance_invalid)
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
+BOOST_AUTO_TEST_CASE(assignment_to_mapping)
+{
+ char const* text = "contract test {\n"
+ " struct str {\n"
+ " mapping(uint=>uint) map;\n"
+ " }\n"
+ " str data;"
+ " function fun() {\n"
+ " var a = data.map;\n"
+ " data.map = a;\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(assignment_to_struct)
+{
+ char const* text = "contract test {\n"
+ " struct str {\n"
+ " mapping(uint=>uint) map;\n"
+ " }\n"
+ " str data;"
+ " function fun() {\n"
+ " var a = data;\n"
+ " data = a;\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}