diff --git a/test/libsolidity/syntaxTests/errors/abi_decode_error.sol b/test/libsolidity/syntaxTests/errors/abi_decode_error.sol new file mode 100644 index 000000000..72b661b6f --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/abi_decode_error.sol @@ -0,0 +1,9 @@ +error E(uint); +contract C { + function f() public pure returns (bytes memory) { + return abi.decode(msg.data, (E)); + } +} +// ---- +// TypeError 1039: (119-120): Argument has to be a type name. +// TypeError 5132: (90-122): Different number of arguments in return statement than in returns declaration. diff --git a/test/libsolidity/syntaxTests/errors/abi_encode_error.sol b/test/libsolidity/syntaxTests/errors/abi_encode_error.sol new file mode 100644 index 000000000..55b4d73df --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/abi_encode_error.sol @@ -0,0 +1,8 @@ +error E(uint); +contract C { + function f() public pure returns (bytes memory) { + return abi.encode(E); + } +} +// ---- +// TypeError 2056: (108-109): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/errors/abi_encode_error_instance.sol b/test/libsolidity/syntaxTests/errors/abi_encode_error_instance.sol new file mode 100644 index 000000000..fbc8b97f1 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/abi_encode_error_instance.sol @@ -0,0 +1,8 @@ +error E(uint); +contract C { + function f() public pure returns (bytes memory) { + return abi.encode(E(2)); + } +} +// ---- +// TypeError 2056: (108-112): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/errors/assert_with_cond_and_error.sol b/test/libsolidity/syntaxTests/errors/assert_with_cond_and_error.sol new file mode 100644 index 000000000..45ac6bfa1 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/assert_with_cond_and_error.sol @@ -0,0 +1,6 @@ +error E(); +function f(bool x) pure { + assert(x, E()); +} +// ---- +// TypeError 6160: (41-55): Wrong argument count for function call: 2 arguments given but expected 1. diff --git a/test/libsolidity/syntaxTests/errors/assert_with_error.sol b/test/libsolidity/syntaxTests/errors/assert_with_error.sol new file mode 100644 index 000000000..90f79b40e --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/assert_with_error.sol @@ -0,0 +1,6 @@ +error E(); +function f() pure { + assert(E()); +} +// ---- +// TypeError 9553: (42-45): Invalid type for argument in function call. Invalid implicit conversion from tuple() to bool requested. diff --git a/test/libsolidity/syntaxTests/errors/basic_usage_parethesized.sol b/test/libsolidity/syntaxTests/errors/basic_usage_parethesized.sol index f8bd7e698..b37c6407d 100644 --- a/test/libsolidity/syntaxTests/errors/basic_usage_parethesized.sol +++ b/test/libsolidity/syntaxTests/errors/basic_usage_parethesized.sol @@ -8,6 +8,6 @@ function g() pure { } // ---- // TypeError 6473: (43-46): Tuple component cannot be empty. -// TypeError 4423: (42-47): Expected error or string. +// TypeError 4423: (42-47): Expected error instance or string. // TypeError 6473: (100-103): Tuple component cannot be empty. -// TypeError 4423: (99-104): Expected error or string. +// TypeError 4423: (99-104): Expected error instance or string. diff --git a/test/libsolidity/syntaxTests/errors/error_address_payable.sol b/test/libsolidity/syntaxTests/errors/error_address_payable.sol new file mode 100644 index 000000000..3e983e374 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_address_payable.sol @@ -0,0 +1,2 @@ +error E(address payable x); +// ---- diff --git a/test/libsolidity/syntaxTests/errors/error_as_function_param.sol b/test/libsolidity/syntaxTests/errors/error_as_function_param.sol new file mode 100644 index 000000000..3741687f6 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_as_function_param.sol @@ -0,0 +1,4 @@ +error E(uint); +function f(E x) pure returns (uint) {} +// ---- +// TypeError 5172: (26-27): Name has to refer to a struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/errors/error_in_interface.sol b/test/libsolidity/syntaxTests/errors/error_in_interface.sol new file mode 100644 index 000000000..3f0f89b61 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_in_interface.sol @@ -0,0 +1,4 @@ +interface C { + error E(uint); +} +// ---- diff --git a/test/libsolidity/syntaxTests/errors/error_in_library.sol b/test/libsolidity/syntaxTests/errors/error_in_library.sol new file mode 100644 index 000000000..1be9718b0 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_in_library.sol @@ -0,0 +1,4 @@ +library L { + error E(uint); +} +// ---- diff --git a/test/libsolidity/syntaxTests/errors/error_location_memory.sol b/test/libsolidity/syntaxTests/errors/error_location_memory.sol new file mode 100644 index 000000000..c40d8dfc2 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_location_memory.sol @@ -0,0 +1,3 @@ +error E(uint[] memory); +// ---- +// ParserError 2314: (15-21): Expected ',' but got 'memory' diff --git a/test/libsolidity/syntaxTests/errors/error_location_specifier.sol b/test/libsolidity/syntaxTests/errors/error_location_specifier.sol new file mode 100644 index 000000000..5f5bdc2bb --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_location_specifier.sol @@ -0,0 +1,3 @@ +error E(uint[] calldata); +// ---- +// ParserError 2314: (15-23): Expected ',' but got 'calldata' diff --git a/test/libsolidity/syntaxTests/errors/error_reserved_name.sol b/test/libsolidity/syntaxTests/errors/error_reserved_name.sol index 8d69460d7..fc89efc18 100644 --- a/test/libsolidity/syntaxTests/errors/error_reserved_name.sol +++ b/test/libsolidity/syntaxTests/errors/error_reserved_name.sol @@ -1,3 +1,3 @@ error Error(uint); // ---- -// SyntaxError 1855: (44-62): The built-in errors "Error" and "Panic" cannot be re-defined. +// SyntaxError 1855: (0-18): The built-in errors "Error" and "Panic" cannot be re-defined. diff --git a/test/libsolidity/syntaxTests/errors/hash_collision.sol b/test/libsolidity/syntaxTests/errors/hash_collision.sol new file mode 100644 index 000000000..37b95c822 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/hash_collision.sol @@ -0,0 +1,6 @@ +contract test { + error gsf(); + error tgeo(); +} +// ---- +// TypeError 4883: (0-52): Error signature hash collision for tgeo() diff --git a/test/libsolidity/syntaxTests/errors/indexed_error.sol b/test/libsolidity/syntaxTests/errors/indexed_error.sol new file mode 100644 index 000000000..2efa3d70d --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/indexed_error.sol @@ -0,0 +1,3 @@ +error E(uint indexed); +// ---- +// ParserError 2314: (13-20): Expected ',' but got 'indexed' diff --git a/test/libsolidity/syntaxTests/errors/name_parenthesized.sol b/test/libsolidity/syntaxTests/errors/name_parenthesized.sol index 58034e7f6..dad64e855 100644 --- a/test/libsolidity/syntaxTests/errors/name_parenthesized.sol +++ b/test/libsolidity/syntaxTests/errors/name_parenthesized.sol @@ -3,4 +3,4 @@ function f() pure { revert((E)()); } // ---- -// TypeError 4423: (42-47): Expected error or string. +// TypeError 4423: (42-47): Expected error instance or string. diff --git a/test/libsolidity/syntaxTests/errors/nested_invocation3.sol b/test/libsolidity/syntaxTests/errors/nested_invocation3.sol index d966bf1ce..6221e43c4 100644 --- a/test/libsolidity/syntaxTests/errors/nested_invocation3.sol +++ b/test/libsolidity/syntaxTests/errors/nested_invocation3.sol @@ -1,7 +1,7 @@ -error E1(uint); +error E1(); error E2(); function f() pure { - revert(E1(E2)); + revert(E1(E2())); } // ---- -// TypeError 9553: (62-64): Invalid type for argument in function call. Invalid implicit conversion from function () pure to uint256 requested. +// TypeError 6160: (55-63): Wrong argument count for function call: 1 arguments given but expected 0. diff --git a/test/libsolidity/syntaxTests/errors/panic_reserved_name.sol b/test/libsolidity/syntaxTests/errors/panic_reserved_name.sol index f269c931a..c6f3dd1af 100644 --- a/test/libsolidity/syntaxTests/errors/panic_reserved_name.sol +++ b/test/libsolidity/syntaxTests/errors/panic_reserved_name.sol @@ -1,5 +1,3 @@ -// TODO: What if an error is imported and alias as Panic? -// TODO I Think the best way would be to have Error in the global scope. error Panic(bytes2); // ---- -// SyntaxError 1855: (131-151): The built-in errors "Error" and "Panic" cannot be re-defined. +// SyntaxError 1855: (0-20): The built-in errors "Error" and "Panic" cannot be re-defined. diff --git a/test/libsolidity/syntaxTests/errors/use_without_parentheses.sol b/test/libsolidity/syntaxTests/errors/use_without_parentheses.sol index 787257cde..94c2c91fb 100644 --- a/test/libsolidity/syntaxTests/errors/use_without_parentheses.sol +++ b/test/libsolidity/syntaxTests/errors/use_without_parentheses.sol @@ -4,4 +4,4 @@ function f() pure { revert(E1); } // ---- -// TypeError 4423: (55-57): Expected error or string. +// TypeError 4423: (55-57): Expected error instance or string. Did you forget the "()" after the error? diff --git a/test/libsolidity/syntaxTests/errors/weird1.sol b/test/libsolidity/syntaxTests/errors/weird1.sol new file mode 100644 index 000000000..b57f34c22 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/weird1.sol @@ -0,0 +1,7 @@ +error E(); + +contract C { + function() internal pure x = E; +} +// ---- +// TypeError 7407: (58-59): Type function () pure is not implicitly convertible to expected type function () pure. Special functions can not be converted to function types. diff --git a/test/libsolidity/syntaxTests/errors/weird2.sol b/test/libsolidity/syntaxTests/errors/weird2.sol new file mode 100644 index 000000000..2e93df819 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/weird2.sol @@ -0,0 +1,7 @@ +error E(); + +contract C { + bytes4 t = E.selector; +} +// ---- +// TypeError 9582: (40-50): Member "selector" not found or not visible after argument-dependent lookup in function () pure. diff --git a/test/libsolidity/syntaxTests/errors/weird3.sol b/test/libsolidity/syntaxTests/errors/weird3.sol new file mode 100644 index 000000000..c81266969 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/weird3.sol @@ -0,0 +1,7 @@ +error E(); + +contract C { + E x; +} +// ---- +// TypeError 5172: (29-30): Name has to refer to a struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/errors/weird4.sol b/test/libsolidity/syntaxTests/errors/weird4.sol new file mode 100644 index 000000000..be1ef90b6 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/weird4.sol @@ -0,0 +1,9 @@ +error E(); + +contract C { + function f() public pure { + E x; + } +} +// ---- +// TypeError 5172: (64-65): Name has to refer to a struct, enum or contract.