aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-05 21:52:25 +0800
committerchriseth <chris@ethereum.org>2018-04-12 22:37:16 +0800
commit75b88286667690ffb4a5e079665ed8b70bcaeb87 (patch)
treeee0952b521768895b329f3e91dfa0a98eb2b4cef /libsolidity/analysis
parent7343c4028365d3fbc9fa46fca6078971a2bed426 (diff)
downloaddexon-solidity-75b88286667690ffb4a5e079665ed8b70bcaeb87.tar
dexon-solidity-75b88286667690ffb4a5e079665ed8b70bcaeb87.tar.gz
dexon-solidity-75b88286667690ffb4a5e079665ed8b70bcaeb87.tar.bz2
dexon-solidity-75b88286667690ffb4a5e079665ed8b70bcaeb87.tar.lz
dexon-solidity-75b88286667690ffb4a5e079665ed8b70bcaeb87.tar.xz
dexon-solidity-75b88286667690ffb4a5e079665ed8b70bcaeb87.tar.zst
dexon-solidity-75b88286667690ffb4a5e079665ed8b70bcaeb87.zip
Allow struct encoding with new encoder.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index df08598c..b95fee38 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1723,6 +1723,8 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
}
else if (isPositionalCall)
{
+ bool const abiEncodeV2 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2);
+
for (size_t i = 0; i < arguments.size(); ++i)
{
auto const& argType = type(*arguments[i]);
@@ -1735,13 +1737,22 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
m_errorReporter.typeError(arguments[i]->location(), "Invalid rational number (too large or division by zero).");
errored = true;
}
- if (!errored && !(
- argType->mobileType() &&
- argType->mobileType()->interfaceType(false) &&
- argType->mobileType()->interfaceType(false)->encodingType() &&
- !(dynamic_cast<StructType const*>(argType->mobileType()->interfaceType(false)->encodingType().get()))
- ))
- m_errorReporter.typeError(arguments[i]->location(), "This type cannot be encoded.");
+ if (!errored)
+ {
+ TypePointer encodingType;
+ if (
+ argType->mobileType() &&
+ argType->mobileType()->interfaceType(false) &&
+ argType->mobileType()->interfaceType(false)->encodingType()
+ )
+ encodingType = argType->mobileType()->interfaceType(false)->encodingType();
+ // Structs are fine as long as ABIV2 is activated and we do not do packed encoding.
+ if (!encodingType || (
+ dynamic_cast<StructType const*>(encodingType.get()) &&
+ !(abiEncodeV2 && functionType->padArguments())
+ ))
+ m_errorReporter.typeError(arguments[i]->location(), "This type cannot be encoded.");
+ }
}
else if (!type(*arguments[i])->isImplicitlyConvertibleTo(*parameterTypes[i]))
m_errorReporter.typeError(