aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFederico Bond <federicobond@gmail.com>2016-12-13 10:59:53 +0800
committerFederico Bond <federicobond@gmail.com>2016-12-13 11:32:37 +0800
commitde720e643d8c54c613356bfcdcb6c49984460a17 (patch)
tree68cf22d6ab999f316ff3ec967029015b3aae6df5 /test
parent1c3605362d6018f5ab72cc84c7511fb49c15d126 (diff)
downloaddexon-solidity-de720e643d8c54c613356bfcdcb6c49984460a17.tar
dexon-solidity-de720e643d8c54c613356bfcdcb6c49984460a17.tar.gz
dexon-solidity-de720e643d8c54c613356bfcdcb6c49984460a17.tar.bz2
dexon-solidity-de720e643d8c54c613356bfcdcb6c49984460a17.tar.lz
dexon-solidity-de720e643d8c54c613356bfcdcb6c49984460a17.tar.xz
dexon-solidity-de720e643d8c54c613356bfcdcb6c49984460a17.tar.zst
dexon-solidity-de720e643d8c54c613356bfcdcb6c49984460a17.zip
Improve error message when trying to modify constant variables
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index a4e601f7..576421fd 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -4865,6 +4865,17 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_modifier_following_non_payable_p
CHECK_SUCCESS_NO_WARNINGS(text);
}
+BOOST_AUTO_TEST_CASE(assignment_to_constant)
+{
+ char const* text = R"(
+ contract c {
+ uint constant a = 1;
+ function f() { a = 2; }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Cannot assign to a constant variable.");
+}
+
BOOST_AUTO_TEST_SUITE_END()
}