aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-07-13 03:45:41 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-07-14 05:16:14 +0800
commitaec3eabdda3ba36ed33746fae9ed9eba02286fd4 (patch)
tree42c592871ef73e752a61607a65f3f65d4644bfc4 /test/libsolidity
parent033fc0cb1acab770e25f54d7ee2d50be994a4e45 (diff)
downloaddexon-solidity-aec3eabdda3ba36ed33746fae9ed9eba02286fd4.tar.gz
dexon-solidity-aec3eabdda3ba36ed33746fae9ed9eba02286fd4.tar.zst
dexon-solidity-aec3eabdda3ba36ed33746fae9ed9eba02286fd4.zip
Add test for explicit type conversion literal string
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 36b48cfd..cb39101e 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -6322,6 +6322,43 @@ BOOST_AUTO_TEST_CASE(too_large_arrays_for_calldata)
CHECK_ERROR(text, TypeError, "Array is too large to be encoded as calldata.");
}
+BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string)
+{
+ char const* text = R"(
+ contract C {
+ function f() {
+ string memory x = "abc";
+ x;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ text = R"(
+ contract C {
+ function f() {
+ string storage x = "abc";
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
+ text = R"(
+ contract C {
+ function f() {
+ string x = "abc";
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
+ text = R"(
+ contract C {
+ function f() {
+ string("abc");
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Explicit type conversion not allowed from \"literal_string \"abc\"\" to \"string storage pointer\"");
+}
+
BOOST_AUTO_TEST_SUITE_END()
}