diff options
author | chriseth <c@ethdev.com> | 2015-09-24 16:23:35 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-09-24 16:23:35 +0800 |
commit | 52f7e3584350a3d204542ccc982c0951f4c94dc7 (patch) | |
tree | fb37a3e6d0694468ce25fe6fa3b0dfa7dc924f4f | |
parent | 4a2114ba35eae0a9dae5be2526d107dd19d33baf (diff) | |
parent | 8a9b9e4fdbead915da0dd725d3dc0ffe45d84065 (diff) | |
download | dexon-solidity-52f7e3584350a3d204542ccc982c0951f4c94dc7.tar.gz dexon-solidity-52f7e3584350a3d204542ccc982c0951f4c94dc7.tar.zst dexon-solidity-52f7e3584350a3d204542ccc982c0951f4c94dc7.zip |
Merge pull request #91 from chriseth/literalStringsToStoragePointer
Literal strings to storage pointer
-rw-r--r-- | libsolidity/Types.cpp | 4 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 18f2817e..0e24a813 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -511,7 +511,9 @@ bool StringLiteralType::isImplicitlyConvertibleTo(Type const& _convertTo) const if (auto fixedBytes = dynamic_cast<FixedBytesType const*>(&_convertTo)) return size_t(fixedBytes->numBytes()) >= m_value.size(); else if (auto arrayType = dynamic_cast<ArrayType const*>(&_convertTo)) - return arrayType->isByteArray(); + return + arrayType->isByteArray() && + !(arrayType->dataStoredIn(DataLocation::Storage) && arrayType->isPointer()); else return false; } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 8346b8ca..cac16682 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2308,6 +2308,16 @@ BOOST_AUTO_TEST_CASE(array_out_of_bound_access) SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError); } +BOOST_AUTO_TEST_CASE(literal_string_to_storage_pointer) +{ + char const* text = R"( + contract C { + function f() { string x = "abc"; } + } + )"; + SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } |