aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-11-25 20:54:13 +0800
committerYoichi Hirai <i@yoichihirai.com>2016-11-25 20:54:13 +0800
commitdf5d5edd1b7cb2e9f26d3a2491442185e0ffc17a (patch)
tree76d3dccfeea173f4107cc789c1764361888b1c57
parente136ec87041cce9d8d472e45f4dfbed9a8d02469 (diff)
downloaddexon-solidity-df5d5edd1b7cb2e9f26d3a2491442185e0ffc17a.tar
dexon-solidity-df5d5edd1b7cb2e9f26d3a2491442185e0ffc17a.tar.gz
dexon-solidity-df5d5edd1b7cb2e9f26d3a2491442185e0ffc17a.tar.bz2
dexon-solidity-df5d5edd1b7cb2e9f26d3a2491442185e0ffc17a.tar.lz
dexon-solidity-df5d5edd1b7cb2e9f26d3a2491442185e0ffc17a.tar.xz
dexon-solidity-df5d5edd1b7cb2e9f26d3a2491442185e0ffc17a.tar.zst
dexon-solidity-df5d5edd1b7cb2e9f26d3a2491442185e0ffc17a.zip
test: add a test about explicitly converting a string literal to string
-rw-r--r--Changelog.md5
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp12
2 files changed, 16 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md
index 468518d2..0b10cd0c 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,8 @@
+### 0.4.7 (unreleased)
+
+Bugfixes:
+ * Type checker: string literals that are not valid UTF-8 cannot be converted to string type
+
### 0.4.6 (2016-11-22)
Bugfixes:
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index cc4da61b..7a132068 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2038,7 +2038,7 @@ BOOST_AUTO_TEST_CASE(string)
BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
}
-BOOST_AUTO_TEST_CASE(invalid_utf8)
+BOOST_AUTO_TEST_CASE(invalid_utf8_implicit)
{
char const* sourceCode = R"(
contract C {
@@ -2048,6 +2048,16 @@ BOOST_AUTO_TEST_CASE(invalid_utf8)
CHECK_ERROR(sourceCode, TypeError, "invalid UTF-8");
}
+BOOST_AUTO_TEST_CASE(invalid_utf8_explicit)
+{
+ char const* sourceCode = R"(
+ contract C {
+ string s = string("\xa0\x00");
+ }
+ )";
+ CHECK_ERROR(sourceCode, TypeError, "Explicit type conversion not allowed");
+}
+
BOOST_AUTO_TEST_CASE(string_index)
{
char const* sourceCode = R"(