aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-11-06 20:29:49 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-11-08 17:51:51 +0800
commitb16a3644fe7d54ed5fa6d7a7dac40b4aab641e76 (patch)
tree114d01c712baccaf1717dfe097ff29f47faaae98 /libsolidity/codegen
parenta3e37a9d5aa2039255783ffba4629574c4acf4c6 (diff)
downloaddexon-solidity-b16a3644fe7d54ed5fa6d7a7dac40b4aab641e76.tar
dexon-solidity-b16a3644fe7d54ed5fa6d7a7dac40b4aab641e76.tar.gz
dexon-solidity-b16a3644fe7d54ed5fa6d7a7dac40b4aab641e76.tar.bz2
dexon-solidity-b16a3644fe7d54ed5fa6d7a7dac40b4aab641e76.tar.lz
dexon-solidity-b16a3644fe7d54ed5fa6d7a7dac40b4aab641e76.tar.xz
dexon-solidity-b16a3644fe7d54ed5fa6d7a7dac40b4aab641e76.tar.zst
dexon-solidity-b16a3644fe7d54ed5fa6d7a7dac40b4aab641e76.zip
Function type conversion test cases.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 22f97dfa..90eb74fe 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -1014,12 +1014,24 @@ void CompilerUtils::convertType(
// stack: <address> <function_id>
m_context << Instruction::POP;
}
- else if (stackTypeCategory == Type::Category::Function && targetTypeCategory == Type::Category::Function)
- solAssert(_typeOnStack.isImplicitlyConvertibleTo(_targetType), "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 (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)