From 484ee8a62162680acea3fbc37ab2a8eadc5758dd Mon Sep 17 00:00:00 2001 From: vlad Date: Thu, 29 Dec 2022 23:43:12 +0400 Subject: [PATCH] Additional tests for edge cases for mutability, visibility, location, experimental, global, indexed and anonymous --- .../file_level_multiple_constant_keywords.sol | 4 + ...ddress_state_mutability_error_argument.sol | 85 +++++++++ .../errors/invalid_parameter_indexed.sol | 5 + .../errors/invalid_parameter_location.sol | 16 ++ .../errors/invalid_parameter_mutability.sol | 7 + .../errors/invalid_parameter_visibility.sol | 21 +++ ...us_event_multiple_anonymous_specifiers.sol | 5 + ...ddress_state_mutability_event_argument.sol | 85 +++++++++ ...ent_multiple_indexed_of_one_parameter.sol} | 0 .../events/invalid_parameter_location.sol | 16 ++ .../events/invalid_parameter_mutability.sol | 7 + .../events/invalid_parameter_visibility.sol | 21 +++ ...ess_state_mutability_modifier_argument.sol | 85 +++++++++ .../invalid_parameter_mutability.sol | 7 + .../invalid_parameter_visibility.sol | 21 +++ .../modifiers/multiple_parameter_location.sol | 21 +++ .../address_invalid_state_mutability.sol | 70 +++++--- ...ary_non_address_payable_state_variable.sol | 29 ---- ...lementary_non_address_payable_argument.sol | 29 ---- .../elementary_non_address_payable_local.sol | 31 ---- .../elementary_non_address_payable_return.sol | 29 ---- ..._non_address_state_mutability_argument.sol | 85 +++++++++ ..._non_address_state_mutability_file_var.sol | 81 +++++++++ ...ary_non_address_state_mutability_local.sol | 91 ++++++++++ ...ry_non_address_state_mutability_return.sol | 85 +++++++++ ...ddress_state_mutability_state_variable.sol | 85 +++++++++ ...ction_parameter_and_return_var_indexed.sol | 11 ++ ...on_parameter_and_return_var_mutability.sol | 9 + .../invalid_state_variable_location.sol | 11 ++ .../parsing/invalid_variable_indexed.sol | 16 ++ .../parsing/invalid_variable_mutablity.sol | 15 ++ ...location_specifiers_for_file_level_var.sol | 10 ++ ...cation_specifiers_for_fn_returns_multi.sol | 21 +++ .../location_specifiers_for_locals_multi.sol | 16 ++ .../location_specifiers_for_params_multi.sol | 14 ++ ...n_specifiers_for_state_variables_multi.sol | 8 +- .../multiple_mutability_specifiers.sol | 11 ++ .../multiple_state_mutability_specifiers.sol | 103 +++++++++++ .../multiple_statemutability_specifiers.sol | 29 ---- .../multiple_visibility_specifiers.sol | 7 - .../syntaxTests/parsing/payable_accessor.sol | 5 - .../experimental_multiple_experimental.sol | 4 + ...ary_non_address_state_mutability_catch.sol | 31 ++++ ...n_address_state_mutability_try_returns.sol | 163 ++++++++++++++++++ ...alid_catch_parameter_location_calldata.sol | 7 + ...valid_catch_parameter_location_storage.sol | 7 + .../tryCatch/invalid_returns_var_location.sol | 7 + ...turns_vars_and_catch_parameter_indexed.sol | 27 +++ ...ns_vars_and_catch_parameter_mutability.sol | 30 ++++ ...ns_vars_and_catch_parameter_visibility.sol | 105 +++++++++++ ...urns_vars_and_catch_parameter_location.sol | 132 ++++++++++++++ .../using/global_multiple_global_keywords.sol | 5 + .../file_level_variable_visibility.sol | 13 ++ ...on_parameter_and_return_var_visibility.sol | 41 +++++ .../invalid_variable_visibility.sol | 29 ++++ .../multiple_visibility_specifiers.sol | 53 ++++++ ...ultiple_visibility_specifiers_external.sol | 16 ++ 57 files changed, 1794 insertions(+), 183 deletions(-) create mode 100644 test/libsolidity/syntaxTests/constants/file_level_multiple_constant_keywords.sol create mode 100644 test/libsolidity/syntaxTests/errors/elementary_non_address_state_mutability_error_argument.sol create mode 100644 test/libsolidity/syntaxTests/errors/invalid_parameter_indexed.sol create mode 100644 test/libsolidity/syntaxTests/errors/invalid_parameter_location.sol create mode 100644 test/libsolidity/syntaxTests/errors/invalid_parameter_mutability.sol create mode 100644 test/libsolidity/syntaxTests/errors/invalid_parameter_visibility.sol create mode 100644 test/libsolidity/syntaxTests/events/anonymous_event_multiple_anonymous_specifiers.sol create mode 100644 test/libsolidity/syntaxTests/events/elementary_non_address_state_mutability_event_argument.sol rename test/libsolidity/syntaxTests/events/{event_several_indexed_of_one_parameter.sol => event_multiple_indexed_of_one_parameter.sol} (100%) create mode 100644 test/libsolidity/syntaxTests/events/invalid_parameter_location.sol create mode 100644 test/libsolidity/syntaxTests/events/invalid_parameter_mutability.sol create mode 100644 test/libsolidity/syntaxTests/events/invalid_parameter_visibility.sol create mode 100644 test/libsolidity/syntaxTests/modifiers/elementary_non_address_state_mutability_modifier_argument.sol create mode 100644 test/libsolidity/syntaxTests/modifiers/invalid_parameter_mutability.sol create mode 100644 test/libsolidity/syntaxTests/modifiers/invalid_parameter_visibility.sol create mode 100644 test/libsolidity/syntaxTests/modifiers/multiple_parameter_location.sol delete mode 100644 test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol delete mode 100644 test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol delete mode 100644 test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol delete mode 100644 test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol create mode 100644 test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_argument.sol create mode 100644 test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_file_var.sol create mode 100644 test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_local.sol create mode 100644 test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_return.sol create mode 100644 test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_state_variable.sol create mode 100644 test/libsolidity/syntaxTests/parsing/invalid_function_parameter_and_return_var_indexed.sol create mode 100644 test/libsolidity/syntaxTests/parsing/invalid_function_parameter_and_return_var_mutability.sol create mode 100644 test/libsolidity/syntaxTests/parsing/invalid_state_variable_location.sol create mode 100644 test/libsolidity/syntaxTests/parsing/invalid_variable_indexed.sol create mode 100644 test/libsolidity/syntaxTests/parsing/invalid_variable_mutablity.sol create mode 100644 test/libsolidity/syntaxTests/parsing/location_specifiers_for_file_level_var.sol create mode 100644 test/libsolidity/syntaxTests/parsing/location_specifiers_for_fn_returns_multi.sol create mode 100644 test/libsolidity/syntaxTests/parsing/multiple_mutability_specifiers.sol create mode 100644 test/libsolidity/syntaxTests/parsing/multiple_state_mutability_specifiers.sol delete mode 100644 test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol delete mode 100644 test/libsolidity/syntaxTests/parsing/multiple_visibility_specifiers.sol delete mode 100644 test/libsolidity/syntaxTests/parsing/payable_accessor.sol create mode 100644 test/libsolidity/syntaxTests/pragma/experimental_multiple_experimental.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/elementary_non_address_state_mutability_catch.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/elementary_non_address_state_mutability_try_returns.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/invalid_catch_parameter_location_calldata.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/invalid_catch_parameter_location_storage.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/invalid_returns_var_location.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_indexed.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_mutability.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_visibility.sol create mode 100644 test/libsolidity/syntaxTests/tryCatch/multiple_returns_vars_and_catch_parameter_location.sol create mode 100644 test/libsolidity/syntaxTests/using/global_multiple_global_keywords.sol create mode 100644 test/libsolidity/syntaxTests/visibility/file_level_variable_visibility.sol create mode 100644 test/libsolidity/syntaxTests/visibility/invalid_function_parameter_and_return_var_visibility.sol create mode 100644 test/libsolidity/syntaxTests/visibility/invalid_variable_visibility.sol create mode 100644 test/libsolidity/syntaxTests/visibility/multiple_visibility_specifiers.sol create mode 100644 test/libsolidity/syntaxTests/visibility/multiple_visibility_specifiers_external.sol diff --git a/test/libsolidity/syntaxTests/constants/file_level_multiple_constant_keywords.sol b/test/libsolidity/syntaxTests/constants/file_level_multiple_constant_keywords.sol new file mode 100644 index 000000000..1ca07c660 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/file_level_multiple_constant_keywords.sol @@ -0,0 +1,4 @@ +uint constant constant x; +// ---- +// ParserError 3109: (14-22): Mutability already set to "constant" + diff --git a/test/libsolidity/syntaxTests/errors/elementary_non_address_state_mutability_error_argument.sol b/test/libsolidity/syntaxTests/errors/elementary_non_address_state_mutability_error_argument.sol new file mode 100644 index 000000000..110af7e34 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/elementary_non_address_state_mutability_error_argument.sol @@ -0,0 +1,85 @@ +contract C { + error a(bool payable); + error b(string payable); + error c(int payable); + error d(int256 payable); + error e(uint payable); + error f(uint256 payable); + error g(bytes1 payable); + error h(bytes payable); + error i(bytes32 payable); + error j(fixed payable); + error k(fixed80x80 payable); + error l(ufixed payable); + error m(ufixed80x80 payable); +} +contract C2 { + error a(bool view); + error b(string view); + error c(int view); + error d(int256 view); + error e(uint view); + error f(uint256 view); + error g(bytes1 view); + error h(bytes view); + error i(bytes32 view); + error j(fixed view); + error k(fixed80x80 view); + error l(ufixed view); + error m(ufixed80x80 view); +} +contract C3 { + error a(bool pure); + error b(string pure); + error c(int pure); + error d(int256 pure); + error e(uint pure); + error f(uint256 pure); + error g(bytes1 pure); + error h(bytes pure); + error i(bytes32 pure); + error j(fixed pure); + error k(fixed80x80 pure); + error l(ufixed pure); + error m(ufixed80x80 pure); +} +// ---- +// ParserError 9106: (30-37): State mutability can only be specified for address types. +// ParserError 9106: (59-66): State mutability can only be specified for address types. +// ParserError 9106: (85-92): State mutability can only be specified for address types. +// ParserError 9106: (114-121): State mutability can only be specified for address types. +// ParserError 9106: (141-148): State mutability can only be specified for address types. +// ParserError 9106: (171-178): State mutability can only be specified for address types. +// ParserError 9106: (200-207): State mutability can only be specified for address types. +// ParserError 9106: (228-235): State mutability can only be specified for address types. +// ParserError 9106: (258-265): State mutability can only be specified for address types. +// ParserError 9106: (286-293): State mutability can only be specified for address types. +// ParserError 9106: (319-326): State mutability can only be specified for address types. +// ParserError 9106: (348-355): State mutability can only be specified for address types. +// ParserError 9106: (382-389): State mutability can only be specified for address types. +// ParserError 9106: (425-429): State mutability can only be specified for address types. +// ParserError 9106: (451-455): State mutability can only be specified for address types. +// ParserError 9106: (474-478): State mutability can only be specified for address types. +// ParserError 9106: (500-504): State mutability can only be specified for address types. +// ParserError 9106: (524-528): State mutability can only be specified for address types. +// ParserError 9106: (551-555): State mutability can only be specified for address types. +// ParserError 9106: (577-581): State mutability can only be specified for address types. +// ParserError 9106: (602-606): State mutability can only be specified for address types. +// ParserError 9106: (629-633): State mutability can only be specified for address types. +// ParserError 9106: (654-658): State mutability can only be specified for address types. +// ParserError 9106: (684-688): State mutability can only be specified for address types. +// ParserError 9106: (710-714): State mutability can only be specified for address types. +// ParserError 9106: (741-745): State mutability can only be specified for address types. +// ParserError 9106: (781-785): State mutability can only be specified for address types. +// ParserError 9106: (807-811): State mutability can only be specified for address types. +// ParserError 9106: (830-834): State mutability can only be specified for address types. +// ParserError 9106: (856-860): State mutability can only be specified for address types. +// ParserError 9106: (880-884): State mutability can only be specified for address types. +// ParserError 9106: (907-911): State mutability can only be specified for address types. +// ParserError 9106: (933-937): State mutability can only be specified for address types. +// ParserError 9106: (958-962): State mutability can only be specified for address types. +// ParserError 9106: (985-989): State mutability can only be specified for address types. +// ParserError 9106: (1010-1014): State mutability can only be specified for address types. +// ParserError 9106: (1040-1044): State mutability can only be specified for address types. +// ParserError 9106: (1066-1070): State mutability can only be specified for address types. +// ParserError 9106: (1097-1101): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/errors/invalid_parameter_indexed.sol b/test/libsolidity/syntaxTests/errors/invalid_parameter_indexed.sol new file mode 100644 index 000000000..99b629cd3 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/invalid_parameter_indexed.sol @@ -0,0 +1,5 @@ +contract C { + error e1(uint indexed x); +} +// ---- +// ParserError 2314: (31-38): Expected ',' but got 'indexed' \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/errors/invalid_parameter_location.sol b/test/libsolidity/syntaxTests/errors/invalid_parameter_location.sol new file mode 100644 index 000000000..a116188d2 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/invalid_parameter_location.sol @@ -0,0 +1,16 @@ +==== Source: A ==== +contract test { + error e1(string storage a); +} +==== Source: B ==== +contract test { + error e1(string memory a); +} +==== Source: C ==== +contract test { + error e1(string calldata a); +} +// ---- +// ParserError 2314: (A:36-43): Expected ',' but got 'storage' +// ParserError 2314: (B:36-42): Expected ',' but got 'memory' +// ParserError 2314: (C:36-44): Expected ',' but got 'calldata' diff --git a/test/libsolidity/syntaxTests/errors/invalid_parameter_mutability.sol b/test/libsolidity/syntaxTests/errors/invalid_parameter_mutability.sol new file mode 100644 index 000000000..fc5b4609b --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/invalid_parameter_mutability.sol @@ -0,0 +1,7 @@ +contract C { + error e1(uint constant x); + error e2(uint immutable x); +} +// ---- +// DeclarationError 1788: (26-41): The "constant" keyword can only be used for state variables or variables at file level. +// DeclarationError 8297: (57-73): The "immutable" keyword can only be used for state variables. diff --git a/test/libsolidity/syntaxTests/errors/invalid_parameter_visibility.sol b/test/libsolidity/syntaxTests/errors/invalid_parameter_visibility.sol new file mode 100644 index 000000000..c35e759df --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/invalid_parameter_visibility.sol @@ -0,0 +1,21 @@ +==== Source: A ==== +contract C { + error e1(uint external x); +} +==== Source: B ==== +contract C { + error e1(uint internal x); +} +==== Source: C ==== +contract C { + error e1(uint public x); +} +==== Source: D ==== +contract C { + error e1(uint private x); +} +// ---- +// ParserError 2314: (A:31-39): Expected ',' but got 'external' +// ParserError 2314: (B:31-39): Expected ',' but got 'internal' +// ParserError 2314: (C:31-37): Expected ',' but got 'public' +// ParserError 2314: (D:31-38): Expected ',' but got 'private' diff --git a/test/libsolidity/syntaxTests/events/anonymous_event_multiple_anonymous_specifiers.sol b/test/libsolidity/syntaxTests/events/anonymous_event_multiple_anonymous_specifiers.sol new file mode 100644 index 000000000..fd3e317b8 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/anonymous_event_multiple_anonymous_specifiers.sol @@ -0,0 +1,5 @@ +contract c { + event e(uint a) anonymous anonymous; +} +// ---- +// ParserError 2314: (43-52): Expected ';' but got 'anonymous' \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/events/elementary_non_address_state_mutability_event_argument.sol b/test/libsolidity/syntaxTests/events/elementary_non_address_state_mutability_event_argument.sol new file mode 100644 index 000000000..a3e08411b --- /dev/null +++ b/test/libsolidity/syntaxTests/events/elementary_non_address_state_mutability_event_argument.sol @@ -0,0 +1,85 @@ +contract C { + event a(bool payable); + event b(string payable); + event c(int payable); + event d(int256 payable); + event e(uint payable); + event f(uint256 payable); + event g(bytes1 payable); + event h(bytes payable); + event i(bytes32 payable); + event j(fixed payable); + event k(fixed80x80 payable); + event l(ufixed payable); + event m(ufixed80x80 payable); +} +contract C2 { + event a(bool view); + event b(string view); + event c(int view); + event d(int256 view); + event e(uint view); + event f(uint256 view); + event g(bytes1 view); + event h(bytes view); + event i(bytes32 view); + event j(fixed view); + event k(fixed80x80 view); + event l(ufixed view); + event m(ufixed80x80 view); +} +contract C3 { + event a(bool pure); + event b(string pure); + event c(int pure); + event d(int256 pure); + event e(uint pure); + event f(uint256 pure); + event g(bytes1 pure); + event h(bytes pure); + event i(bytes32 pure); + event j(fixed pure); + event k(fixed80x80 pure); + event l(ufixed pure); + event m(ufixed80x80 pure); +} +// ---- +// ParserError 9106: (30-37): State mutability can only be specified for address types. +// ParserError 9106: (59-66): State mutability can only be specified for address types. +// ParserError 9106: (85-92): State mutability can only be specified for address types. +// ParserError 9106: (114-121): State mutability can only be specified for address types. +// ParserError 9106: (141-148): State mutability can only be specified for address types. +// ParserError 9106: (171-178): State mutability can only be specified for address types. +// ParserError 9106: (200-207): State mutability can only be specified for address types. +// ParserError 9106: (228-235): State mutability can only be specified for address types. +// ParserError 9106: (258-265): State mutability can only be specified for address types. +// ParserError 9106: (286-293): State mutability can only be specified for address types. +// ParserError 9106: (319-326): State mutability can only be specified for address types. +// ParserError 9106: (348-355): State mutability can only be specified for address types. +// ParserError 9106: (382-389): State mutability can only be specified for address types. +// ParserError 9106: (425-429): State mutability can only be specified for address types. +// ParserError 9106: (451-455): State mutability can only be specified for address types. +// ParserError 9106: (474-478): State mutability can only be specified for address types. +// ParserError 9106: (500-504): State mutability can only be specified for address types. +// ParserError 9106: (524-528): State mutability can only be specified for address types. +// ParserError 9106: (551-555): State mutability can only be specified for address types. +// ParserError 9106: (577-581): State mutability can only be specified for address types. +// ParserError 9106: (602-606): State mutability can only be specified for address types. +// ParserError 9106: (629-633): State mutability can only be specified for address types. +// ParserError 9106: (654-658): State mutability can only be specified for address types. +// ParserError 9106: (684-688): State mutability can only be specified for address types. +// ParserError 9106: (710-714): State mutability can only be specified for address types. +// ParserError 9106: (741-745): State mutability can only be specified for address types. +// ParserError 9106: (781-785): State mutability can only be specified for address types. +// ParserError 9106: (807-811): State mutability can only be specified for address types. +// ParserError 9106: (830-834): State mutability can only be specified for address types. +// ParserError 9106: (856-860): State mutability can only be specified for address types. +// ParserError 9106: (880-884): State mutability can only be specified for address types. +// ParserError 9106: (907-911): State mutability can only be specified for address types. +// ParserError 9106: (933-937): State mutability can only be specified for address types. +// ParserError 9106: (958-962): State mutability can only be specified for address types. +// ParserError 9106: (985-989): State mutability can only be specified for address types. +// ParserError 9106: (1010-1014): State mutability can only be specified for address types. +// ParserError 9106: (1040-1044): State mutability can only be specified for address types. +// ParserError 9106: (1066-1070): State mutability can only be specified for address types. +// ParserError 9106: (1097-1101): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/events/event_several_indexed_of_one_parameter.sol b/test/libsolidity/syntaxTests/events/event_multiple_indexed_of_one_parameter.sol similarity index 100% rename from test/libsolidity/syntaxTests/events/event_several_indexed_of_one_parameter.sol rename to test/libsolidity/syntaxTests/events/event_multiple_indexed_of_one_parameter.sol diff --git a/test/libsolidity/syntaxTests/events/invalid_parameter_location.sol b/test/libsolidity/syntaxTests/events/invalid_parameter_location.sol new file mode 100644 index 000000000..04ee9b7bc --- /dev/null +++ b/test/libsolidity/syntaxTests/events/invalid_parameter_location.sol @@ -0,0 +1,16 @@ +==== Source: A ==== +contract test { + event e1(string storage a); +} +==== Source: B ==== +contract test { + event e1(string memory a); +} +==== Source: C ==== +contract test { + event e1(string calldata a); +} +// ---- +// ParserError 2314: (A:36-43): Expected ',' but got 'storage' +// ParserError 2314: (B:36-42): Expected ',' but got 'memory' +// ParserError 2314: (C:36-44): Expected ',' but got 'calldata' diff --git a/test/libsolidity/syntaxTests/events/invalid_parameter_mutability.sol b/test/libsolidity/syntaxTests/events/invalid_parameter_mutability.sol new file mode 100644 index 000000000..f7314e6f5 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/invalid_parameter_mutability.sol @@ -0,0 +1,7 @@ +contract test { + event e1(uint constant a); + event e2(uint immutable a); +} +// ---- +// DeclarationError 1788: (29-44): The "constant" keyword can only be used for state variables or variables at file level. +// DeclarationError 8297: (60-76): The "immutable" keyword can only be used for state variables. diff --git a/test/libsolidity/syntaxTests/events/invalid_parameter_visibility.sol b/test/libsolidity/syntaxTests/events/invalid_parameter_visibility.sol new file mode 100644 index 000000000..bcb6d4306 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/invalid_parameter_visibility.sol @@ -0,0 +1,21 @@ +==== Source: A ==== +contract test { + event e1(uint external a); +} +==== Source: B ==== +contract test { + event e1(uint internal a); +} +==== Source: C ==== +contract test { + event e1(uint public a); +} +==== Source: D ==== +contract test { + event e1(uint private a); +} +// ---- +// ParserError 2314: (A:34-42): Expected ',' but got 'external' +// ParserError 2314: (B:34-42): Expected ',' but got 'internal' +// ParserError 2314: (C:34-40): Expected ',' but got 'public' +// ParserError 2314: (D:34-41): Expected ',' but got 'private' diff --git a/test/libsolidity/syntaxTests/modifiers/elementary_non_address_state_mutability_modifier_argument.sol b/test/libsolidity/syntaxTests/modifiers/elementary_non_address_state_mutability_modifier_argument.sol new file mode 100644 index 000000000..568743b36 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/elementary_non_address_state_mutability_modifier_argument.sol @@ -0,0 +1,85 @@ +contract C { + modifier a(bool payable) {} + modifier b(string payable) {} + modifier c(int payable) {} + modifier d(int256 payable) {} + modifier e(uint payable) {} + modifier f(uint256 payable) {} + modifier g(bytes1 payable) {} + modifier h(bytes payable) {} + modifier i(bytes32 payable) {} + modifier j(fixed payable) {} + modifier k(fixed80x80 payable) {} + modifier l(ufixed payable) {} + modifier m(ufixed80x80 payable) {} +} +contract C2 { + modifier a(bool view) {} + modifier b(string view) {} + modifier c(int view) {} + modifier d(int256 view) {} + modifier e(uint view) {} + modifier f(uint256 view) {} + modifier g(bytes1 view) {} + modifier h(bytes view) {} + modifier i(bytes32 view) {} + modifier j(fixed view) {} + modifier k(fixed80x80 view) {} + modifier l(ufixed view) {} + modifier m(ufixed80x80 view) {} +} +contract C3 { + modifier a(bool pure) {} + modifier b(string pure) {} + modifier c(int pure) {} + modifier d(int256 pure) {} + modifier e(uint pure) {} + modifier f(uint256 pure) {} + modifier g(bytes1 pure) {} + modifier h(bytes pure) {} + modifier i(bytes32 pure) {} + modifier j(fixed pure) {} + modifier k(fixed80x80 pure) {} + modifier l(ufixed pure) {} + modifier m(ufixed80x80 pure) {} +} +// ---- +// ParserError 9106: (33-40): State mutability can only be specified for address types. +// ParserError 9106: (67-74): State mutability can only be specified for address types. +// ParserError 9106: (98-105): State mutability can only be specified for address types. +// ParserError 9106: (132-139): State mutability can only be specified for address types. +// ParserError 9106: (164-171): State mutability can only be specified for address types. +// ParserError 9106: (199-206): State mutability can only be specified for address types. +// ParserError 9106: (233-240): State mutability can only be specified for address types. +// ParserError 9106: (266-273): State mutability can only be specified for address types. +// ParserError 9106: (301-308): State mutability can only be specified for address types. +// ParserError 9106: (334-341): State mutability can only be specified for address types. +// ParserError 9106: (372-379): State mutability can only be specified for address types. +// ParserError 9106: (406-413): State mutability can only be specified for address types. +// ParserError 9106: (445-452): State mutability can only be specified for address types. +// ParserError 9106: (493-497): State mutability can only be specified for address types. +// ParserError 9106: (524-528): State mutability can only be specified for address types. +// ParserError 9106: (552-556): State mutability can only be specified for address types. +// ParserError 9106: (583-587): State mutability can only be specified for address types. +// ParserError 9106: (612-616): State mutability can only be specified for address types. +// ParserError 9106: (644-648): State mutability can only be specified for address types. +// ParserError 9106: (675-679): State mutability can only be specified for address types. +// ParserError 9106: (705-709): State mutability can only be specified for address types. +// ParserError 9106: (737-741): State mutability can only be specified for address types. +// ParserError 9106: (767-771): State mutability can only be specified for address types. +// ParserError 9106: (802-806): State mutability can only be specified for address types. +// ParserError 9106: (833-837): State mutability can only be specified for address types. +// ParserError 9106: (869-873): State mutability can only be specified for address types. +// ParserError 9106: (914-918): State mutability can only be specified for address types. +// ParserError 9106: (945-949): State mutability can only be specified for address types. +// ParserError 9106: (973-977): State mutability can only be specified for address types. +// ParserError 9106: (1004-1008): State mutability can only be specified for address types. +// ParserError 9106: (1033-1037): State mutability can only be specified for address types. +// ParserError 9106: (1065-1069): State mutability can only be specified for address types. +// ParserError 9106: (1096-1100): State mutability can only be specified for address types. +// ParserError 9106: (1126-1130): State mutability can only be specified for address types. +// ParserError 9106: (1158-1162): State mutability can only be specified for address types. +// ParserError 9106: (1188-1192): State mutability can only be specified for address types. +// ParserError 9106: (1223-1227): State mutability can only be specified for address types. +// ParserError 9106: (1254-1258): State mutability can only be specified for address types. +// ParserError 9106: (1290-1294): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/modifiers/invalid_parameter_mutability.sol b/test/libsolidity/syntaxTests/modifiers/invalid_parameter_mutability.sol new file mode 100644 index 000000000..f23861ebf --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/invalid_parameter_mutability.sol @@ -0,0 +1,7 @@ +contract A { + modifier mod1(uint constant a) { _; } + modifier mod2(uint immutable a) { _; } +} +// ---- +// DeclarationError 1788: (31-46): The "constant" keyword can only be used for state variables or variables at file level. +// DeclarationError 8297: (73-89): The "immutable" keyword can only be used for state variables. \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/modifiers/invalid_parameter_visibility.sol b/test/libsolidity/syntaxTests/modifiers/invalid_parameter_visibility.sol new file mode 100644 index 000000000..0ef9e5c05 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/invalid_parameter_visibility.sol @@ -0,0 +1,21 @@ +==== Source: A ==== +contract A { + modifier mod(uint internal a) { _; } +} +==== Source: B ==== +contract A { + modifier mod(uint external a) { _; } +} +==== Source: C ==== +contract A { + modifier mod(uint public a) { _; } +} +==== Source: D ==== +contract A { + modifier mod(uint private a) { _; } +} +// ---- +// ParserError 2314: (A:35-43): Expected ',' but got 'internal' +// ParserError 2314: (B:35-43): Expected ',' but got 'external' +// ParserError 2314: (C:35-41): Expected ',' but got 'public' +// ParserError 2314: (D:35-42): Expected ',' but got 'private' diff --git a/test/libsolidity/syntaxTests/modifiers/multiple_parameter_location.sol b/test/libsolidity/syntaxTests/modifiers/multiple_parameter_location.sol new file mode 100644 index 000000000..e264a593f --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/multiple_parameter_location.sol @@ -0,0 +1,21 @@ +contract A { + modifier mod1(string storage storage a) { _; } + modifier mod2(string storage memory a) { _; } + modifier mod3(string storage calldata a) { _; } + modifier mod4(string memory storage a) { _; } + modifier mod5(string memory memory a) { _; } + modifier mod6(string memory calldata a) { _; } + modifier mod7(string calldata storage a) { _; } + modifier mod8(string calldata memory a) { _; } + modifier mod9(string calldata calldata a) { _; } +} +// ---- +// ParserError 3548: (46-53): Location already specified. +// ParserError 3548: (97-103): Location already specified. +// ParserError 3548: (147-155): Location already specified. +// ParserError 3548: (198-205): Location already specified. +// ParserError 3548: (248-254): Location already specified. +// ParserError 3548: (297-305): Location already specified. +// ParserError 3548: (350-357): Location already specified. +// ParserError 3548: (402-408): Location already specified. +// ParserError 3548: (453-461): Location already specified. diff --git a/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol b/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol index 90968ebc6..2aa4dd344 100644 --- a/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol +++ b/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol @@ -1,26 +1,50 @@ contract C { - address view m_a; - address pure m_b; - address view[] m_c; - mapping(uint => address view) m_d; - function f() public pure { - address view a; - address pure b; - a; b; - } - function g(address view) public pure {} - function h(address pure) public pure {} - function i() public pure returns (address view) {} - function j() public pure returns (address pure) {} + address view m_a; + address pure m_b; + address view[] m_c; + mapping(uint => address view) m_d; + function f() public pure { + address view a; + address pure b; + a; b; + } + function g(address view) public pure {} + function h(address pure) public pure {} + function i() public pure returns (address view) {} + function j() public pure returns (address pure) {} + modifier m1(address view) {_;} + modifier m2(address pure) {_;} + event e1(address view); + event e2(address pure); + error err1(address view); + error err2(address pure); + function f2() public pure returns (address) { + try this.f2() returns (address view res) {} catch {} + } + function f3() public pure returns (address) { + try this.f3() returns (address pure res) {} catch {} + } } +address view constant f_a; +address pure constant f_b; // ---- -// TypeError 2311: (14-26): Address types can only be payable or non-payable. -// TypeError 2311: (33-45): Address types can only be payable or non-payable. -// TypeError 2311: (52-64): Address types can only be payable or non-payable. -// TypeError 2311: (89-101): Address types can only be payable or non-payable. -// TypeError 2311: (138-150): Address types can only be payable or non-payable. -// TypeError 2311: (156-168): Address types can only be payable or non-payable. -// TypeError 2311: (195-207): Address types can only be payable or non-payable. -// TypeError 2311: (236-248): Address types can only be payable or non-payable. -// TypeError 2311: (300-312): Address types can only be payable or non-payable. -// TypeError 2311: (352-364): Address types can only be payable or non-payable. +// TypeError 2311: (17-29): Address types can only be payable or non-payable. +// TypeError 2311: (39-51): Address types can only be payable or non-payable. +// TypeError 2311: (61-73): Address types can only be payable or non-payable. +// TypeError 2311: (101-113): Address types can only be payable or non-payable. +// TypeError 2311: (159-171): Address types can only be payable or non-payable. +// TypeError 2311: (183-195): Address types can only be payable or non-payable. +// TypeError 2311: (234-246): Address types can only be payable or non-payable. +// TypeError 2311: (278-290): Address types can only be payable or non-payable. +// TypeError 2311: (345-357): Address types can only be payable or non-payable. +// TypeError 2311: (400-412): Address types can only be payable or non-payable. +// TypeError 2311: (433-445): Address types can only be payable or non-payable. +// TypeError 2311: (468-480): Address types can only be payable or non-payable. +// TypeError 2311: (500-512): Address types can only be payable or non-payable. +// TypeError 2311: (528-540): Address types can only be payable or non-payable. +// TypeError 2311: (558-570): Address types can only be payable or non-payable. +// TypeError 2311: (588-600): Address types can only be payable or non-payable. +// TypeError 2311: (684-696): Address types can only be payable or non-payable. +// TypeError 2311: (801-813): Address types can only be payable or non-payable. +// TypeError 2311: (839-851): Address types can only be payable or non-payable. +// TypeError 2311: (866-878): Address types can only be payable or non-payable. diff --git a/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol b/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol deleted file mode 100644 index bc5db10ba..000000000 --- a/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol +++ /dev/null @@ -1,29 +0,0 @@ -contract C { - bool payable a; - string payable b; - int payable c; - int256 payable d; - uint payable e; - uint256 payable f; - bytes1 payable g; - bytes payable h; - bytes32 payable i; - fixed payable j; - fixed80x80 payable k; - ufixed payable l; - ufixed80x80 payable m; -} -// ---- -// ParserError 9106: (22-29): State mutability can only be specified for address types. -// ParserError 9106: (44-51): State mutability can only be specified for address types. -// ParserError 9106: (63-70): State mutability can only be specified for address types. -// ParserError 9106: (85-92): State mutability can only be specified for address types. -// ParserError 9106: (105-112): State mutability can only be specified for address types. -// ParserError 9106: (128-135): State mutability can only be specified for address types. -// ParserError 9106: (150-157): State mutability can only be specified for address types. -// ParserError 9106: (171-178): State mutability can only be specified for address types. -// ParserError 9106: (194-201): State mutability can only be specified for address types. -// ParserError 9106: (215-222): State mutability can only be specified for address types. -// ParserError 9106: (241-248): State mutability can only be specified for address types. -// ParserError 9106: (263-270): State mutability can only be specified for address types. -// ParserError 9106: (290-297): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol deleted file mode 100644 index 7d26f74c0..000000000 --- a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol +++ /dev/null @@ -1,29 +0,0 @@ -contract C { - function a(bool payable) public pure {} - function b(string payable) public pure {} - function c(int payable) public pure {} - function d(int256 payable) public pure {} - function e(uint payable) public pure {} - function f(uint256 payable) public pure {} - function g(bytes1 payable) public pure {} - function h(bytes payable) public pure {} - function i(bytes32 payable) public pure {} - function j(fixed payable) public pure {} - function k(fixed80x80 payable) public pure {} - function l(ufixed payable) public pure {} - function m(ufixed80x80 payable) public pure {} -} -// ---- -// ParserError 9106: (33-40): State mutability can only be specified for address types. -// ParserError 9106: (79-86): State mutability can only be specified for address types. -// ParserError 9106: (122-129): State mutability can only be specified for address types. -// ParserError 9106: (168-175): State mutability can only be specified for address types. -// ParserError 9106: (212-219): State mutability can only be specified for address types. -// ParserError 9106: (259-266): State mutability can only be specified for address types. -// ParserError 9106: (305-312): State mutability can only be specified for address types. -// ParserError 9106: (350-357): State mutability can only be specified for address types. -// ParserError 9106: (397-404): State mutability can only be specified for address types. -// ParserError 9106: (442-449): State mutability can only be specified for address types. -// ParserError 9106: (492-499): State mutability can only be specified for address types. -// ParserError 9106: (538-545): State mutability can only be specified for address types. -// ParserError 9106: (589-596): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol deleted file mode 100644 index 2aad9cd04..000000000 --- a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol +++ /dev/null @@ -1,31 +0,0 @@ -contract C { - function f() public pure { - bool payable a; - string payable b; - int payable c; - int256 payable d; - uint payable e; - uint256 payable f; - bytes1 payable g; - bytes payable h; - bytes32 payable i; - fixed payable j; - fixed80x80 payable k; - ufixed payable l; - ufixed80x80 payable m; - } -} -// ---- -// ParserError 9106: (57-64): State mutability can only be specified for address types. -// ParserError 9106: (83-90): State mutability can only be specified for address types. -// ParserError 9106: (106-113): State mutability can only be specified for address types. -// ParserError 9106: (132-139): State mutability can only be specified for address types. -// ParserError 9106: (156-163): State mutability can only be specified for address types. -// ParserError 9106: (183-190): State mutability can only be specified for address types. -// ParserError 9106: (209-216): State mutability can only be specified for address types. -// ParserError 9106: (234-241): State mutability can only be specified for address types. -// ParserError 9106: (261-268): State mutability can only be specified for address types. -// ParserError 9106: (286-293): State mutability can only be specified for address types. -// ParserError 9106: (316-323): State mutability can only be specified for address types. -// ParserError 9106: (342-349): State mutability can only be specified for address types. -// ParserError 9106: (373-380): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol deleted file mode 100644 index 026138cde..000000000 --- a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol +++ /dev/null @@ -1,29 +0,0 @@ -contract C { - function a() public pure returns (bool payable) {} - function b() public pure returns (string payable) {} - function c() public pure returns (int payable) {} - function d() public pure returns (int256 payable) {} - function e() public pure returns (uint payable) {} - function f() public pure returns (uint256 payable) {} - function g() public pure returns (bytes1 payable) {} - function h() public pure returns (bytes payable) {} - function i() public pure returns (bytes32 payable) {} - function j() public pure returns (fixed payable) {} - function k() public pure returns (fixed80x80 payable) {} - function l() public pure returns (ufixed payable) {} - function m() public pure returns (ufixed80x80 payable) {} -} -// ---- -// ParserError 9106: (56-63): State mutability can only be specified for address types. -// ParserError 9106: (113-120): State mutability can only be specified for address types. -// ParserError 9106: (167-174): State mutability can only be specified for address types. -// ParserError 9106: (224-231): State mutability can only be specified for address types. -// ParserError 9106: (279-286): State mutability can only be specified for address types. -// ParserError 9106: (337-344): State mutability can only be specified for address types. -// ParserError 9106: (394-401): State mutability can only be specified for address types. -// ParserError 9106: (450-457): State mutability can only be specified for address types. -// ParserError 9106: (508-515): State mutability can only be specified for address types. -// ParserError 9106: (564-571): State mutability can only be specified for address types. -// ParserError 9106: (625-632): State mutability can only be specified for address types. -// ParserError 9106: (682-689): State mutability can only be specified for address types. -// ParserError 9106: (744-751): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_argument.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_argument.sol new file mode 100644 index 000000000..aefb4748c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_argument.sol @@ -0,0 +1,85 @@ +contract C { + function a(bool payable) public pure {} + function b(string payable) public pure {} + function c(int payable) public pure {} + function d(int256 payable) public pure {} + function e(uint payable) public pure {} + function f(uint256 payable) public pure {} + function g(bytes1 payable) public pure {} + function h(bytes payable) public pure {} + function i(bytes32 payable) public pure {} + function j(fixed payable) public pure {} + function k(fixed80x80 payable) public pure {} + function l(ufixed payable) public pure {} + function m(ufixed80x80 payable) public pure {} +} +contract C1 { + function a(bool view) public pure {} + function b(string view) public pure {} + function c(int view) public pure {} + function d(int256 view) public pure {} + function e(uint view) public pure {} + function f(uint256 view) public pure {} + function g(bytes1 view) public pure {} + function h(bytes view) public pure {} + function i(bytes32 view) public pure {} + function j(fixed view) public pure {} + function k(fixed80x80 view) public pure {} + function l(ufixed view) public pure {} + function m(ufixed80x80 view) public pure {} +} +contract C2 { + function a(bool pure) public pure {} + function b(string pure) public pure {} + function c(int pure) public pure {} + function d(int256 pure) public pure {} + function e(uint pure) public pure {} + function f(uint256 pure) public pure {} + function g(bytes1 pure) public pure {} + function h(bytes pure) public pure {} + function i(bytes32 pure) public pure {} + function j(fixed pure) public pure {} + function k(fixed80x80 pure) public pure {} + function l(ufixed pure) public pure {} + function m(ufixed80x80 pure) public pure {} +} +// ---- +// ParserError 9106: (33-40): State mutability can only be specified for address types. +// ParserError 9106: (79-86): State mutability can only be specified for address types. +// ParserError 9106: (122-129): State mutability can only be specified for address types. +// ParserError 9106: (168-175): State mutability can only be specified for address types. +// ParserError 9106: (212-219): State mutability can only be specified for address types. +// ParserError 9106: (259-266): State mutability can only be specified for address types. +// ParserError 9106: (305-312): State mutability can only be specified for address types. +// ParserError 9106: (350-357): State mutability can only be specified for address types. +// ParserError 9106: (397-404): State mutability can only be specified for address types. +// ParserError 9106: (442-449): State mutability can only be specified for address types. +// ParserError 9106: (492-499): State mutability can only be specified for address types. +// ParserError 9106: (538-545): State mutability can only be specified for address types. +// ParserError 9106: (589-596): State mutability can only be specified for address types. +// ParserError 9106: (649-653): State mutability can only be specified for address types. +// ParserError 9106: (692-696): State mutability can only be specified for address types. +// ParserError 9106: (732-736): State mutability can only be specified for address types. +// ParserError 9106: (775-779): State mutability can only be specified for address types. +// ParserError 9106: (816-820): State mutability can only be specified for address types. +// ParserError 9106: (860-864): State mutability can only be specified for address types. +// ParserError 9106: (903-907): State mutability can only be specified for address types. +// ParserError 9106: (945-949): State mutability can only be specified for address types. +// ParserError 9106: (989-993): State mutability can only be specified for address types. +// ParserError 9106: (1031-1035): State mutability can only be specified for address types. +// ParserError 9106: (1078-1082): State mutability can only be specified for address types. +// ParserError 9106: (1121-1125): State mutability can only be specified for address types. +// ParserError 9106: (1169-1173): State mutability can only be specified for address types. +// ParserError 9106: (1226-1230): State mutability can only be specified for address types. +// ParserError 9106: (1269-1273): State mutability can only be specified for address types. +// ParserError 9106: (1309-1313): State mutability can only be specified for address types. +// ParserError 9106: (1352-1356): State mutability can only be specified for address types. +// ParserError 9106: (1393-1397): State mutability can only be specified for address types. +// ParserError 9106: (1437-1441): State mutability can only be specified for address types. +// ParserError 9106: (1480-1484): State mutability can only be specified for address types. +// ParserError 9106: (1522-1526): State mutability can only be specified for address types. +// ParserError 9106: (1566-1570): State mutability can only be specified for address types. +// ParserError 9106: (1608-1612): State mutability can only be specified for address types. +// ParserError 9106: (1655-1659): State mutability can only be specified for address types. +// ParserError 9106: (1698-1702): State mutability can only be specified for address types. +// ParserError 9106: (1746-1750): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_file_var.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_file_var.sol new file mode 100644 index 000000000..25b9acc9f --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_file_var.sol @@ -0,0 +1,81 @@ +bool payable a; +string payable b; +int payable c; +int256 payable d; +uint payable e; +uint256 payable f; +bytes1 payable g; +bytes payable h; +bytes32 payable i; +fixed payable j; +fixed80x80 payable k; +ufixed payable l; +ufixed80x80 payable m; + +bool view a2; +string view b2; +int view c2; +int256 view d2; +uint view e2; +uint256 view f2; +bytes1 view g2; +bytes view h2; +bytes32 view i2; +fixed view j2; +fixed80x80 view k2; +ufixed view l2; +ufixed80x80 view m2; + +bool pure a3; +string pure b3; +int pure c3; +int256 pure d3; +uint pure e3; +uint256 pure f3; +bytes1 pure g3; +bytes pure h3; +bytes32 pure i3; +fixed pure j3; +fixed80x80 pure k3; +ufixed pure l3; +ufixed80x80 pure m3; +// ---- +// ParserError 9106: (5-12): State mutability can only be specified for address types. +// ParserError 9106: (23-30): State mutability can only be specified for address types. +// ParserError 9106: (38-45): State mutability can only be specified for address types. +// ParserError 9106: (56-63): State mutability can only be specified for address types. +// ParserError 9106: (72-79): State mutability can only be specified for address types. +// ParserError 9106: (91-98): State mutability can only be specified for address types. +// ParserError 9106: (109-116): State mutability can only be specified for address types. +// ParserError 9106: (126-133): State mutability can only be specified for address types. +// ParserError 9106: (145-152): State mutability can only be specified for address types. +// ParserError 9106: (162-169): State mutability can only be specified for address types. +// ParserError 9106: (184-191): State mutability can only be specified for address types. +// ParserError 9106: (202-209): State mutability can only be specified for address types. +// ParserError 9106: (225-232): State mutability can only be specified for address types. +// ParserError 9106: (242-246): State mutability can only be specified for address types. +// ParserError 9106: (258-262): State mutability can only be specified for address types. +// ParserError 9106: (271-275): State mutability can only be specified for address types. +// ParserError 9106: (287-291): State mutability can only be specified for address types. +// ParserError 9106: (301-305): State mutability can only be specified for address types. +// ParserError 9106: (318-322): State mutability can only be specified for address types. +// ParserError 9106: (334-338): State mutability can only be specified for address types. +// ParserError 9106: (349-353): State mutability can only be specified for address types. +// ParserError 9106: (366-370): State mutability can only be specified for address types. +// ParserError 9106: (381-385): State mutability can only be specified for address types. +// ParserError 9106: (401-405): State mutability can only be specified for address types. +// ParserError 9106: (417-421): State mutability can only be specified for address types. +// ParserError 9106: (438-442): State mutability can only be specified for address types. +// ParserError 9106: (453-457): State mutability can only be specified for address types. +// ParserError 9106: (469-473): State mutability can only be specified for address types. +// ParserError 9106: (482-486): State mutability can only be specified for address types. +// ParserError 9106: (498-502): State mutability can only be specified for address types. +// ParserError 9106: (512-516): State mutability can only be specified for address types. +// ParserError 9106: (529-533): State mutability can only be specified for address types. +// ParserError 9106: (545-549): State mutability can only be specified for address types. +// ParserError 9106: (560-564): State mutability can only be specified for address types. +// ParserError 9106: (577-581): State mutability can only be specified for address types. +// ParserError 9106: (592-596): State mutability can only be specified for address types. +// ParserError 9106: (612-616): State mutability can only be specified for address types. +// ParserError 9106: (628-632): State mutability can only be specified for address types. +// ParserError 9106: (649-653): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_local.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_local.sol new file mode 100644 index 000000000..d0b25a539 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_local.sol @@ -0,0 +1,91 @@ +contract C { + function f() public pure { + bool payable a; + string payable b; + int payable c; + int256 payable d; + uint payable e; + uint256 payable f; + bytes1 payable g; + bytes payable h; + bytes32 payable i; + fixed payable j; + fixed80x80 payable k; + ufixed payable l; + ufixed80x80 payable m; + } +} +contract C2 { + function f() public pure { + bool view a; + string view b; + int view c; + int256 view d; + uint view e; + uint256 view f; + bytes1 view g; + bytes view h; + bytes32 view i; + fixed view j; + fixed80x80 view k; + ufixed view l; + ufixed80x80 view m; + } +} +contract C3 { + function f() public pure { + bool pure a; + string pure b; + int pure c; + int256 pure d; + uint pure e; + uint256 pure f; + bytes1 pure g; + bytes pure h; + bytes32 pure i; + fixed pure j; + fixed80x80 pure k; + ufixed pure l; + ufixed80x80 pure m; + } +} +// ---- +// ParserError 9106: (57-64): State mutability can only be specified for address types. +// ParserError 9106: (83-90): State mutability can only be specified for address types. +// ParserError 9106: (106-113): State mutability can only be specified for address types. +// ParserError 9106: (132-139): State mutability can only be specified for address types. +// ParserError 9106: (156-163): State mutability can only be specified for address types. +// ParserError 9106: (183-190): State mutability can only be specified for address types. +// ParserError 9106: (209-216): State mutability can only be specified for address types. +// ParserError 9106: (234-241): State mutability can only be specified for address types. +// ParserError 9106: (261-268): State mutability can only be specified for address types. +// ParserError 9106: (286-293): State mutability can only be specified for address types. +// ParserError 9106: (316-323): State mutability can only be specified for address types. +// ParserError 9106: (342-349): State mutability can only be specified for address types. +// ParserError 9106: (373-380): State mutability can only be specified for address types. +// ParserError 9106: (450-454): State mutability can only be specified for address types. +// ParserError 9106: (473-477): State mutability can only be specified for address types. +// ParserError 9106: (493-497): State mutability can only be specified for address types. +// ParserError 9106: (516-520): State mutability can only be specified for address types. +// ParserError 9106: (537-541): State mutability can only be specified for address types. +// ParserError 9106: (561-565): State mutability can only be specified for address types. +// ParserError 9106: (584-588): State mutability can only be specified for address types. +// ParserError 9106: (606-610): State mutability can only be specified for address types. +// ParserError 9106: (630-634): State mutability can only be specified for address types. +// ParserError 9106: (652-656): State mutability can only be specified for address types. +// ParserError 9106: (679-683): State mutability can only be specified for address types. +// ParserError 9106: (702-706): State mutability can only be specified for address types. +// ParserError 9106: (730-734): State mutability can only be specified for address types. +// ParserError 9106: (804-808): State mutability can only be specified for address types. +// ParserError 9106: (827-831): State mutability can only be specified for address types. +// ParserError 9106: (847-851): State mutability can only be specified for address types. +// ParserError 9106: (870-874): State mutability can only be specified for address types. +// ParserError 9106: (891-895): State mutability can only be specified for address types. +// ParserError 9106: (915-919): State mutability can only be specified for address types. +// ParserError 9106: (938-942): State mutability can only be specified for address types. +// ParserError 9106: (960-964): State mutability can only be specified for address types. +// ParserError 9106: (984-988): State mutability can only be specified for address types. +// ParserError 9106: (1006-1010): State mutability can only be specified for address types. +// ParserError 9106: (1033-1037): State mutability can only be specified for address types. +// ParserError 9106: (1056-1060): State mutability can only be specified for address types. +// ParserError 9106: (1084-1088): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_return.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_return.sol new file mode 100644 index 000000000..9e428fa9d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_return.sol @@ -0,0 +1,85 @@ +contract C { + function a() public pure returns (bool payable) {} + function b() public pure returns (string payable) {} + function c() public pure returns (int payable) {} + function d() public pure returns (int256 payable) {} + function e() public pure returns (uint payable) {} + function f() public pure returns (uint256 payable) {} + function g() public pure returns (bytes1 payable) {} + function h() public pure returns (bytes payable) {} + function i() public pure returns (bytes32 payable) {} + function j() public pure returns (fixed payable) {} + function k() public pure returns (fixed80x80 payable) {} + function l() public pure returns (ufixed payable) {} + function m() public pure returns (ufixed80x80 payable) {} +} +contract C1 { + function a() public pure returns (bool view) {} + function b() public pure returns (string view) {} + function c() public pure returns (int view) {} + function d() public pure returns (int256 view) {} + function e() public pure returns (uint view) {} + function f() public pure returns (uint256 view) {} + function g() public pure returns (bytes1 view) {} + function h() public pure returns (bytes view) {} + function i() public pure returns (bytes32 view) {} + function j() public pure returns (fixed view) {} + function k() public pure returns (fixed80x80 view) {} + function l() public pure returns (ufixed view) {} + function m() public pure returns (ufixed80x80 view) {} +} +contract C2 { + function a() public pure returns (bool pure) {} + function b() public pure returns (string pure) {} + function c() public pure returns (int pure) {} + function d() public pure returns (int256 pure) {} + function e() public pure returns (uint pure) {} + function f() public pure returns (uint256 pure) {} + function g() public pure returns (bytes1 pure) {} + function h() public pure returns (bytes pure) {} + function i() public pure returns (bytes32 pure) {} + function j() public pure returns (fixed pure) {} + function k() public pure returns (fixed80x80 pure) {} + function l() public pure returns (ufixed pure) {} + function m() public pure returns (ufixed80x80 pure) {} +} +// ---- +// ParserError 9106: (56-63): State mutability can only be specified for address types. +// ParserError 9106: (113-120): State mutability can only be specified for address types. +// ParserError 9106: (167-174): State mutability can only be specified for address types. +// ParserError 9106: (224-231): State mutability can only be specified for address types. +// ParserError 9106: (279-286): State mutability can only be specified for address types. +// ParserError 9106: (337-344): State mutability can only be specified for address types. +// ParserError 9106: (394-401): State mutability can only be specified for address types. +// ParserError 9106: (450-457): State mutability can only be specified for address types. +// ParserError 9106: (508-515): State mutability can only be specified for address types. +// ParserError 9106: (564-571): State mutability can only be specified for address types. +// ParserError 9106: (625-632): State mutability can only be specified for address types. +// ParserError 9106: (682-689): State mutability can only be specified for address types. +// ParserError 9106: (744-751): State mutability can only be specified for address types. +// ParserError 9106: (815-819): State mutability can only be specified for address types. +// ParserError 9106: (869-873): State mutability can only be specified for address types. +// ParserError 9106: (920-924): State mutability can only be specified for address types. +// ParserError 9106: (974-978): State mutability can only be specified for address types. +// ParserError 9106: (1026-1030): State mutability can only be specified for address types. +// ParserError 9106: (1081-1085): State mutability can only be specified for address types. +// ParserError 9106: (1135-1139): State mutability can only be specified for address types. +// ParserError 9106: (1188-1192): State mutability can only be specified for address types. +// ParserError 9106: (1243-1247): State mutability can only be specified for address types. +// ParserError 9106: (1296-1300): State mutability can only be specified for address types. +// ParserError 9106: (1354-1358): State mutability can only be specified for address types. +// ParserError 9106: (1408-1412): State mutability can only be specified for address types. +// ParserError 9106: (1467-1471): State mutability can only be specified for address types. +// ParserError 9106: (1535-1539): State mutability can only be specified for address types. +// ParserError 9106: (1589-1593): State mutability can only be specified for address types. +// ParserError 9106: (1640-1644): State mutability can only be specified for address types. +// ParserError 9106: (1694-1698): State mutability can only be specified for address types. +// ParserError 9106: (1746-1750): State mutability can only be specified for address types. +// ParserError 9106: (1801-1805): State mutability can only be specified for address types. +// ParserError 9106: (1855-1859): State mutability can only be specified for address types. +// ParserError 9106: (1908-1912): State mutability can only be specified for address types. +// ParserError 9106: (1963-1967): State mutability can only be specified for address types. +// ParserError 9106: (2016-2020): State mutability can only be specified for address types. +// ParserError 9106: (2074-2078): State mutability can only be specified for address types. +// ParserError 9106: (2128-2132): State mutability can only be specified for address types. +// ParserError 9106: (2187-2191): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_state_variable.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_state_variable.sol new file mode 100644 index 000000000..960929f91 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_state_mutability_state_variable.sol @@ -0,0 +1,85 @@ +contract C { + bool payable a; + string payable b; + int payable c; + int256 payable d; + uint payable e; + uint256 payable f; + bytes1 payable g; + bytes payable h; + bytes32 payable i; + fixed payable j; + fixed80x80 payable k; + ufixed payable l; + ufixed80x80 payable m; +} +contract C2 { + bool view a; + string view b; + int view c; + int256 view d; + uint view e; + uint256 view f; + bytes1 view g; + bytes view h; + bytes32 view i; + fixed view j; + fixed80x80 view k; + ufixed view l; + ufixed80x80 view m; +} +contract C3 { + bool pure a; + string pure b; + int pure c; + int256 pure d; + uint pure e; + uint256 pure f; + bytes1 pure g; + bytes pure h; + bytes32 pure i; + fixed pure j; + fixed80x80 pure k; + ufixed pure l; + ufixed80x80 pure m; +} +// ---- +// ParserError 9106: (22-29): State mutability can only be specified for address types. +// ParserError 9106: (44-51): State mutability can only be specified for address types. +// ParserError 9106: (63-70): State mutability can only be specified for address types. +// ParserError 9106: (85-92): State mutability can only be specified for address types. +// ParserError 9106: (105-112): State mutability can only be specified for address types. +// ParserError 9106: (128-135): State mutability can only be specified for address types. +// ParserError 9106: (150-157): State mutability can only be specified for address types. +// ParserError 9106: (171-178): State mutability can only be specified for address types. +// ParserError 9106: (194-201): State mutability can only be specified for address types. +// ParserError 9106: (215-222): State mutability can only be specified for address types. +// ParserError 9106: (241-248): State mutability can only be specified for address types. +// ParserError 9106: (263-270): State mutability can only be specified for address types. +// ParserError 9106: (290-297): State mutability can only be specified for address types. +// ParserError 9106: (326-330): State mutability can only be specified for address types. +// ParserError 9106: (345-349): State mutability can only be specified for address types. +// ParserError 9106: (361-365): State mutability can only be specified for address types. +// ParserError 9106: (380-384): State mutability can only be specified for address types. +// ParserError 9106: (397-401): State mutability can only be specified for address types. +// ParserError 9106: (417-421): State mutability can only be specified for address types. +// ParserError 9106: (436-440): State mutability can only be specified for address types. +// ParserError 9106: (454-458): State mutability can only be specified for address types. +// ParserError 9106: (474-478): State mutability can only be specified for address types. +// ParserError 9106: (492-496): State mutability can only be specified for address types. +// ParserError 9106: (515-519): State mutability can only be specified for address types. +// ParserError 9106: (534-538): State mutability can only be specified for address types. +// ParserError 9106: (558-562): State mutability can only be specified for address types. +// ParserError 9106: (591-595): State mutability can only be specified for address types. +// ParserError 9106: (610-614): State mutability can only be specified for address types. +// ParserError 9106: (626-630): State mutability can only be specified for address types. +// ParserError 9106: (645-649): State mutability can only be specified for address types. +// ParserError 9106: (662-666): State mutability can only be specified for address types. +// ParserError 9106: (682-686): State mutability can only be specified for address types. +// ParserError 9106: (701-705): State mutability can only be specified for address types. +// ParserError 9106: (719-723): State mutability can only be specified for address types. +// ParserError 9106: (739-743): State mutability can only be specified for address types. +// ParserError 9106: (757-761): State mutability can only be specified for address types. +// ParserError 9106: (780-784): State mutability can only be specified for address types. +// ParserError 9106: (799-803): State mutability can only be specified for address types. +// ParserError 9106: (823-827): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/invalid_function_parameter_and_return_var_indexed.sol b/test/libsolidity/syntaxTests/parsing/invalid_function_parameter_and_return_var_indexed.sol new file mode 100644 index 000000000..0dd79bae7 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/invalid_function_parameter_and_return_var_indexed.sol @@ -0,0 +1,11 @@ +==== Source: A ==== +contract test { + function f1(uint indexed a) public returns (uint) { } +} +==== Source: B ==== +contract test { + function f1(uint a) public returns (uint indexed) { } +} +// ---- +// ParserError 2314: (A:37-44): Expected ',' but got 'indexed' +// ParserError 2314: (B:61-68): Expected ',' but got 'indexed' diff --git a/test/libsolidity/syntaxTests/parsing/invalid_function_parameter_and_return_var_mutability.sol b/test/libsolidity/syntaxTests/parsing/invalid_function_parameter_and_return_var_mutability.sol new file mode 100644 index 000000000..602414192 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/invalid_function_parameter_and_return_var_mutability.sol @@ -0,0 +1,9 @@ +contract test { + function f1(uint immutable a) public returns (uint immutable) { } + function f2(uint constant a) public returns (uint constant) { } +} +// ---- +// DeclarationError 8297: (32-48): The "immutable" keyword can only be used for state variables. +// DeclarationError 8297: (66-80): The "immutable" keyword can only be used for state variables. +// DeclarationError 1788: (102-117): The "constant" keyword can only be used for state variables or variables at file level. +// DeclarationError 1788: (135-148): The "constant" keyword can only be used for state variables or variables at file level. diff --git a/test/libsolidity/syntaxTests/parsing/invalid_state_variable_location.sol b/test/libsolidity/syntaxTests/parsing/invalid_state_variable_location.sol new file mode 100644 index 000000000..b5b3439f4 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/invalid_state_variable_location.sol @@ -0,0 +1,11 @@ +==== Source: A ==== +contract test { + string memory a; +} +==== Source: B ==== +contract test { + string calldata a; +} +// ---- +// ParserError 2314: (A:27-33): Expected identifier but got 'memory' +// ParserError 2314: (B:27-35): Expected identifier but got 'calldata' diff --git a/test/libsolidity/syntaxTests/parsing/invalid_variable_indexed.sol b/test/libsolidity/syntaxTests/parsing/invalid_variable_indexed.sol new file mode 100644 index 000000000..9508e795a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/invalid_variable_indexed.sol @@ -0,0 +1,16 @@ +==== Source: A ==== +uint indexed a; +==== Source: B ==== +contract test { + function f(uint a) public { + uint indexed a; + } +} +==== Source: C ==== +contract test { + uint indexed a; +} +// ---- +// ParserError 2314: (A:5-12): Expected identifier but got 'indexed' +// ParserError 2314: (B:61-68): Expected ';' but got 'indexed' +// ParserError 2314: (C:25-32): Expected identifier but got 'indexed' \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/parsing/invalid_variable_mutablity.sol b/test/libsolidity/syntaxTests/parsing/invalid_variable_mutablity.sol new file mode 100644 index 000000000..874a18512 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/invalid_variable_mutablity.sol @@ -0,0 +1,15 @@ +==== Source: A ==== +contract test { + function f(uint a) public { + uint constant a; + } +} +==== Source: B ==== +contract test { + function f(uint a) public { + uint immutable a; + } +} +// ---- +// ParserError 2314: (A:61-69): Expected ';' but got 'constant' +// ParserError 2314: (B:61-70): Expected ';' but got 'immutable' \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_file_level_var.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_file_level_var.sol new file mode 100644 index 000000000..c7b1558e6 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_file_level_var.sol @@ -0,0 +1,10 @@ +==== Source: A ==== +uint[] storage a; +==== Source: B ==== +uint[] memory b; +==== Source: C ==== +uint[] calldata c; +// ---- +// ParserError 2314: (A:7-14): Expected identifier but got 'storage' +// ParserError 2314: (B:7-13): Expected identifier but got 'memory' +// ParserError 2314: (C:7-15): Expected identifier but got 'calldata' diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_fn_returns_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_fn_returns_multi.sol new file mode 100644 index 000000000..06627bd64 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_fn_returns_multi.sol @@ -0,0 +1,21 @@ +contract Foo { + function f1() returns (string calldata calldata) {} + function f2() returns (string calldata memory) {} + function f3() returns (string calldata storage) {} + function f4() returns (string memory calldata) {} + function f5() returns (string memory memory) {} + function f6() returns (string memory storage) {} + function f7() returns (string storage calldata) {} + function f8() returns (string storage memory) {} + function f9() returns (string storage storage) {} +} +// ---- +// ParserError 3548: (58-66): Location already specified. +// ParserError 3548: (114-120): Location already specified. +// ParserError 3548: (168-175): Location already specified. +// ParserError 3548: (221-229): Location already specified. +// ParserError 3548: (275-281): Location already specified. +// ParserError 3548: (327-334): Location already specified. +// ParserError 3548: (381-389): Location already specified. +// ParserError 3548: (436-442): Location already specified. +// ParserError 3548: (489-496): Location already specified. diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol index f660c0953..f61cd9498 100644 --- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol @@ -3,6 +3,14 @@ contract Foo { function f() public view { uint[] storage memory x = m_x; uint[] memory storage calldata y; + uint[] storage calldata x2; + uint[] storage storage x3; + uint[] calldata memory x4; + uint[] calldata calldata x5; + uint[] calldata storage x6; + uint[] storage memory x4; + uint[] storage calldata x5; + uint[] storage storage x6; x; y; } } @@ -10,3 +18,11 @@ contract Foo { // ParserError 3548: (85-91): Location already specified. // ParserError 3548: (123-130): Location already specified. // ParserError 3548: (131-139): Location already specified. +// ParserError 3548: (166-174): Location already specified. +// ParserError 3548: (202-209): Location already specified. +// ParserError 3548: (238-244): Location already specified. +// ParserError 3548: (273-281): Location already specified. +// ParserError 3548: (310-317): Location already specified. +// ParserError 3548: (345-351): Location already specified. +// ParserError 3548: (379-387): Location already specified. +// ParserError 3548: (415-422): Location already specified. diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol index 25d1e02d3..8d1985cd6 100644 --- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol @@ -1,6 +1,20 @@ contract Foo { function f(uint[] storage memory constant x, uint[] memory calldata y) internal { } + function f2(uint[] storage storage x) internal { } + function f3(uint[] storage calldata x) internal { } + function f4(uint[] memory storage x) internal { } + function f5(uint[] memory memory x) internal { } + function f6(uint[] calldata storage x) internal { } + function f7(uint[] calldata memory x) internal { } + function f8(uint[] calldata calldata x) internal { } } // ---- // ParserError 3548: (45-51): Location already specified. // ParserError 3548: (78-86): Location already specified. +// ParserError 3548: (134-141): Location already specified. +// ParserError 3548: (189-197): Location already specified. +// ParserError 3548: (244-251): Location already specified. +// ParserError 3548: (298-304): Location already specified. +// ParserError 3548: (353-360): Location already specified. +// ParserError 3548: (409-415): Location already specified. +// ParserError 3548: (464-472): Location already specified. diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol index 134397fec..d53f24757 100644 --- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol @@ -1,5 +1,11 @@ +==== Source: A ==== contract Foo { uint[] memory storage calldata x; } +==== Source: B ==== +contract Foo { + uint[] storage storage x; +} // ---- -// ParserError 2314: (23-29): Expected identifier but got 'memory' +// ParserError 2314: (A:23-29): Expected identifier but got 'memory' +// ParserError 2314: (B:23-30): Expected identifier but got 'storage' \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/parsing/multiple_mutability_specifiers.sol b/test/libsolidity/syntaxTests/parsing/multiple_mutability_specifiers.sol new file mode 100644 index 000000000..50579054c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multiple_mutability_specifiers.sol @@ -0,0 +1,11 @@ +contract C { + uint constant constant a; + uint immutable immutable b; + uint constant immutable c; + uint immutable constant d; +} +// ---- +// ParserError 3109: (31-39): Mutability already set to "constant" +// ParserError 3109: (62-71): Mutability already set to "immutable" +// ParserError 3109: (93-102): Mutability already set to "constant" +// ParserError 3109: (125-133): Mutability already set to "immutable" diff --git a/test/libsolidity/syntaxTests/parsing/multiple_state_mutability_specifiers.sol b/test/libsolidity/syntaxTests/parsing/multiple_state_mutability_specifiers.sol new file mode 100644 index 000000000..e9c440105 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multiple_state_mutability_specifiers.sol @@ -0,0 +1,103 @@ +==== Source: A ==== +contract c1 { + function f() payable payable {} +} +contract c2 { + function f() view view {} +} +contract c3 { + function f() pure pure {} +} +contract c4 { + function f() pure view {} +} +contract c5 { + function f() payable view {} +} +contract c6 { + function f() pure payable {} +} +contract c7 { + function f() view payable {} +} +contract c8 { + function f() payable pure {} +} +contract c9 { + function f() view pure {} +} +==== Source: B ==== +contract c { + address payable payable v; +} +==== Source: C ==== +contract c { + function fn(address payable payable) public { } +} +==== Source: D ==== +contract c { + function fn() public returns (address payable payable) { } +} +==== Source: E ==== +contract c { + function fn() public { + address payable payable v; + } +} +==== Source: F ==== +contract c { + function fn(address payable payable v) public { } +} +==== Source: G ==== +contract c { + function fn() public returns (address payable payable res) { } +} +==== Source: H ==== +address payable payable v; +==== Source: I ==== +contract c { + modifier m(address payable payable x) { _; } +} +==== Source: J ==== +contract c { + event e(address payable payable x); +} +==== Source: K ==== +contract c { + error e1(address payable payable x); +} +==== Source: L ==== +contract c { + function f() public returns (address payable) { + try this.f() returns (address payable payable) { } catch { } + } +} +==== Source: M ==== +contract c { + function f() public returns (address payable) { + try this.f() returns (address payable) { } catch Error(address payable payable) { } + } +} +// ---- +// ParserError 9680: (A:39-46): State mutability already specified as "payable". +// ParserError 9680: (A:88-92): State mutability already specified as "view". +// ParserError 9680: (A:134-138): State mutability already specified as "pure". +// ParserError 9680: (A:180-184): State mutability already specified as "pure". +// ParserError 9680: (A:229-233): State mutability already specified as "payable". +// ParserError 9680: (A:275-282): State mutability already specified as "pure". +// ParserError 9680: (A:324-331): State mutability already specified as "view". +// ParserError 9680: (A:376-380): State mutability already specified as "payable". +// ParserError 9680: (A:422-426): State mutability already specified as "view". +// ParserError 2314: (B:33-40): Expected identifier but got 'payable' +// ParserError 2314: (C:45-52): Expected ',' but got 'payable' +// ParserError 2314: (D:63-70): Expected ',' but got 'payable' +// ParserError 2314: (E:64-71): Expected identifier but got 'payable' +// ParserError 2314: (F:45-52): Expected ',' but got 'payable' +// ParserError 2314: (G:63-70): Expected ',' but got 'payable' +// ParserError 2314: (H:16-23): Expected identifier but got 'payable' +// ParserError 2314: (I:44-51): Expected ',' but got 'payable' +// ParserError 2314: (J:41-48): Expected ',' but got 'payable' +// ParserError 2314: (K:42-49): Expected ',' but got 'payable' +// ParserError 2314: (L:111-118): Expected ',' but got 'payable' +// ParserError 2314: (M:144-151): Expected ',' but got 'payable' + diff --git a/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol b/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol deleted file mode 100644 index e2c56ae57..000000000 --- a/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol +++ /dev/null @@ -1,29 +0,0 @@ -contract c1 { - function f() payable payable {} -} -contract c2 { - function f() view view {} -} -contract c3 { - function f() pure pure {} -} -contract c4 { - function f() pure view {} -} -contract c5 { - function f() payable view {} -} -contract c6 { - function f() pure payable {} -} -contract c7 { - function f() view payable {} -} -// ---- -// ParserError 9680: (39-46): State mutability already specified as "payable". -// ParserError 9680: (88-92): State mutability already specified as "view". -// ParserError 9680: (134-138): State mutability already specified as "pure". -// ParserError 9680: (180-184): State mutability already specified as "pure". -// ParserError 9680: (229-233): State mutability already specified as "payable". -// ParserError 9680: (275-282): State mutability already specified as "pure". -// ParserError 9680: (324-331): State mutability already specified as "view". diff --git a/test/libsolidity/syntaxTests/parsing/multiple_visibility_specifiers.sol b/test/libsolidity/syntaxTests/parsing/multiple_visibility_specifiers.sol deleted file mode 100644 index c04558171..000000000 --- a/test/libsolidity/syntaxTests/parsing/multiple_visibility_specifiers.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract C { - uint private internal a; - function f() private external {} -} -// ---- -// ParserError 4110: (30-38): Visibility already specified as "private". -// ParserError 9439: (67-75): Visibility already specified as "private". diff --git a/test/libsolidity/syntaxTests/parsing/payable_accessor.sol b/test/libsolidity/syntaxTests/parsing/payable_accessor.sol deleted file mode 100644 index 4df1b18df..000000000 --- a/test/libsolidity/syntaxTests/parsing/payable_accessor.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract test { - uint payable x; -} -// ---- -// ParserError 9106: (22-29): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/pragma/experimental_multiple_experimental.sol b/test/libsolidity/syntaxTests/pragma/experimental_multiple_experimental.sol new file mode 100644 index 000000000..49fe597ec --- /dev/null +++ b/test/libsolidity/syntaxTests/pragma/experimental_multiple_experimental.sol @@ -0,0 +1,4 @@ +pragma experimental experimental __test; +// ---- +// SyntaxError 6022: (0-40): Stray arguments. + diff --git a/test/libsolidity/syntaxTests/tryCatch/elementary_non_address_state_mutability_catch.sol b/test/libsolidity/syntaxTests/tryCatch/elementary_non_address_state_mutability_catch.sol new file mode 100644 index 000000000..edb3c5301 --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/elementary_non_address_state_mutability_catch.sol @@ -0,0 +1,31 @@ +contract C { + function a() public pure { + try this.a() {} catch (string payable memory) {} + } + function c() public pure { + try this.c() {} catch (bytes payable memory) {} + } +} +contract C2 { + function a() public pure { + try this.a() {} catch (string view memory) {} + } + function c() public pure { + try this.c() {} catch (bytes view memory) {} + } +} +contract C3 { + function a() public pure { + try this.a() {} catch (string pure memory) {} + } + function c() public pure { + try this.c() {} catch (bytes pure memory) {} + } +} +// ---- +// ParserError 9106: (82-89): State mutability can only be specified for address types. +// ParserError 9106: (175-182): State mutability can only be specified for address types. +// ParserError 9106: (285-289): State mutability can only be specified for address types. +// ParserError 9106: (375-379): State mutability can only be specified for address types. +// ParserError 9106: (482-486): State mutability can only be specified for address types. +// ParserError 9106: (572-576): State mutability can only be specified for address types. \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/tryCatch/elementary_non_address_state_mutability_try_returns.sol b/test/libsolidity/syntaxTests/tryCatch/elementary_non_address_state_mutability_try_returns.sol new file mode 100644 index 000000000..bc16f19c7 --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/elementary_non_address_state_mutability_try_returns.sol @@ -0,0 +1,163 @@ +contract C { + function a() public pure returns (bool) { + try this.a() returns (bool payable res) {} catch {} + } + function b() public pure returns (string) { + try this.b() returns (string payable res) {} catch {} + } + function c() public pure returns (int) { + try this.c() returns (int payable res) {} catch {} + } + function d() public pure returns (int256) { + try this.d() returns (int256 payable res) {} catch {} + } + function e() public pure returns (uint) { + try this.e() returns (uint payable res) {} catch {} + } + function f() public pure returns (uint256) { + try this.f() returns (uint256 payable res) {} catch {} + } + function g() public pure returns (bytes1) { + try this.g() returns (bytes1 payable res) {} catch {} + } + function h() public pure returns (bytes) { + try this.h() returns (bytes payable res) {} catch {} + } + function i() public pure returns (bytes32) { + try this.i() returns (bytes32 payable res) {} catch {} + } + function j() public pure returns (fixed) { + try this.j() returns (fixed payable res) {} catch {} + } + function k() public pure returns (fixed80x80) { + try this.k() returns (fixed80x80 payable res) {} catch {} + } + function l() public pure returns (ufixed) { + try this.l() returns (ufixed payable res) {} catch {} + } + function m() public pure returns (ufixed80x80) { + try this.m() returns (ufixed80x80 payable res) {} catch {} + } +} +contract C1 { + function a() public pure returns (bool) { + try this.a() returns (bool view res) {} catch {} + } + function b() public pure returns (string) { + try this.b() returns (string view res) {} catch {} + } + function c() public pure returns (int) { + try this.c() returns (int view res) {} catch {} + } + function d() public pure returns (int256) { + try this.d() returns (int256 view res) {} catch {} + } + function e() public pure returns (uint) { + try this.e() returns (uint view res) {} catch {} + } + function f() public pure returns (uint256) { + try this.f() returns (uint256 view res) {} catch {} + } + function g() public pure returns (bytes1) { + try this.g() returns (bytes1 view res) {} catch {} + } + function h() public pure returns (bytes) { + try this.h() returns (bytes view res) {} catch {} + } + function i() public pure returns (bytes32) { + try this.i() returns (bytes32 view res) {} catch {} + } + function j() public pure returns (fixed) { + try this.j() returns (fixed view res) {} catch {} + } + function k() public pure returns (fixed80x80) { + try this.k() returns (fixed80x80 view res) {} catch {} + } + function l() public pure returns (ufixed) { + try this.l() returns (ufixed view res) {} catch {} + } + function m() public pure returns (ufixed80x80) { + try this.m() returns (ufixed80x80 view res) {} catch {} + } +} +contract C2 { + function a() public pure returns (bool) { + try this.a() returns (bool pure res) {} catch {} + } + function b() public pure returns (string) { + try this.b() returns (string pure res) {} catch {} + } + function c() public pure returns (int) { + try this.c() returns (int pure res) {} catch {} + } + function d() public pure returns (int256) { + try this.d() returns (int256 pure res) {} catch {} + } + function e() public pure returns (uint) { + try this.e() returns (uint pure res) {} catch {} + } + function f() public pure returns (uint256) { + try this.f() returns (uint256 pure res) {} catch {} + } + function g() public pure returns (bytes1) { + try this.g() returns (bytes1 pure res) {} catch {} + } + function h() public pure returns (bytes) { + try this.h() returns (bytes pure res) {} catch {} + } + function i() public pure returns (bytes32) { + try this.i() returns (bytes32 pure res) {} catch {} + } + function j() public pure returns (fixed) { + try this.j() returns (fixed pure res) {} catch {} + } + function k() public pure returns (fixed80x80) { + try this.k() returns (fixed80x80 pure res) {} catch {} + } + function l() public pure returns (ufixed) { + try this.l() returns (ufixed pure res) {} catch {} + } + function m() public pure returns (ufixed80x80) { + try this.m() returns (ufixed80x80 pure res) {} catch {} + } +} +// ---- +// ParserError 9106: (94-101): State mutability can only be specified for address types. +// ParserError 9106: (210-217): State mutability can only be specified for address types. +// ParserError 9106: (320-327): State mutability can only be specified for address types. +// ParserError 9106: (436-443): State mutability can only be specified for address types. +// ParserError 9106: (548-555): State mutability can only be specified for address types. +// ParserError 9106: (666-673): State mutability can only be specified for address types. +// ParserError 9106: (782-789): State mutability can only be specified for address types. +// ParserError 9106: (896-903): State mutability can only be specified for address types. +// ParserError 9106: (1014-1021): State mutability can only be specified for address types. +// ParserError 9106: (1128-1135): State mutability can only be specified for address types. +// ParserError 9106: (1252-1259): State mutability can only be specified for address types. +// ParserError 9106: (1368-1375): State mutability can only be specified for address types. +// ParserError 9106: (1494-1501): State mutability can only be specified for address types. +// ParserError 9106: (1622-1626): State mutability can only be specified for address types. +// ParserError 9106: (1735-1739): State mutability can only be specified for address types. +// ParserError 9106: (1842-1846): State mutability can only be specified for address types. +// ParserError 9106: (1955-1959): State mutability can only be specified for address types. +// ParserError 9106: (2064-2068): State mutability can only be specified for address types. +// ParserError 9106: (2179-2183): State mutability can only be specified for address types. +// ParserError 9106: (2292-2296): State mutability can only be specified for address types. +// ParserError 9106: (2403-2407): State mutability can only be specified for address types. +// ParserError 9106: (2518-2522): State mutability can only be specified for address types. +// ParserError 9106: (2629-2633): State mutability can only be specified for address types. +// ParserError 9106: (2750-2754): State mutability can only be specified for address types. +// ParserError 9106: (2863-2867): State mutability can only be specified for address types. +// ParserError 9106: (2986-2990): State mutability can only be specified for address types. +// ParserError 9106: (3111-3115): State mutability can only be specified for address types. +// ParserError 9106: (3224-3228): State mutability can only be specified for address types. +// ParserError 9106: (3331-3335): State mutability can only be specified for address types. +// ParserError 9106: (3444-3448): State mutability can only be specified for address types. +// ParserError 9106: (3553-3557): State mutability can only be specified for address types. +// ParserError 9106: (3668-3672): State mutability can only be specified for address types. +// ParserError 9106: (3781-3785): State mutability can only be specified for address types. +// ParserError 9106: (3892-3896): State mutability can only be specified for address types. +// ParserError 9106: (4007-4011): State mutability can only be specified for address types. +// ParserError 9106: (4118-4122): State mutability can only be specified for address types. +// ParserError 9106: (4239-4243): State mutability can only be specified for address types. +// ParserError 9106: (4352-4356): State mutability can only be specified for address types. +// ParserError 9106: (4475-4479): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/tryCatch/invalid_catch_parameter_location_calldata.sol b/test/libsolidity/syntaxTests/tryCatch/invalid_catch_parameter_location_calldata.sol new file mode 100644 index 000000000..d9302ef1f --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/invalid_catch_parameter_location_calldata.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + try this.f() {} catch (string calldata a) { } + } +} +// ---- +// TypeError 6651: (70-87): Data location must be "memory" for parameter in function, but "calldata" was given. diff --git a/test/libsolidity/syntaxTests/tryCatch/invalid_catch_parameter_location_storage.sol b/test/libsolidity/syntaxTests/tryCatch/invalid_catch_parameter_location_storage.sol new file mode 100644 index 000000000..066b1ebfe --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/invalid_catch_parameter_location_storage.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + try this.f() {} catch (string storage a) { } + } +} +// ---- +// TypeError 6651: (70-86): Data location must be "memory" for parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/tryCatch/invalid_returns_var_location.sol b/test/libsolidity/syntaxTests/tryCatch/invalid_returns_var_location.sol new file mode 100644 index 000000000..c9980026f --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/invalid_returns_var_location.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (string memory) { + try this.f() returns (string storage a) {} catch { } + } +} +// ---- +// TypeError 6651: (93-109): Data location must be "memory" for parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_indexed.sol b/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_indexed.sol new file mode 100644 index 000000000..43e04583a --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_indexed.sol @@ -0,0 +1,27 @@ +==== Source: A ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint indexed a) { + } catch { } + } +} +==== Source: E ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch Error(string memory indexed x) { + } + } +} +==== Source: I ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch (bytes memory indexed x) { + } + } +} +// ---- +// ParserError 2314: (A:89-96): Expected ',' but got 'indexed' +// ParserError 2314: (E:128-135): Expected ',' but got 'indexed' +// ParserError 2314: (I:122-129): Expected ',' but got 'indexed' diff --git a/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_mutability.sol b/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_mutability.sol new file mode 100644 index 000000000..bbc267f89 --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_mutability.sol @@ -0,0 +1,30 @@ +contract C { + function f() public returns (uint, uint) { + try this.f() returns (uint constant a, uint immutable b) { + } catch Error(string memory immutable x) { + x; + } + + try this.f() returns (uint a, uint b) { + } catch (bytes memory immutable x) { + x; + } + + try this.f() returns (uint a, uint b) { + } catch Error(string memory constant x) { + x; + } + + try this.f() returns (uint a, uint b) { + } catch (bytes memory constant x) { + x; + } + } +} +// ---- +// DeclarationError 1788: (90-105): The "constant" keyword can only be used for state variables or variables at file level. +// DeclarationError 8297: (107-123): The "immutable" keyword can only be used for state variables. +// DeclarationError 8297: (149-174): The "immutable" keyword can only be used for state variables. +// DeclarationError 8297: (269-293): The "immutable" keyword can only be used for state variables. +// DeclarationError 1788: (393-417): The "constant" keyword can only be used for state variables or variables at file level. +// DeclarationError 1788: (512-535): The "constant" keyword can only be used for state variables or variables at file level. diff --git a/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_visibility.sol b/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_visibility.sol new file mode 100644 index 000000000..1828f25d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/invalid_returns_vars_and_catch_parameter_visibility.sol @@ -0,0 +1,105 @@ +==== Source: A ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint public a) { + } catch { } + } +} +==== Source: B ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint private a) { + } catch { } + } +} +==== Source: C ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint external a) { + } catch { } + } +} +==== Source: D ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint internal a) { + } catch { } + } +} +==== Source: E ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch Error(string memory public x) { + } + } +} +==== Source: F ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch Error(string memory private x) { + } + } +} +==== Source: G ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch Error(string memory external x) { + } + } +} +==== Source: H ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch Error(string memory internal x) { + } + } +} +==== Source: I ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch (bytes memory public x) { + } + } +} +==== Source: J ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch (bytes memory private x) { + } + } +} +==== Source: K ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch (bytes memory external x) { + } + } +} +==== Source: L ==== +contract C { + function f() public returns (uint) { + try this.f() returns (uint) { + } catch (bytes memory internal x) { + } + } +} +// ---- +// ParserError 2314: (A:89-95): Expected ',' but got 'public' +// ParserError 2314: (B:89-96): Expected ',' but got 'private' +// ParserError 2314: (C:89-97): Expected ',' but got 'external' +// ParserError 2314: (D:89-97): Expected ',' but got 'internal' +// ParserError 2314: (E:128-134): Expected ',' but got 'public' +// ParserError 2314: (F:128-135): Expected ',' but got 'private' +// ParserError 2314: (G:128-136): Expected ',' but got 'external' +// ParserError 2314: (H:128-136): Expected ',' but got 'internal' +// ParserError 2314: (I:122-128): Expected ',' but got 'public' +// ParserError 2314: (J:122-129): Expected ',' but got 'private' +// ParserError 2314: (K:122-130): Expected ',' but got 'external' +// ParserError 2314: (L:122-130): Expected ',' but got 'internal' \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/tryCatch/multiple_returns_vars_and_catch_parameter_location.sol b/test/libsolidity/syntaxTests/tryCatch/multiple_returns_vars_and_catch_parameter_location.sol new file mode 100644 index 000000000..88df3f5ba --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/multiple_returns_vars_and_catch_parameter_location.sol @@ -0,0 +1,132 @@ +==== Source: A1 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string memory memory a) { } catch { } + } +} +==== Source: A2 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string memory storage a) { } catch { } + } +} +==== Source: A3 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string memory calldata a) { } catch { } + } +} + +==== Source: B1 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string calldata memory a) { } catch { } + } +} +==== Source: B2 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string calldata storage a) { } catch { } + } +} +==== Source: B3 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string calldata calldata a) { } catch { } + } +} + +==== Source: C1 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string storage memory a) { } catch { } + } +} +==== Source: C2 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string storage storage a) { } catch { } + } +} +==== Source: C3 ==== +contract C { + function f() public returns (string memory) { + try this.f() returns (string storage calldata a) { } catch { } + } +} + +==== Source: D1 ==== +contract C { + function f() public { + try this.f() {} catch (string memory memory x) { } + } +} +==== Source: D2 ==== +contract C { + function f() public { + try this.f() {} catch (string memory calldata x) { } + } +} +==== Source: D3 ==== +contract C { + function f() public { + try this.f() {} catch (string memory storage x) { } + } +} + +==== Source: E1 ==== +contract C { + function f() public { + try this.f() {} catch (string calldata memory x) { } + } +} +==== Source: E2 ==== +contract C { + function f() public { + try this.f() {} catch (string calldata calldata x) { } + } +} +==== Source: E3 ==== +contract C { + function f() public { + try this.f() {} catch (string calldata storage x) { } + } +} + +==== Source: G1 ==== +contract C { + function f() public { + try this.f() {} catch (string storage memory x) { } + } +} +==== Source: G2 ==== +contract C { + function f() public { + try this.f() {} catch (string storage calldata x) { } + } +} +==== Source: G3 ==== +contract C { + function f() public { + try this.f() {} catch (string storage storage x) { } + } +} +// ---- +// ParserError 3548: (A1:107-113): Location already specified. +// ParserError 3548: (A2:107-114): Location already specified. +// ParserError 3548: (A3:107-115): Location already specified. +// ParserError 3548: (B1:109-115): Location already specified. +// ParserError 3548: (B2:109-116): Location already specified. +// ParserError 3548: (B3:109-117): Location already specified. +// ParserError 3548: (C1:108-114): Location already specified. +// ParserError 3548: (C2:108-115): Location already specified. +// ParserError 3548: (C3:108-116): Location already specified. +// ParserError 3548: (D1:85-91): Location already specified. +// ParserError 3548: (D2:85-93): Location already specified. +// ParserError 3548: (D3:85-92): Location already specified. +// ParserError 3548: (E1:87-93): Location already specified. +// ParserError 3548: (E2:87-95): Location already specified. +// ParserError 3548: (E3:87-94): Location already specified. +// ParserError 3548: (G1:86-92): Location already specified. +// ParserError 3548: (G2:86-94): Location already specified. +// ParserError 3548: (G3:86-93): Location already specified. diff --git a/test/libsolidity/syntaxTests/using/global_multiple_global_keywords.sol b/test/libsolidity/syntaxTests/using/global_multiple_global_keywords.sol new file mode 100644 index 000000000..48ce7f111 --- /dev/null +++ b/test/libsolidity/syntaxTests/using/global_multiple_global_keywords.sol @@ -0,0 +1,5 @@ +using {f} for S global global; +struct S { uint x; } +function f(S memory _x) pure returns (uint) { return _x.x; } +// ---- +// ParserError 2314: (23-29): Expected ';' but got identifier diff --git a/test/libsolidity/syntaxTests/visibility/file_level_variable_visibility.sol b/test/libsolidity/syntaxTests/visibility/file_level_variable_visibility.sol new file mode 100644 index 000000000..3de9f3ae2 --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/file_level_variable_visibility.sol @@ -0,0 +1,13 @@ +==== Source: A ==== +uint external a; +==== Source: B ==== +uint internal a; +==== Source: C ==== +uint public a; +==== Source: D ==== +uint private a; +// ---- +// ParserError 2314: (A:5-13): Expected identifier but got 'external' +// ParserError 2314: (B:5-13): Expected identifier but got 'internal' +// ParserError 2314: (C:5-11): Expected identifier but got 'public' +// ParserError 2314: (D:5-12): Expected identifier but got 'private' diff --git a/test/libsolidity/syntaxTests/visibility/invalid_function_parameter_and_return_var_visibility.sol b/test/libsolidity/syntaxTests/visibility/invalid_function_parameter_and_return_var_visibility.sol new file mode 100644 index 000000000..4f73e884d --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/invalid_function_parameter_and_return_var_visibility.sol @@ -0,0 +1,41 @@ +==== Source: A ==== +contract test { + function f(uint external a) public returns (uint) { } +} +==== Source: B ==== +contract test { + function f(uint internal a) public returns (uint) { } +} +==== Source: C ==== +contract test { + function f(uint public a) public returns (uint) { } +} +==== Source: D ==== +contract test { + function f(uint private a) public returns (uint) { } +} +==== Source: E ==== +contract test { + function f(uint a) public returns (uint external) { } +} +==== Source: F ==== +contract test { + function f(uint a) public returns (uint internal) { } +} +==== Source: G ==== +contract test { + function f(uint a) public returns (uint public) { } +} +==== Source: H ==== +contract test { + function f(uint a) public returns (uint private) { } +} +// ---- +// ParserError 2314: (A:36-44): Expected ',' but got 'external' +// ParserError 2314: (B:36-44): Expected ',' but got 'internal' +// ParserError 2314: (C:36-42): Expected ',' but got 'public' +// ParserError 2314: (D:36-43): Expected ',' but got 'private' +// ParserError 2314: (E:60-68): Expected ',' but got 'external' +// ParserError 2314: (F:60-68): Expected ',' but got 'internal' +// ParserError 2314: (G:60-66): Expected ',' but got 'public' +// ParserError 2314: (H:60-67): Expected ',' but got 'private' diff --git a/test/libsolidity/syntaxTests/visibility/invalid_variable_visibility.sol b/test/libsolidity/syntaxTests/visibility/invalid_variable_visibility.sol new file mode 100644 index 000000000..4fc73dfbe --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/invalid_variable_visibility.sol @@ -0,0 +1,29 @@ +==== Source: A ==== +contract test { + function f(uint a) public { + uint public a; + } +} +==== Source: B ==== +contract test { + function f(uint a) public { + uint private a; + } +} +==== Source: C ==== +contract test { + function f(uint a) public { + uint external a; + } +} +==== Source: D ==== +contract test { + function f(uint a) public { + uint internal a; + } +} +// ---- +// ParserError 2314: (A:61-67): Expected ';' but got 'public' +// ParserError 2314: (B:61-68): Expected ';' but got 'private' +// ParserError 2314: (C:61-69): Expected ';' but got 'external' +// ParserError 2314: (D:61-69): Expected ';' but got 'internal' diff --git a/test/libsolidity/syntaxTests/visibility/multiple_visibility_specifiers.sol b/test/libsolidity/syntaxTests/visibility/multiple_visibility_specifiers.sol new file mode 100644 index 000000000..5f3d6d687 --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/multiple_visibility_specifiers.sol @@ -0,0 +1,53 @@ +contract C { + uint private internal a; + uint private public b; + uint private private c; + uint internal internal e; + uint internal public f; + uint internal private g; + uint public internal h; + uint public public i; + uint public private j; + function f1() private external {} + function f2() private internal {} + function f3() private public {} + function f4() private private {} + function f5() external external {} + function f6() external internal {} + function f7() external public {} + function f8() external private {} + function f9() internal external {} + function f10() internal internal {} + function f11() internal public {} + function f12() internal private {} + function f13() public external {} + function f14() public internal {} + function f15() public public {} + function f16() public private {} +} +// ---- +// ParserError 4110: (30-38): Visibility already specified as "private". +// ParserError 4110: (59-65): Visibility already specified as "private". +// ParserError 4110: (86-93): Visibility already specified as "private". +// ParserError 4110: (115-123): Visibility already specified as "internal". +// ParserError 4110: (145-151): Visibility already specified as "internal". +// ParserError 4110: (173-180): Visibility already specified as "internal". +// ParserError 4110: (200-208): Visibility already specified as "public". +// ParserError 4110: (228-234): Visibility already specified as "public". +// ParserError 4110: (254-261): Visibility already specified as "public". +// ParserError 9439: (291-299): Visibility already specified as "private". +// ParserError 9439: (329-337): Visibility already specified as "private". +// ParserError 9439: (367-373): Visibility already specified as "private". +// ParserError 9439: (403-410): Visibility already specified as "private". +// ParserError 9439: (441-449): Visibility already specified as "external". +// ParserError 9439: (480-488): Visibility already specified as "external". +// ParserError 9439: (519-525): Visibility already specified as "external". +// ParserError 9439: (556-563): Visibility already specified as "external". +// ParserError 9439: (594-602): Visibility already specified as "internal". +// ParserError 9439: (634-642): Visibility already specified as "internal". +// ParserError 9439: (674-680): Visibility already specified as "internal". +// ParserError 9439: (712-719): Visibility already specified as "internal". +// ParserError 9439: (749-757): Visibility already specified as "public". +// ParserError 9439: (787-795): Visibility already specified as "public". +// ParserError 9439: (825-831): Visibility already specified as "public". +// ParserError 9439: (861-868): Visibility already specified as "public". diff --git a/test/libsolidity/syntaxTests/visibility/multiple_visibility_specifiers_external.sol b/test/libsolidity/syntaxTests/visibility/multiple_visibility_specifiers_external.sol new file mode 100644 index 000000000..b543e10a4 --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/multiple_visibility_specifiers_external.sol @@ -0,0 +1,16 @@ +==== Source: A ==== +contract C { + uint external external x; +} +==== Source: B ==== +contract C { + uint internal external x; +} +==== Source: C ==== +contract C { + uint external internal x; +} +// ---- +// ParserError 2314: (A:22-30): Expected identifier but got 'external' +// ParserError 2314: (B:31-39): Expected identifier but got 'external' +// ParserError 2314: (C:22-30): Expected identifier but got 'external'