From b0ae85b6b0e72f2af37acb8465ec657d299a62c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 19 May 2020 18:00:50 +0200 Subject: [PATCH 1/2] IRGenerationContext::internalDispatch(): Don't use asCallableFunction() to get internal function type --- libsolidity/codegen/ir/IRGenerationContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsolidity/codegen/ir/IRGenerationContext.cpp b/libsolidity/codegen/ir/IRGenerationContext.cpp index ee477792f..8472bb82a 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.cpp +++ b/libsolidity/codegen/ir/IRGenerationContext.cpp @@ -153,7 +153,7 @@ string IRGenerationContext::internalDispatch(size_t _in, size_t _out) for (auto const& contract: mostDerivedContract().annotation().linearizedBaseContracts) for (FunctionDefinition const* function: contract->definedFunctions()) if ( - FunctionType const* functionType = TypeProvider::function(*function)->asCallableFunction(false); + FunctionType const* functionType = TypeProvider::function(*function, FunctionType::Kind::Internal); !function->isConstructor() && TupleType(functionType->parameterTypes()).sizeOnStack() == _in && TupleType(functionType->returnParameterTypes()).sizeOnStack() == _out From 16e80b7bcd07181daacf3111cf251141e83a3530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 19 May 2020 18:02:14 +0200 Subject: [PATCH 2/2] Test case for internal dispatch with functions that have arguments that take up multiple slots --- ...n_with_multislot_arguments_via_pointer.sol | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/libsolidity/semanticTests/functionCall/call_internal_function_with_multislot_arguments_via_pointer.sol diff --git a/test/libsolidity/semanticTests/functionCall/call_internal_function_with_multislot_arguments_via_pointer.sol b/test/libsolidity/semanticTests/functionCall/call_internal_function_with_multislot_arguments_via_pointer.sol new file mode 100644 index 000000000..344d1dc63 --- /dev/null +++ b/test/libsolidity/semanticTests/functionCall/call_internal_function_with_multislot_arguments_via_pointer.sol @@ -0,0 +1,31 @@ +contract C { + function m( + function() external returns (uint) a, + function() external returns (uint) b + ) internal returns (function() external returns (uint)) { + return a; + } + + function s(uint a, uint b) internal returns (uint) { + return a + b; + } + + function foo() external returns (uint) { + return 6; + } + + function test() public returns (uint) { + function(uint, uint) internal returns (uint) single_slot_function = s; + + function( + function() external returns (uint), + function() external returns (uint) + ) internal returns (function() external returns (uint)) multi_slot_function = m; + + return multi_slot_function(this.foo, this.foo)() + single_slot_function(5, 1); + } +} +// ==== +// compileViaYul: also +// ---- +// test() -> 12