Merge pull request #91 from chriseth/literalStringsToStoragePointer

Literal strings to storage pointer
This commit is contained in:
chriseth 2015-09-24 10:23:35 +02:00
commit 52f7e35843
2 changed files with 13 additions and 1 deletions

View File

@ -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;
}

View File

@ -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()
}