Merge pull request #6639 from ethereum/yul-require-assert

Yul generation of "require" and "assert"
This commit is contained in:
chriseth
2019-05-07 16:59:37 +02:00
committed by GitHub
7 changed files with 152 additions and 1 deletions
@@ -0,0 +1,22 @@
contract C {
function f(bool a) public pure returns (bool x) {
bool b = a;
x = b;
assert(b);
}
function fail() public pure returns (bool x) {
x = true;
assert(false);
}
function succeed() public pure returns (bool x) {
x = true;
assert(true);
}
}
// ====
// compileViaYul: true
// ----
// f(bool): true -> true
// f(bool): false -> FAILURE
// fail() -> FAILURE
// succeed() -> true
@@ -0,0 +1,19 @@
contract C {
function f(bool a) public pure returns (bool x) {
bool b = a;
x = b;
assert(b);
}
function f2(bool a) public pure returns (bool x) {
bool b = a;
x = b;
require(b);
}
}
// ====
// compileViaYul: true
// ----
// f(bool): true -> true
// f(bool): false -> FAILURE
// f2(bool): true -> true
// f2(bool): false -> FAILURE
@@ -0,0 +1,28 @@
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);
}
/* Not properly supported by test system yet
function f2(bool a) public pure returns (bool x) {
x = a;
string memory message;
require(a, message);
}*/
}
// ====
// compileViaYul: true
// ----
// f(bool): true -> true
// f(bool): false -> FAILURE
// fail() -> FAILURE
// succeed() -> true