Code generation for errors.

This commit is contained in:
chriseth
2021-02-01 18:26:31 +01:00
parent 4d1fd84150
commit 2deb2b370f
12 changed files with 281 additions and 104 deletions
@@ -0,0 +1,10 @@
error E(uint a, uint b);
contract C {
function f() public pure {
revert(E({b: 7, a: 2}));
}
}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE, hex"85208890", hex"0000000000000000000000000000000000000000000000000000000000000002", hex"0000000000000000000000000000000000000000000000000000000000000007"
@@ -0,0 +1,11 @@
error E(uint a, uint b);
contract C {
function f(bool c) public pure {
require(c, E({b: 7, a: 2}));
}
}
// ====
// compileViaYul: also
// ----
// f(bool): true ->
// f(bool): false -> FAILURE, hex"85208890", hex"0000000000000000000000000000000000000000000000000000000000000002", hex"0000000000000000000000000000000000000000000000000000000000000007"
@@ -0,0 +1,13 @@
error E(string a, uint[] b);
contract C {
uint[] x;
function f(bool c) public {
x.push(7);
require(c, E("abc", x));
}
}
// ====
// compileViaYul: also
// ----
// f(bool): false -> FAILURE, hex"59e4d4df", 0x40, 0x80, 3, "abc", 1, 7
// f(bool): true ->
@@ -0,0 +1,19 @@
error E(uint a, uint b);
contract C {
uint public x;
function f(bool c) public {
require(c, E(g(), 7));
}
function g() public returns (uint) {
x++;
return 2;
}
}
// ====
// compileViaYul: also
// ----
// x() -> 0
// f(bool): true ->
// x() -> 1
// f(bool): false -> FAILURE, hex"85208890", hex"0000000000000000000000000000000000000000000000000000000000000002", hex"0000000000000000000000000000000000000000000000000000000000000007"
// x() -> 1
@@ -0,0 +1,12 @@
error E(string a, uint[] b);
contract C {
uint[] x;
function f() public {
x.push(7);
revert(E("abc", x));
}
}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE, hex"59e4d4df", 0x40, 0x80, 3, "abc", 1, 7
@@ -0,0 +1,10 @@
error E(uint a, uint b);
contract C {
function f() public pure {
revert(E(2, 7));
}
}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE, hex"85208890", 2, 7
@@ -0,0 +1,11 @@
error E(uint a, uint b);
contract C {
function f(bool c) public pure {
require(c, E(2, 7));
}
}
// ====
// compileViaYul: also
// ----
// f(bool): true ->
// f(bool): false -> FAILURE, hex"85208890", hex"0000000000000000000000000000000000000000000000000000000000000002", hex"0000000000000000000000000000000000000000000000000000000000000007"