solidity/test/libsolidity/semanticTests/tryCatch/malformed_panic_3.sol
2020-12-22 11:08:44 +01:00

60 lines
1.5 KiB
Solidity

contract C {
function f(uint size) public pure {
assembly {
mstore(0, 0x4e487b7100000000000000000000000000000000000000000000000000000000)
mstore(4, 0x43)
revert(0, size)
}
}
function a() public returns (uint) {
try this.f(3) {
assert(false);
} catch Panic(uint) {
assert(false);
} catch Error(string memory) {
assert(false);
}
// Error will be re-thrown, since there is no low-level catch clause
assert(false);
}
function b() public returns (uint) {
try this.f(6) {
assert(false);
} catch Panic(uint) {
assert(false);
} catch Error(string memory) {
assert(false);
}
// Error will be re-thrown, since there is no low-level catch clause
assert(false);
}
function c() public returns (uint) {
try this.f(0x24) {
assert(false);
} catch Panic(uint c) {
assert(true);
return c;
} catch Error(string memory) {
assert(false);
}
}
function d() public returns (uint) {
try this.f(0x100) {
assert(false);
} catch Panic(uint c) {
assert(true);
return c;
} catch Error(string memory) {
assert(false);
}
}
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// ----
// a() -> FAILURE, hex"4e487b"
// b() -> FAILURE, hex"4e487b710000"
// c() -> 0x43
// d() -> 0x43