forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary_call.sol
40 lines (40 loc) · 977 Bytes
/
library_call.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library L {
struct S { uint x; }
function integer(uint t, bool b) public pure 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 pure 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);
}
}
}
// ====
// EVMVersion: >=byzantium
// ----