I'm a bit confused by the code at this smart contract, which is part of the Aragon project code:
function delegatedFwd(
address _dst,
bytes _calldata,
uint256 _minReturnSize) internal {
require(isContract(_dst));
uint256 size;
uint256 result;
uint256 fwd_gas_limit = FWD_GAS_LIMIT;
assembly {
result := delegatecall(sub(gas, fwd_gas_limit), _dst, add(_calldata, 0x20), mload(_calldata), 0, 0)
size := returndatasize
}
require(size >= _minReturnSize);
assembly {
let ptr := mload(0x40)
returndatacopy(ptr, 0, size)
// revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
// if the call returned error data, forward it
switch result case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
The function declaration does not declare a return value, yet the function itself appears in the last line to return data.
If a caller called this function, wouldn't the caller have to ignore the return value or the code should fail to compile?
What am I missing? Would the caller have to access the return values with assembly and if that's the case isn't this violating the spirit of the function definition? It seems like bad programming practice to me.