mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Display human readable type name in conversion error message
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
interface MyInterface {
|
||||
error MyCustomError(uint256, bool);
|
||||
}
|
||||
|
||||
contract Test {
|
||||
function test() public returns(bytes4) {
|
||||
return bytes4(MyInterface.MyCustomError);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9640: (143-176): Explicit type conversion not allowed from "error MyCustomError(uint256,bool)" to "bytes4".
|
||||
@@ -0,0 +1,9 @@
|
||||
contract Test {
|
||||
event MyCustomEvent(uint256);
|
||||
|
||||
function test() public returns(bytes4) {
|
||||
return bytes4(MyCustomEvent);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9640: (111-132): Explicit type conversion not allowed from "event MyCustomEvent(uint256)" to "bytes4".
|
||||
@@ -0,0 +1,28 @@
|
||||
interface MyInterface {
|
||||
enum MyEnum { E1, E2 }
|
||||
error CustomError1(
|
||||
uint256,
|
||||
bool,
|
||||
bool[],
|
||||
address payable,
|
||||
MyInterface,
|
||||
MyEnum,
|
||||
function (string memory) external returns (uint)
|
||||
);
|
||||
}
|
||||
|
||||
contract Test {
|
||||
function testFunction(string memory) external returns (uint) {}
|
||||
|
||||
function test() public {
|
||||
MyInterface instance = MyInterface(msg.sender);
|
||||
bool[] calldata arr;
|
||||
address payable addr;
|
||||
bytes4(MyInterface.CustomEror1);
|
||||
bytes4(MyInterface.CustomError1());
|
||||
bytes4(MyInterface.CustomError1(1, true, arr, addr, instance, MyInterface.MyEnum.E1, this.testFunction));
|
||||
address(MyInterface.CustomError1);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9582: (495-518): Member "CustomEror1" not found or not visible after argument-dependent lookup in type(contract MyInterface).
|
||||
@@ -0,0 +1,34 @@
|
||||
interface MyInterface {
|
||||
enum MyEnum { E1, E2 }
|
||||
}
|
||||
|
||||
contract Test {
|
||||
function testFunction(string memory) external returns (uint) {}
|
||||
|
||||
event CustomEvent1(
|
||||
uint256,
|
||||
bool,
|
||||
bool[],
|
||||
address payable,
|
||||
MyInterface,
|
||||
MyInterface.MyEnum,
|
||||
function (string memory) external returns (uint)
|
||||
);
|
||||
|
||||
|
||||
function test() public {
|
||||
MyInterface instance = MyInterface(msg.sender);
|
||||
bool[] calldata arr;
|
||||
address payable addr;
|
||||
bytes4(CustomEvent1);
|
||||
bytes4(CustomEvent1());
|
||||
bytes4(CustomEvent1(1, true, arr, addr, instance, MyInterface.MyEnum.E1, this.testFunction));
|
||||
address(CustomEvent1);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9640: (502-522): Explicit type conversion not allowed from "event CustomEvent1(uint256,bool,bool[],address payable,contract MyInterface,enum MyInterface.MyEnum,function (string) external returns (uint256))" to "bytes4".
|
||||
// TypeError 6160: (539-553): Wrong argument count for function call: 0 arguments given but expected 7.
|
||||
// TypeError 9640: (532-554): Explicit type conversion not allowed from "tuple()" to "bytes4".
|
||||
// TypeError 9640: (564-656): Explicit type conversion not allowed from "tuple()" to "bytes4".
|
||||
// TypeError 9640: (666-687): Explicit type conversion not allowed from "event CustomEvent1(uint256,bool,bool[],address payable,contract MyInterface,enum MyInterface.MyEnum,function (string) external returns (uint256))" to "address".
|
||||
Reference in New Issue
Block a user