diff options
author | Gav Wood <g@ethdev.com> | 2014-12-03 17:15:11 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2014-12-03 17:15:11 +0800 |
commit | e7201a032429534b4cde33c21c00777c04448b15 (patch) | |
tree | 6b525073833fc746ba2d584620be59523456e589 | |
parent | 2f5b9151d5d28d1874acce22fe52b6cc0ab2c226 (diff) | |
parent | 5cecf5699b4e5fa25770ebab350750731a0d430d (diff) | |
download | dexon-solidity-e7201a032429534b4cde33c21c00777c04448b15.tar dexon-solidity-e7201a032429534b4cde33c21c00777c04448b15.tar.gz dexon-solidity-e7201a032429534b4cde33c21c00777c04448b15.tar.bz2 dexon-solidity-e7201a032429534b4cde33c21c00777c04448b15.tar.lz dexon-solidity-e7201a032429534b4cde33c21c00777c04448b15.tar.xz dexon-solidity-e7201a032429534b4cde33c21c00777c04448b15.tar.zst dexon-solidity-e7201a032429534b4cde33c21c00777c04448b15.zip |
Merge pull request #549 from chriseth/sol_saveScope
Disallow assignments to structs and mappings
-rw-r--r-- | solidityNameAndTypeResolution.cpp | 30 |
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() } |