diff options
author | liangdzou <liang.d.zou@gmail.com> | 2018-09-12 18:01:34 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-09-14 14:42:40 +0800 |
commit | f3cbdadec7a38626e5dd64c0faa981161b99bd80 (patch) | |
tree | 85320ca1805bfaad95c45b60160481d4fcb09e6c /libsolidity/analysis | |
parent | 5f4a2d2cad56dee3f7f350d65d24b98d1f4b2b07 (diff) | |
download | dexon-solidity-f3cbdadec7a38626e5dd64c0faa981161b99bd80.tar.gz dexon-solidity-f3cbdadec7a38626e5dd64c0faa981161b99bd80.tar.zst dexon-solidity-f3cbdadec7a38626e5dd64c0faa981161b99bd80.zip |
Do not set to ref for explicit conversion and add assertion for array
type conversion. Also, add some test cases for #4901 and #4948.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 13294476..3056561b 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -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) { |