Compiler enters unreachable code when building for Solana
The following contract enters unreachable code when we build it for Solana:
contract testing {
function doThis(int a) public view returns (int) {
return a+2;
}
function IlikeTests() public returns(function (int) external returns (int) retPtr) {
function (int) external returns (int) fPtr = this.doThis;
return fPtr;
}
}
The error is the following:
thread 'main' panicked at 'internal error: entered unreachable code', src/emit/ethabiencoder.rs:1546:18
The eth abi encoding does not know how to encode external function types.
This is not easy/possible to implement on Solana. Eth abi encoding encodes this into 32 bytes: 20 bytes for address, and 4 bytes for the function selector. On Solana, we already use 32 bytes for address, so we need to use a different encoding, which won't be compatible with the eth abi encoding libraries. I guess we could encode it as a struct and then specify it as a struct in the abi file.
Once we switch to borsh encoding, this problem goes away.
Once we switch to borsh encoding, this problem goes away.
@seanyoung Yes, this is why I haven't touched this issue.
Closed by #1053