solidity/test/libsolidity/semanticTests/tryCatch/create.sol
2020-11-11 17:52:50 +01:00

34 lines
851 B
Solidity

contract Reverts {
constructor(uint) { revert("test message."); }
}
contract Succeeds {
constructor(uint) { }
}
contract C {
function f() public returns (Reverts x, uint, string memory txt) {
uint i = 3;
try new Reverts(i) returns (Reverts r) {
x = r;
txt = "success";
} catch Error(string memory s) {
txt = s;
}
}
function g() public returns (Succeeds x, uint, string memory txt) {
uint i = 8;
try new Succeeds(i) returns (Succeeds r) {
x = r;
txt = "success";
} catch Error(string memory s) {
txt = s;
}
}
}
// ====
// compileViaYul: also
// EVMVersion: >=byzantium
// ----
// f() -> 0, 0, 96, 13, "test message."
// g() -> 0xf01f7809444bd9a93a854361c6fae3f23d9e23db, 0, 96, 7, "success"