solidity/test/libsolidity/semanticTests/tryCatch/try_catch_library_call.sol
Alex Beregszaszi 8d9c332593 Properly terminate definitions using define() in IRGenerateForStatements
The lack of termination can result in unparseable output.
2020-11-25 16:41:39 +00:00

47 lines
1.1 KiB
Solidity

library L {
struct S { uint x; }
function integer(uint t, bool b) public view returns (uint) {
if (b) {
return t;
} else {
revert("failure");
}
}
function stru(S storage t, bool b) public view returns (uint) {
if (b) {
return t.x;
} else {
revert("failure");
}
}
}
contract C {
using L for L.S;
L.S t;
function f(bool b) public returns (uint, string memory) {
uint x = 8;
try L.integer(x, b) returns (uint _x) {
return (_x, "");
} catch Error(string memory message) {
return (18, message);
}
}
function g(bool b) public returns (uint, string memory) {
t.x = 9;
try t.stru(b) returns (uint x) {
return (x, "");
} catch Error(string memory message) {
return (19, message);
}
}
}
// ====
// compileViaYul: also
// EVMVersion: >=byzantium
// ----
// library: L
// f(bool): true -> 8, 0x40, 0
// f(bool): false -> 18, 0x40, 7, "failure"
// g(bool): true -> 9, 0x40, 0
// g(bool): false -> 19, 0x40, 7, "failure"