aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-27 21:50:06 +0800
committerChristian <c@ethdev.com>2015-02-28 05:52:19 +0800
commite42183f2ff4e49bdba598651ab5f2c1d81042a57 (patch)
treeb9de9ac4dea46dee25113a08abdc5aff3334dfb6
parentdca13033973c4346326cd23c71a02c8ea12b0e50 (diff)
downloaddexon-solidity-e42183f2ff4e49bdba598651ab5f2c1d81042a57.tar
dexon-solidity-e42183f2ff4e49bdba598651ab5f2c1d81042a57.tar.gz
dexon-solidity-e42183f2ff4e49bdba598651ab5f2c1d81042a57.tar.bz2
dexon-solidity-e42183f2ff4e49bdba598651ab5f2c1d81042a57.tar.lz
dexon-solidity-e42183f2ff4e49bdba598651ab5f2c1d81042a57.tar.xz
dexon-solidity-e42183f2ff4e49bdba598651ab5f2c1d81042a57.tar.zst
dexon-solidity-e42183f2ff4e49bdba598651ab5f2c1d81042a57.zip
Type checks for array assignment.
-rw-r--r--SolidityNameAndTypeResolution.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp
index 4809aac1..ff9fa165 100644
--- a/SolidityNameAndTypeResolution.cpp
+++ b/SolidityNameAndTypeResolution.cpp
@@ -1185,6 +1185,61 @@ BOOST_AUTO_TEST_CASE(array_with_nonconstant_length)
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
+BOOST_AUTO_TEST_CASE(array_copy_with_different_types1)
+{
+ char const* text = R"(
+ contract c {
+ bytes a;
+ uint[] b;
+ function f() { b = a; }
+ })";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(array_copy_with_different_types2)
+{
+ char const* text = R"(
+ contract c {
+ uint32[] a;
+ uint8[] b;
+ function f() { b = a; }
+ })";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(array_copy_with_different_types_conversion_possible)
+{
+ char const* text = R"(
+ contract c {
+ uint32[] a;
+ uint8[] b;
+ function f() { a = b; }
+ })";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+BOOST_AUTO_TEST_CASE(array_copy_with_different_types_static_dynamic)
+{
+ char const* text = R"(
+ contract c {
+ uint32[] a;
+ uint8[80] b;
+ function f() { a = b; }
+ })";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+BOOST_AUTO_TEST_CASE(array_copy_with_different_types_dynamic_static)
+{
+ char const* text = R"(
+ contract c {
+ uint[] a;
+ uint[80] b;
+ function f() { b = a; }
+ })";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}