aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-08 18:29:55 +0800
committerGitHub <noreply@github.com>2018-11-08 18:29:55 +0800
commit84e8a782d6af15d89c443681efb7663b031c57be (patch)
tree78c496133ec577749774379b3eee2d3b5edc0d10 /libsolidity
parentcc2de07bc6be6125fb5505d17f8c50fac8d15dc6 (diff)
parentb16a3644fe7d54ed5fa6d7a7dac40b4aab641e76 (diff)
downloaddexon-solidity-84e8a782d6af15d89c443681efb7663b031c57be.tar.gz
dexon-solidity-84e8a782d6af15d89c443681efb7663b031c57be.tar.zst
dexon-solidity-84e8a782d6af15d89c443681efb7663b031c57be.zip
Merge pull request #5351 from ethereum/functionTypeConversion
Relax type equality requirement of function types during conversion in code generation.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index d89d023e..90eb74fe 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -1016,8 +1016,22 @@ void CompilerUtils::convertType(
}
else
{
- // All other types should not be convertible to non-equal types.
- solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
+ if (stackTypeCategory == Type::Category::Function && targetTypeCategory == Type::Category::Function)
+ {
+ FunctionType const& typeOnStack = dynamic_cast<FunctionType const&>(_typeOnStack);
+ FunctionType const& targetType = dynamic_cast<FunctionType const&>(_targetType);
+ solAssert(
+ typeOnStack.isImplicitlyConvertibleTo(targetType) &&
+ typeOnStack.sizeOnStack() == targetType.sizeOnStack() &&
+ (typeOnStack.kind() == FunctionType::Kind::Internal || typeOnStack.kind() == FunctionType::Kind::External) &&
+ typeOnStack.kind() == targetType.kind(),
+ "Invalid function type conversion requested."
+ );
+ }
+ else
+ // All other types should not be convertible to non-equal types.
+ solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
+
if (_cleanupNeeded && _targetType.canBeStored() && _targetType.storageBytes() < 32)
m_context
<< ((u256(1) << (8 * _targetType.storageBytes())) - 1)