I have a function that takes a parameter of type function (uint256) view returns (uint256).
I want to pass it a pointer to a function of type function (uint256) pure returns (uint256).
Obviously there shouldn't be a problem with passing this pure function into a parameter that expects a view function, because the parameter and returns types are the same and pure is even more limiting than view. However, I get this TypeError:
TypeError: Invalid type for argument in function call. Invalid implicit conversion from
function (uint256) pure returns (uint256)tofunction (uint256) view returns (uint256)requested.
Things I've tried:
Assigning the function to a local variable gives a similar TypeError:
function(uint256) view returns(uint256) a = func;
TypeError: Type
function (uint256) pure returns (uint256)is not implicitly convertible to expected typefunction (uint256) view returns (uint256)
The usual type-casting syntax of Solidity gives a ParserError at the function keyword
function(uint256) view returns(uint256) a = function(uint256) view returns(uint256) (func);
ParserError: Expected primary expression
-------
I've noticed that the TypeError's keep telling me that the function pointer is not implicitly convertible. Is there a way to explicitly convert it?
viewfunction as parameter. I want to pass it apurefunction. – Jesbus Feb 10 '19 at 14:39