Description
Abstract
NOTE: This seems to only be breaking if you do another external call from a contract with address(0). e.g. in the example below, if callA returns address(0).
try/catch
only catches the very first external call although it allows multiple external calls to be tried. This could be a bit of a footgun if a single external call is not warned or enforced or if each of the external calls in the "try" block are not tried.
Motivation
This can be slightly confusing when you do something like: try IContractB(contractA.callA()).callB() {} catch {}
This will revert if the function callB
doesn't exist on the address returned by contractA.callA
.
The interfaces:
IContractA {
function callA() external returns (address);
}
IContractB {
function callB() external;
}
Specification
It would make more sense to:
- not allow multiple external calls to be tried (compiler error)
- try each of them separately
- warn that you have multiple external calls in a try "block" (compiler warning)
Backwards Compatibility
Specifications 2 and 3 would likely be backwards compatible, but Specification 1 would probably break code which violates this rule when they update their solc if this change was made.