Skip to content

Instantly share code, notes, and snippets.

@ezesundayeze
Last active July 24, 2024 10:25
Show Gist options
  • Save ezesundayeze/b14fbe071b4ef64439dc995d72f51032 to your computer and use it in GitHub Desktop.
Save ezesundayeze/b14fbe071b4ef64439dc995d72f51032 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.25+commit.b61c2a91.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.2 <0.9.0;
import "hardhat/console.sol";
interface IFoo {
// Interface is returning data but the try/catch isn’t looking for it
function f() external view returns (uint256);
}
contract Foo {
function f() external pure {} // no return
}
contract Bar {
// this always reverts
function callFoo(IFoo foo) external view {
// The interface expects a return value, but this function does not return one
try foo.f() {
} catch (bytes memory lowLevelData) {
console.logBytes(lowLevelData); // <-- this will not be reached.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment