mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6639 from ethereum/yul-require-assert
Yul generation of "require" and "assert"
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user