mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol2Yul] Implements codegen part for try/catch statements.
This commit is contained in:
committed by
chriseth
parent
3b83365b42
commit
d00d3c45b1
@@ -12,6 +12,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// f(bool): true -> 1, 2, 96, 0
|
||||
|
||||
@@ -26,6 +26,7 @@ contract C {
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool,bool): true, true -> 1, 2, 96, 7, "success"
|
||||
// f(bool,bool): true, false -> 12, 0, 96, 7, "failure"
|
||||
|
||||
@@ -13,5 +13,7 @@ contract C {
|
||||
}
|
||||
function fun() public pure {}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0x1, 0xfdd67305928fcac8d213d1e47bfa6165cd0b87b946644cd0000000000000000, 9
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
contract C {
|
||||
function g(bool b) public pure returns (uint, uint) {
|
||||
function g(bool b) public pure returns (uint x, uint y) {
|
||||
require(b);
|
||||
return (1, 2);
|
||||
}
|
||||
function f(bool b) public returns (uint x, uint y) {
|
||||
try this.g(b) returns (uint a, uint b) {
|
||||
function f(bool flag) public view returns (uint x, uint y) {
|
||||
try this.g(flag) returns (uint a, uint b) {
|
||||
(x, y) = (a, b);
|
||||
} catch {
|
||||
(x, y) = (9, 10);
|
||||
@@ -13,6 +13,7 @@ contract C {
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool): true -> 1, 2
|
||||
// f(bool): false -> 9, 10
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function g(bool b) public pure returns (uint x) {
|
||||
require(b);
|
||||
return 13;
|
||||
}
|
||||
function f(bool flag) public view returns (uint x) {
|
||||
try this.g(flag) returns (uint a) {
|
||||
x = a;
|
||||
} catch {
|
||||
x = 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool): true -> 13
|
||||
// f(bool): false -> 9
|
||||
@@ -14,6 +14,7 @@ contract C {
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool): true -> 1, 2, 0x60, 7, "success"
|
||||
// f(bool): false -> 0, 0, 0x60, 7, "message"
|
||||
|
||||
@@ -18,6 +18,7 @@ contract C {
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool): true -> 1, 2, 96, 7, "success"
|
||||
// f(bool): false -> 99, 0, 96, 82, "message longer than 32 bytes 32 ", "bytes 32 bytes 32 bytes 32 bytes", " 32 bytes 32 bytes"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
function g(bool x) external pure {
|
||||
require(x);
|
||||
}
|
||||
function f(bool x) public returns (uint) {
|
||||
try this.g(x) {
|
||||
return 1;
|
||||
} catch {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool): true -> 1
|
||||
// f(bool): false -> 2
|
||||
Reference in New Issue
Block a user