fixup! Syntax changes for catching custom errors.

This commit is contained in:
chriseth
2021-02-02 17:05:49 +01:00
parent b6183edd18
commit 6fd0cf547e
10 changed files with 142 additions and 13 deletions
@@ -0,0 +1,14 @@
contract C {
error E();
function f() public {
try this.f() {
} catch E() {
}
}
}
// ====
// EVMVersion: >=byzantium
// ----
// UnimplementedFeatureError: NONE
@@ -0,0 +1,18 @@
==== Source: A ====
error E(uint);
==== Source: B ====
import {E as Error} from "A";
contract C {
function f() public {
try this.f() {
} catch Error(uint x) {
}
}
}
// ====
// EVMVersion: >=byzantium
// ----
// TypeError 2943: (B:104-136): Expected `catch Error(string memory ...) { ... }`.
@@ -0,0 +1,18 @@
==== Source: A ====
error E(uint);
==== Source: B ====
import "A" as Error;
contract C {
function f() public {
try this.f() {
} catch Error.E(uint x) {
}
}
}
// ====
// EVMVersion: >=byzantium
// ----
// ParserError 2314: (B:106-107): Expected '(' but got '.'
@@ -0,0 +1,14 @@
contract C {
error E();
function f() public returns (uint, uint) {
try this.f() {
} catch E {
}
}
}
// ====
// EVMVersion: >=byzantium
// ----
// ParserError 2314: (117-118): Expected '(' but got '{'
@@ -0,0 +1,19 @@
==== Source: A ====
error E(uint);
==== Source: B ====
import "A" as X;
contract C {
function f() public {
try this.f() {
} catch X.E(uint x) {
}
}
}
// ====
// EVMVersion: >=byzantium
// ----
// UnimplementedFeatureError: NONE
// Warning 5667: (B:101-107): Unused try/catch parameter. Remove or comment out the variable name to silence this warning.
@@ -0,0 +1,14 @@
contract C {
error E(uint x);
function f() public returns (uint, uint) {
try this.f() {
} catch E() {
}
}
}
// ====
// EVMVersion: >=byzantium
// ----
// TypeError 4873: (115-137): Expected 1 parameters for error "E" but got 0.
@@ -0,0 +1,14 @@
contract C {
error E();
function f() public returns (uint, uint) {
try this.f() {
} catch E(uint a) {
}
}
}
// ====
// EVMVersion: >=byzantium
// ----
// TypeError 4873: (109-137): Expected 0 parameters for error "E" but got 1.
@@ -0,0 +1,15 @@
contract C {
error E(uint a, uint8 b);
function f() public returns (uint, uint) {
try this.f() {
} catch E(uint8 x, uint y) {
}
}
}
// ====
// EVMVersion: >=byzantium
// ----
// TypeError 63958: (132-139): Expected a parameter of type "uint256" but got "uint8"
// TypeError 63958: (141-147): Expected a parameter of type "uint8" but got "uint256"
@@ -8,4 +8,4 @@ contract C {
}
}
// ----
// ParserError 3546: (101-102): Expected type name
// TypeError 6231: (94-115): Expected `catch (bytes memory ...) { ... }` or `catch { ... }`.