Skip to content

Instantly share code, notes, and snippets.

@Marenz
Created August 19, 2019 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marenz/596e33300290d10f0aee4f8f7602dbdb to your computer and use it in GitHub Desktop.
Save Marenz/596e33300290d10f0aee4f8f7602dbdb to your computer and use it in GitHub Desktop.
contract C {
function f(bool a) public pure returns (bool x) {
bool b = a;
x = b;
require(b);
}
function fail() public pure returns (bool x) {
x = true;
require(false);
}
function succeed() public pure returns (bool x) {
x = true;
require(true);
}
function f2(bool a) public pure returns (bool x) {
x = a;
string memory message;
require(a, message);
}
function f3(bool a) public pure returns (bool x) {
x = a;
require(a, "msg");
}
}
// ====
// compileViaYul: true
// ----
// f(bool): true -> true
// f(bool): false -> FAILURE
// fail() -> FAILURE
// succeed() -> true
// f2(bool): true -> true
// f2(bool): false -> FAILURE, hex"00", 0x00, "Transaction failed."
// f3(bool): true -> true
// f3(bool): false -> FAILURE, hex"00", 0x00, "Transaction failed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment