mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not set to ref for explicit conversion and add assertion for array
type conversion. Also, add some test cases for #4901 and #4948.
This commit is contained in:
committed by
Daniel Kirchner
parent
5f4a2d2cad
commit
f3cbdadec7
@@ -1733,8 +1733,23 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
|
||||
DataLocation dataLoc = DataLocation::Memory;
|
||||
if (auto argRefType = dynamic_cast<ReferenceType const*>(argType.get()))
|
||||
dataLoc = argRefType->location();
|
||||
resultType = ReferenceType::copyForLocationIfReference(dataLoc, resultType);
|
||||
if (!argType->isExplicitlyConvertibleTo(*resultType))
|
||||
if (auto type = dynamic_cast<ReferenceType const*>(resultType.get()))
|
||||
resultType = type->copyForLocation(dataLoc, type->isPointer());
|
||||
if (argType->isExplicitlyConvertibleTo(*resultType))
|
||||
{
|
||||
if (auto argArrayType = dynamic_cast<ArrayType const*>(argType.get()))
|
||||
{
|
||||
auto resultArrayType = dynamic_cast<ArrayType const*>(resultType.get());
|
||||
solAssert(!!resultArrayType, "");
|
||||
solAssert(
|
||||
argArrayType->location() != DataLocation::Storage ||
|
||||
((resultArrayType->isPointer() || (argArrayType->isByteArray() && resultArrayType->isByteArray())) &&
|
||||
resultArrayType->location() == DataLocation::Storage),
|
||||
"Invalid explicit conversion to storage type."
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resultType->category() == Type::Category::Contract && argType->category() == Type::Category::Address)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user