Improve error message when trying to modify constant variables

This commit is contained in:
Federico Bond
2016-12-13 00:32:37 -03:00
parent 1c3605362d
commit de720e643d
3 changed files with 19 additions and 1 deletions
@@ -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()
}