diff options
Diffstat (limited to 'test/libsolidity/syntaxTests')
710 files changed, 5326 insertions, 1120 deletions
diff --git a/test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol b/test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol index 11d40f26..5add9106 100644 --- a/test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol +++ b/test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol @@ -1,7 +1,7 @@ contract C { - function f(uint constant LEN) { + function f(uint constant LEN) public { uint[LEN] a; } } // ---- -// TypeError: (62-65): Invalid array length, expected integer literal or constant expression. +// TypeError: (69-72): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol b/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol index ac3abc4c..2ad97d27 100644 --- a/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol +++ b/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol @@ -1,6 +1,6 @@ contract C { - function f() {} + function f() public {} uint[f] ids; } // ---- -// TypeError: (42-43): Invalid array length, expected integer literal or constant expression. +// TypeError: (49-50): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol b/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol index a6863955..bb8cc599 100644 --- a/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol +++ b/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol @@ -1,7 +1,7 @@ contract C { - function f(uint x) {} + function f(uint x) public {} uint constant LEN = f(); uint[LEN] ids; } // ---- -// TypeError: (77-80): Invalid array length, expected integer literal or constant expression. +// TypeError: (84-87): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol b/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol index 254f9f02..ee107078 100644 --- a/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol +++ b/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol @@ -2,7 +2,7 @@ contract C { uint constant L2 = LEN - 10; uint constant L1 = L2 / 10; uint constant LEN = 10 + L1 * 5; - function f() { + function f() public { uint[LEN] a; } } diff --git a/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol b/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol index 91ba9045..3adc0e9b 100644 --- a/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol +++ b/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol @@ -1,6 +1,6 @@ contract C { uint constant LEN = LEN; - function f() { + function f() public { uint[LEN] a; } } diff --git a/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol b/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol new file mode 100644 index 00000000..363d8147 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol @@ -0,0 +1,9 @@ +contract C { + function f() { + uint[] storage x; + uint[10] storage y; + } +} +// ---- +// DeclarationError: (31-47): Uninitialized storage pointer. +// DeclarationError: (51-69): Uninitialized storage pointer. diff --git a/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol b/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol index 88e94e29..0e242b30 100644 --- a/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol +++ b/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol @@ -3,4 +3,4 @@ contract C { uint constant y = x(); } // ---- -// Warning: (74-77): Initial value for constant variable has to be compile-time constant. This will fail to compile with the next breaking version change. +// TypeError: (74-77): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol index 08d20c3a..9f1d9722 100644 --- a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol @@ -1,12 +1,10 @@ contract C { uint constant a = b * c; uint constant b = 7; - uint constant c = b + uint(keccak256(d)); + uint constant c = b + uint(keccak256(abi.encodePacked(d))); uint constant d = 2 + a; } // ---- -// Warning: (98-110): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (98-110): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. // TypeError: (17-40): The value of the constant a has a cyclic dependency via c. -// TypeError: (71-111): The value of the constant c has a cyclic dependency via d. -// TypeError: (117-140): The value of the constant d has a cyclic dependency via a. +// TypeError: (71-129): The value of the constant c has a cyclic dependency via d. +// TypeError: (135-158): The value of the constant d has a cyclic dependency via a. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol index df5cd969..cc34fad2 100644 --- a/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol @@ -1,9 +1,7 @@ contract C { uint constant a = b * c; uint constant b = 7; - uint constant c = 4 + uint(keccak256(d)); + uint constant c = 4 + uint(keccak256(abi.encode(d))); uint constant d = 2 + b; } // ---- -// Warning: (98-110): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (98-110): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol new file mode 100644 index 00000000..88553084 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol @@ -0,0 +1,3 @@ +contract A { constructor() {} } +// ---- +// Warning: (13-29): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_no_visibility_050.sol b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility_050.sol new file mode 100644 index 00000000..0f57a41f --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility_050.sol @@ -0,0 +1,4 @@ +pragma experimental "v0.5.0"; +contract A { constructor() {} } +// ---- +// SyntaxError: (43-59): No visibility specified. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol index 15ed0e1e..39bf6384 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol @@ -1,13 +1,9 @@ contract test1 { - constructor() constant {} + constructor() public view {} } contract test2 { - constructor() view {} -} -contract test3 { - constructor() pure {} + constructor() public pure {} } // ---- -// TypeError: (19-44): Constructor must be payable or non-payable, but is "view". -// TypeError: (66-87): Constructor must be payable or non-payable, but is "view". -// TypeError: (109-130): Constructor must be payable or non-payable, but is "pure". +// TypeError: (19-47): Constructor must be payable or non-payable, but is "view". +// TypeError: (69-97): Constructor must be payable or non-payable, but is "pure". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol index 6dbcbc97..b9f2a4bb 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol @@ -1,16 +1,11 @@ contract test1 { - function test1() constant {} + function test1() public view {} } contract test2 { - function test2() view {} -} -contract test3 { - function test3() pure {} + function test2() public pure {} } // ---- -// Warning: (21-49): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (73-97): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (121-145): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// TypeError: (21-49): Constructor must be payable or non-payable, but is "view". -// TypeError: (73-97): Constructor must be payable or non-payable, but is "view". -// TypeError: (121-145): Constructor must be payable or non-payable, but is "pure". +// Warning: (21-52): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. +// Warning: (76-107): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. +// TypeError: (21-52): Constructor must be payable or non-payable, but is "view". +// TypeError: (76-107): Constructor must be payable or non-payable, but is "pure". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_new.sol b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_new.sol index 5e619143..6bbb83ce 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_new.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_new.sol @@ -1,5 +1,5 @@ contract C { - constructor(); + constructor() public; } // ---- -// TypeError: (14-28): Constructor must be implemented if declared. +// TypeError: (14-35): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_old.sol b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_old.sol index 72458703..12bf6315 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_old.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_old.sol @@ -1,6 +1,6 @@ contract C { - function C(); + function C() public; } // ---- -// Warning: (14-27): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// TypeError: (14-27): Constructor must be implemented if declared. +// Warning: (14-34): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. +// TypeError: (14-34): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol b/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol index fa5d54c4..2cab1851 100644 --- a/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol +++ b/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol @@ -1,7 +1,7 @@ interface I { - constructor(); + constructor() public; } // ---- -// Warning: (15-29): Functions in interfaces should be declared external. -// TypeError: (15-29): Constructor cannot be defined in interfaces. -// TypeError: (15-29): Constructor must be implemented if declared. +// Warning: (15-36): Functions in interfaces should be declared external. +// TypeError: (15-36): Constructor cannot be defined in interfaces. +// TypeError: (15-36): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol b/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol index ddf54977..313d4345 100644 --- a/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol +++ b/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol @@ -1,8 +1,8 @@ interface I { - function I(); + function I() public; } // ---- -// Warning: (15-28): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (15-28): Functions in interfaces should be declared external. -// TypeError: (15-28): Constructor cannot be defined in interfaces. -// TypeError: (15-28): Constructor must be implemented if declared. +// Warning: (15-35): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. +// Warning: (15-35): Functions in interfaces should be declared external. +// TypeError: (15-35): Constructor cannot be defined in interfaces. +// TypeError: (15-35): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/library_constructor_new.sol b/test/libsolidity/syntaxTests/constructor/library_constructor_new.sol index 8db7e62a..38934f8d 100644 --- a/test/libsolidity/syntaxTests/constructor/library_constructor_new.sol +++ b/test/libsolidity/syntaxTests/constructor/library_constructor_new.sol @@ -1,6 +1,6 @@ library Lib { - constructor(); + constructor() public; } // ---- -// TypeError: (15-29): Constructor cannot be defined in libraries. -// TypeError: (15-29): Constructor must be implemented if declared. +// TypeError: (15-36): Constructor cannot be defined in libraries. +// TypeError: (15-36): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/library_constructor_old.sol b/test/libsolidity/syntaxTests/constructor/library_constructor_old.sol index d4499049..271cc790 100644 --- a/test/libsolidity/syntaxTests/constructor/library_constructor_old.sol +++ b/test/libsolidity/syntaxTests/constructor/library_constructor_old.sol @@ -1,7 +1,7 @@ library Lib { - function Lib(); + function Lib() public; } // ---- -// Warning: (15-30): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// TypeError: (15-30): Constructor cannot be defined in libraries. -// TypeError: (15-30): Constructor must be implemented if declared. +// Warning: (15-37): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. +// TypeError: (15-37): Constructor cannot be defined in libraries. +// TypeError: (15-37): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/overriding_constructor.sol b/test/libsolidity/syntaxTests/constructor/overriding_constructor.sol index 3290a33b..5fb3a189 100644 --- a/test/libsolidity/syntaxTests/constructor/overriding_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/overriding_constructor.sol @@ -1,6 +1,10 @@ -// It is fine to "override" constructor of a base class since it is invisible -contract A { function A() public { } } +contract A { constructor() public {} } contract B is A { function A() public pure returns (uint8) {} } +contract C is A { function A() public pure returns (uint8) {} } +contract D is B { function B() public pure returns (uint8) {} } +contract E is D { function B() public pure returns (uint8) {} } // ---- -// Warning: (91-114): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (135-178): This declaration shadows an existing declaration. +// Warning: (57-100): This declaration shadows an existing declaration. +// Warning: (121-164): This declaration shadows an existing declaration. +// Warning: (185-228): This declaration shadows an existing declaration. +// Warning: (249-292): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol index 876d6fd6..ac312685 100644 --- a/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol +++ b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol @@ -1,5 +1,5 @@ contract test { - function f() { + function f() public { uint storage a1; bytes16 storage b1; uint memory a2; @@ -7,7 +7,7 @@ contract test { } } // ---- -// TypeError: (41-56): Data location can only be given for array or struct types. -// TypeError: (64-82): Data location can only be given for array or struct types. -// TypeError: (90-104): Data location can only be given for array or struct types. -// TypeError: (112-129): Data location can only be given for array or struct types. +// TypeError: (48-63): Data location can only be given for array or struct types. +// TypeError: (71-89): Data location can only be given for array or struct types. +// TypeError: (97-111): Data location can only be given for array or struct types. +// TypeError: (119-136): Data location can only be given for array or struct types. diff --git a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol index 3571e8a9..f115ac60 100644 --- a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol +++ b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol @@ -2,4 +2,4 @@ contract C { uint constant x = 0x01 wei; } // ---- -// Warning: (32-40): Hexadecimal numbers with unit denominations are deprecated. You can use an expression of the form "0x1234 * 1 day" instead. +// TypeError: (32-40): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead. diff --git a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination_050.sol b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination_050.sol deleted file mode 100644 index 98865999..00000000 --- a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination_050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - uint constant x = 0x01 wei; -} -// ---- -// TypeError: (62-70): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead. diff --git a/test/libsolidity/syntaxTests/denominations/denominations.sol b/test/libsolidity/syntaxTests/denominations/denominations.sol index 6d1aa2f3..43049a14 100644 --- a/test/libsolidity/syntaxTests/denominations/denominations.sol +++ b/test/libsolidity/syntaxTests/denominations/denominations.sol @@ -1,7 +1,6 @@ contract C { uint constant a = 1 wei + 2 szabo + 3 finney + 4 ether; - uint constant b = 1 seconds + 2 minutes + 3 hours + 4 days + 5 weeks + 6 years; + uint constant b = 1 seconds + 2 minutes + 3 hours + 4 days + 5 weeks; uint constant c = 2 szabo / 1 seconds + 3 finney * 3 hours; } // ---- -// Warning: (142-149): Using "years" as a unit denomination is deprecated. diff --git a/test/libsolidity/syntaxTests/denominations/deprecated_year.sol b/test/libsolidity/syntaxTests/denominations/deprecated_year.sol index 30e86535..691c0cb0 100644 --- a/test/libsolidity/syntaxTests/denominations/deprecated_year.sol +++ b/test/libsolidity/syntaxTests/denominations/deprecated_year.sol @@ -2,4 +2,4 @@ contract C { uint constant a = 3 years; } // ---- -// Warning: (32-39): Using "years" as a unit denomination is deprecated. +// TypeError: (32-39): Using "years" as a unit denomination is deprecated. diff --git a/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol b/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol deleted file mode 100644 index 4baaeaa3..00000000 --- a/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - uint constant a = 3 years; -} -// ---- -// TypeError: (62-69): Using "years" as a unit denomination is deprecated. diff --git a/test/libsolidity/syntaxTests/deprecated_functions.sol b/test/libsolidity/syntaxTests/deprecated_functions.sol index 9df2b43c..62dfcff9 100644 --- a/test/libsolidity/syntaxTests/deprecated_functions.sol +++ b/test/libsolidity/syntaxTests/deprecated_functions.sol @@ -1,12 +1,12 @@ contract test { function f() pure public { - bytes32 x = sha3(); + bytes32 x = sha3(""); x; } function g() public { - suicide(1); + suicide(0x0000000000000000000000000000000000000001); } } // ---- -// Warning: (58-64): "sha3" has been deprecated in favour of "keccak256" -// Warning: (99-109): "suicide" has been deprecated in favour of "selfdestruct" +// TypeError: (58-66): "sha3" has been deprecated in favour of "keccak256" +// TypeError: (101-152): "suicide" has been deprecated in favour of "selfdestruct" diff --git a/test/libsolidity/syntaxTests/deprecated_functions_050.sol b/test/libsolidity/syntaxTests/deprecated_functions_050.sol deleted file mode 100644 index b28e5abb..00000000 --- a/test/libsolidity/syntaxTests/deprecated_functions_050.sol +++ /dev/null @@ -1,15 +0,0 @@ -pragma experimental "v0.5.0"; -contract test { - function f() pure public { - bytes32 x = sha3(uint8(1)); - x; - } - function g() public { - suicide(1); - } -} -// ---- -// TypeError: (88-102): "sha3" has been deprecated in favour of "keccak256" -// TypeError: (88-102): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (88-102): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory. -// TypeError: (137-147): "suicide" has been deprecated in favour of "selfdestruct" diff --git a/test/libsolidity/syntaxTests/double_variable_declaration.sol b/test/libsolidity/syntaxTests/double_variable_declaration.sol index 9ab87959..53c5c9be 100644 --- a/test/libsolidity/syntaxTests/double_variable_declaration.sol +++ b/test/libsolidity/syntaxTests/double_variable_declaration.sol @@ -1,8 +1,9 @@ contract test { function f() pure public { uint256 x; - if (true) { uint256 x; } + x = 1; + if (true) { uint256 x; x = 2; } } } // ---- -// DeclarationError: (71-80): Identifier already declared. +// Warning: (80-89): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol b/test/libsolidity/syntaxTests/double_variable_declaration_050.sol deleted file mode 100644 index 2f47e6dc..00000000 --- a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract test { - function f() pure public { - uint256 x; - if (true) { uint256 x; } - } -} -// ---- -// Warning: (101-110): This declaration shadows an existing declaration. -// Warning: (76-85): Unused local variable. -// Warning: (101-110): Unused local variable. diff --git a/test/libsolidity/syntaxTests/emit_non_event.sol b/test/libsolidity/syntaxTests/emit_non_event.sol index 1df6990d..d5045ddf 100644 --- a/test/libsolidity/syntaxTests/emit_non_event.sol +++ b/test/libsolidity/syntaxTests/emit_non_event.sol @@ -1,10 +1,10 @@ contract C { uint256 Test; - function f() { + function f() public { emit Test(); } } // ---- -// TypeError: (56-62): Type is not callable -// TypeError: (56-60): Expression has to be an event invocation. +// TypeError: (63-69): Type is not callable +// TypeError: (63-67): Expression has to be an event invocation. diff --git a/test/libsolidity/syntaxTests/empty_string_var.sol b/test/libsolidity/syntaxTests/empty_string_var.sol deleted file mode 100644 index e9837590..00000000 --- a/test/libsolidity/syntaxTests/empty_string_var.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract C { - function f() { - var a = ""; - bytes1 b = bytes1(a); - bytes memory c = bytes(a); - string memory d = string(a); - } -} -// ---- -// Warning: (34-39): Use of the "var" keyword is deprecated. -// TypeError: (61-70): Explicit type conversion not allowed from "string memory" to "bytes1". diff --git a/test/libsolidity/syntaxTests/empty_struct.sol b/test/libsolidity/syntaxTests/empty_struct.sol index 12655309..0a52fb72 100644 --- a/test/libsolidity/syntaxTests/empty_struct.sol +++ b/test/libsolidity/syntaxTests/empty_struct.sol @@ -2,4 +2,4 @@ contract test { struct A {} } // ---- -// Warning: (17-28): Defining empty structs is deprecated. +// SyntaxError: (17-28): Defining empty structs is disallowed. diff --git a/test/libsolidity/syntaxTests/empty_struct_050.sol b/test/libsolidity/syntaxTests/empty_struct_050.sol deleted file mode 100644 index 886f1f83..00000000 --- a/test/libsolidity/syntaxTests/empty_struct_050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract test { - struct A {} -} -// ---- -// SyntaxError: (47-58): Defining empty structs is disallowed. diff --git a/test/libsolidity/syntaxTests/fallback/default_visibility.sol b/test/libsolidity/syntaxTests/fallback/default_visibility.sol new file mode 100644 index 00000000..f45bbd3c --- /dev/null +++ b/test/libsolidity/syntaxTests/fallback/default_visibility.sol @@ -0,0 +1,6 @@ +contract C { + // Check that visibility is also enforced for the fallback function. + function() {} +} +// ---- +// Warning: (90-103): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/fallback/pure_modifier.sol b/test/libsolidity/syntaxTests/fallback/pure_modifier.sol index 20d5b0ac..12d790d1 100644 --- a/test/libsolidity/syntaxTests/fallback/pure_modifier.sol +++ b/test/libsolidity/syntaxTests/fallback/pure_modifier.sol @@ -1,6 +1,6 @@ contract C { uint x; - function() pure { x = 2; } + function() external pure { x = 2; } } // ---- -// TypeError: (29-55): Fallback function must be payable or non-payable, but is "pure". +// TypeError: (29-64): Fallback function must be payable or non-payable, but is "pure". diff --git a/test/libsolidity/syntaxTests/fallback/view_modifier.sol b/test/libsolidity/syntaxTests/fallback/view_modifier.sol index 44c5d204..2497e9fa 100644 --- a/test/libsolidity/syntaxTests/fallback/view_modifier.sol +++ b/test/libsolidity/syntaxTests/fallback/view_modifier.sol @@ -1,6 +1,6 @@ contract C { uint x; - function() view { x = 2; } + function() external view { x = 2; } } // ---- -// TypeError: (29-55): Fallback function must be payable or non-payable, but is "view". +// TypeError: (29-64): Fallback function must be payable or non-payable, but is "view". diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol index a6fe6c22..2481c455 100644 --- a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol +++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol @@ -3,15 +3,13 @@ contract C { function(uint) internal returns (uint) y; function f() public { delete x; - var a = y; + function(uint) internal returns (uint) a = y; delete a; delete y; - var c = f; + function() internal c = f; delete c; function(uint) internal returns (uint) g; delete g; } } // ---- -// Warning: (157-162): Use of the "var" keyword is deprecated. -// Warning: (212-217): Use of the "var" keyword is deprecated. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol index 95ebc179..6549eb48 100644 --- a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol @@ -1,7 +1,7 @@ contract C { // Fool parser into parsing a constructor as a function type. - constructor() x; + constructor() public x; } // ---- -// Warning: (83-99): Modifiers of functions without implementation are ignored. -// DeclarationError: (97-98): Undeclared identifier. +// Warning: (83-106): Modifiers of functions without implementation are ignored. +// DeclarationError: (104-105): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol new file mode 100644 index 00000000..12191530 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol @@ -0,0 +1,5 @@ +contract C { + function(uint) returns (bool ret) f; +} +// ---- +// SyntaxError: (41-49): Return parameters in function types may not be named. diff --git a/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol b/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol index 10c6767c..e7d2c9a9 100644 --- a/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol +++ b/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol @@ -1,5 +1,5 @@ contract test { - function fa(uint) {} + function fa(uint) public {} function fb(uint) internal {} function fc(uint) internal {} function fd(uint) external {} @@ -13,11 +13,14 @@ contract test { function(uint) internal internal c = fc; function(uint) external d = this.fd; function(uint) external internal e = this.fe; - function(uint) internal public f = ff; - function(uint) internal pure public g = fg; - function(uint) pure internal public h = fh; + function(uint) internal f = ff; + function(uint) internal pure g = fg; + function(uint) pure internal h = fh; } // ---- -// TypeError: (545-582): Internal or recursive type is not allowed for public state variables. -// TypeError: (588-630): Internal or recursive type is not allowed for public state variables. -// TypeError: (636-678): Internal or recursive type is not allowed for public state variables. +// Warning: (20-47): Function state mutability can be restricted to pure +// Warning: (52-81): Function state mutability can be restricted to pure +// Warning: (86-115): Function state mutability can be restricted to pure +// Warning: (120-149): Function state mutability can be restricted to pure +// Warning: (154-183): Function state mutability can be restricted to pure +// Warning: (188-217): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol deleted file mode 100644 index 67a74e54..00000000 --- a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - function(uint) returns (bool ret) f; -} -// ---- -// Warning: (41-49): Naming function type return parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol new file mode 100644 index 00000000..e8134539 --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol @@ -0,0 +1,13 @@ +contract C { + function f() public { + require(address(this).call()); + require(address(this).call(bytes4(0x12345678))); + require(address(this).call(uint(1))); + require(address(this).call(uint(1), uint(2))); + } +} +// ---- +// TypeError: (55-75): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata. +// TypeError: (113-131): Invalid type for argument in function call. Invalid implicit conversion from bytes4 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. +// TypeError: (170-177): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. +// TypeError: (197-233): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. diff --git a/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol new file mode 100644 index 00000000..2b424d53 --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(address(this).callcode()); + require(address(this).callcode(uint(1))); + require(address(this).callcode(uint(1), uint(2))); + } +} +// ---- +// TypeError: (55-79): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata. +// TypeError: (121-128): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. +// TypeError: (148-188): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. diff --git a/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol new file mode 100644 index 00000000..be0347de --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(address(this).delegatecall()); + require(address(this).delegatecall(uint(1))); + require(address(this).delegatecall(uint(1), uint(2))); + } +} +// ---- +// TypeError: (55-83): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata. +// TypeError: (129-136): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. +// TypeError: (156-200): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. diff --git a/test/libsolidity/syntaxTests/globalFunctions/keccak256_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/keccak256_with_wrong_arg_count.sol new file mode 100644 index 00000000..4857bc2e --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/keccak256_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(keccak256() != 0); + require(keccak256(uint(1)) != 0); + require(keccak256(uint(1), uint(2)) != 0); + } +} +// ---- +// TypeError: (55-66): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (100-107): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (132-159): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. diff --git a/test/libsolidity/syntaxTests/globalFunctions/ripemd160_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/ripemd160_with_wrong_arg_count.sol new file mode 100644 index 00000000..da41fccd --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/ripemd160_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(ripemd160() != 0); + require(ripemd160(uint(1)) != 0); + require(ripemd160(uint(1), uint(2)) != 0); + } +} +// ---- +// TypeError: (55-66): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (100-107): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (132-159): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. diff --git a/test/libsolidity/syntaxTests/globalFunctions/sha256_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/sha256_with_wrong_arg_count.sol new file mode 100644 index 00000000..2939e7fc --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/sha256_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(sha256() != 0); + require(sha256(uint(1)) != 0); + require(sha256(uint(1), uint(2)) != 0); + } +} +// ---- +// TypeError: (55-63): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (94-101): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (126-150): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol index 015b33e5..96be62f2 100644 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol @@ -6,4 +6,4 @@ contract Derived is Base, Base1 { constructor(uint i) Base(i) public {} } // ---- -// Warning: (138-145): Base constructor arguments given twice. +// DeclarationError: (138-145): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol index 24cff54d..76cc937b 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol @@ -2,4 +2,4 @@ contract A { constructor(uint) public { } } contract B is A(2) { constructor() public { } } contract C is B { constructor() A(3) public { } } // ---- -// Warning: (125-129): Base constructor arguments given twice. +// DeclarationError: (125-129): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol index 9ceaea5e..4c7a684f 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol @@ -1,4 +1,4 @@ contract A { constructor(uint) public { } } contract B is A(2) { constructor() A(3) public { } } // ---- -// Warning: (79-83): Base constructor arguments given twice. +// DeclarationError: (79-83): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol index e5c2aa36..2e77e077 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol @@ -3,5 +3,5 @@ contract A is C(2) {} contract B is C(2) {} contract D is A, B { constructor() C(3) public {} } // ---- -// Warning: (122-126): Base constructor arguments given twice. -// Warning: (122-126): Base constructor arguments given twice. +// DeclarationError: (122-126): Base constructor arguments given twice. +// DeclarationError: (122-126): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol index 1abf2992..0beb1552 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol @@ -3,4 +3,4 @@ contract A is C(2) {} contract B is C(2) {} contract D is A, B {} // ---- -// Warning: (87-108): Base constructor arguments given twice. +// DeclarationError: (87-108): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol index e15242db..7142840e 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol @@ -3,4 +3,4 @@ contract A is C { constructor() C(2) public {} } contract B is C { constructor() C(2) public {} } contract D is A, B { } // ---- -// Warning: (141-163): Base constructor arguments given twice. +// DeclarationError: (141-163): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/override/add_view.sol b/test/libsolidity/syntaxTests/inheritance/override/add_view.sol index 9973b23e..21e43792 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/add_view.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/add_view.sol @@ -1,4 +1,4 @@ contract B { function f() public {} } -contract C is B { function f() view {} } +contract C is B { function f() public view {} } // ---- -// TypeError: (56-76): Overriding function changes state mutability from "nonpayable" to "view". +// TypeError: (56-83): Overriding function changes state mutability from "nonpayable" to "view". diff --git a/test/libsolidity/syntaxTests/inheritance/override/remove_view.sol b/test/libsolidity/syntaxTests/inheritance/override/remove_view.sol index e58f6b20..cc785858 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/remove_view.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/remove_view.sol @@ -1,4 +1,4 @@ -contract B { function f() view {} } +contract B { function f() public view {} } contract C is B { function f() public {} } // ---- -// TypeError: (54-76): Overriding function changes state mutability from "view" to "nonpayable". +// TypeError: (61-83): Overriding function changes state mutability from "view" to "nonpayable". diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol new file mode 100644 index 00000000..55c83674 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -0,0 +1,11 @@ +contract C { + uint[] x; + function() public { + uint[] storage y = x; + assembly { + pop(y) + } + } +} +// ---- +// TypeError: (117-118): You have to use the _slot or _offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol new file mode 100644 index 00000000..3ae24b34 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -0,0 +1,11 @@ +contract C { + uint[] x; + function() public { + uint[] storage y = x; + assembly { + pop(y_slot) + pop(y_offset) + } + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup.sol b/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup.sol index c23992e9..119df5d3 100644 --- a/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup.sol +++ b/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup.sol @@ -1,7 +1,7 @@ contract C { - function f(uint, uint) {} - function f(uint) {} - function g() { f(1, 2, 3); } + function f(uint, uint) public {} + function f(uint) public {} + function g() public { f(1, 2, 3); } } // ---- -// TypeError: (80-81): No matching declaration found after argument-dependent lookup. +// TypeError: (101-102): No matching declaration found after argument-dependent lookup. diff --git a/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup_in_library.sol b/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup_in_library.sol index 310c4a10..df0cba3f 100644 --- a/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup_in_library.sol +++ b/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup_in_library.sol @@ -1,9 +1,9 @@ library L { - function f(uint, uint) {} - function f(uint) {} + function f(uint, uint) public {} + function f(uint) public {} } contract C { - function g() { L.f(1, 2, 3); } + function g() public { L.f(1, 2, 3); } } // ---- -// TypeError: (94-97): Member "f" not found or not visible after argument-dependent lookup in type(library L) +// TypeError: (115-118): Member "f" not found or not visible after argument-dependent lookup in type(library L) diff --git a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol index bdbab5d8..49d0d7bf 100644 --- a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol +++ b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol @@ -3,5 +3,5 @@ contract B is C { constructor() C(2) C(2) public {} } // ---- -// Warning: (81-85): Base constructor arguments given twice. +// DeclarationError: (81-85): Base constructor arguments given twice. // DeclarationError: (86-90): Base constructor already provided. diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol index 00031924..76bb6fc0 100644 --- a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol @@ -2,3 +2,5 @@ contract B { function f() mod(x) pure public { uint x = 7; } modifier mod(uint a) { if (a > 0) _; } } +// ---- +// DeclarationError: (34-35): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol deleted file mode 100644 index c19ccf2c..00000000 --- a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol +++ /dev/null @@ -1,7 +0,0 @@ -pragma experimental "v0.5.0"; -contract B { - function f() mod(x) pure public { uint x = 7; } - modifier mod(uint a) { if (a > 0) _; } -} -// ---- -// DeclarationError: (64-65): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol b/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol index 2d75f29b..307b728d 100644 --- a/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol +++ b/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol @@ -1,5 +1,5 @@ contract C { - function f() { + function f() public { b = 5; b = 5; b = 5; @@ -265,260 +265,260 @@ contract C { } } // ---- -// DeclarationError: (34-35): Undeclared identifier. -// DeclarationError: (45-46): Undeclared identifier. -// DeclarationError: (56-57): Undeclared identifier. -// DeclarationError: (67-68): Undeclared identifier. -// DeclarationError: (78-79): Undeclared identifier. -// DeclarationError: (89-90): Undeclared identifier. -// DeclarationError: (100-101): Undeclared identifier. -// DeclarationError: (111-112): Undeclared identifier. -// DeclarationError: (122-123): Undeclared identifier. -// DeclarationError: (133-134): Undeclared identifier. -// DeclarationError: (144-145): Undeclared identifier. -// DeclarationError: (155-156): Undeclared identifier. -// DeclarationError: (166-167): Undeclared identifier. -// DeclarationError: (177-178): Undeclared identifier. -// DeclarationError: (188-189): Undeclared identifier. -// DeclarationError: (199-200): Undeclared identifier. -// DeclarationError: (210-211): Undeclared identifier. -// DeclarationError: (221-222): Undeclared identifier. -// DeclarationError: (232-233): Undeclared identifier. -// DeclarationError: (243-244): Undeclared identifier. -// DeclarationError: (254-255): Undeclared identifier. -// DeclarationError: (265-266): Undeclared identifier. -// DeclarationError: (276-277): Undeclared identifier. -// DeclarationError: (287-288): Undeclared identifier. -// DeclarationError: (298-299): Undeclared identifier. -// DeclarationError: (309-310): Undeclared identifier. -// DeclarationError: (320-321): Undeclared identifier. -// DeclarationError: (331-332): Undeclared identifier. -// DeclarationError: (342-343): Undeclared identifier. -// DeclarationError: (353-354): Undeclared identifier. -// DeclarationError: (364-365): Undeclared identifier. -// DeclarationError: (375-376): Undeclared identifier. -// DeclarationError: (386-387): Undeclared identifier. -// DeclarationError: (397-398): Undeclared identifier. -// DeclarationError: (408-409): Undeclared identifier. -// DeclarationError: (419-420): Undeclared identifier. -// DeclarationError: (430-431): Undeclared identifier. -// DeclarationError: (441-442): Undeclared identifier. -// DeclarationError: (452-453): Undeclared identifier. -// DeclarationError: (463-464): Undeclared identifier. -// DeclarationError: (474-475): Undeclared identifier. -// DeclarationError: (485-486): Undeclared identifier. -// DeclarationError: (496-497): Undeclared identifier. -// DeclarationError: (507-508): Undeclared identifier. -// DeclarationError: (518-519): Undeclared identifier. -// DeclarationError: (529-530): Undeclared identifier. -// DeclarationError: (540-541): Undeclared identifier. -// DeclarationError: (551-552): Undeclared identifier. -// DeclarationError: (562-563): Undeclared identifier. -// DeclarationError: (573-574): Undeclared identifier. -// DeclarationError: (584-585): Undeclared identifier. -// DeclarationError: (595-596): Undeclared identifier. -// DeclarationError: (606-607): Undeclared identifier. -// DeclarationError: (617-618): Undeclared identifier. -// DeclarationError: (628-629): Undeclared identifier. -// DeclarationError: (639-640): Undeclared identifier. -// DeclarationError: (650-651): Undeclared identifier. -// DeclarationError: (661-662): Undeclared identifier. -// DeclarationError: (672-673): Undeclared identifier. -// DeclarationError: (683-684): Undeclared identifier. -// DeclarationError: (694-695): Undeclared identifier. -// DeclarationError: (705-706): Undeclared identifier. -// DeclarationError: (716-717): Undeclared identifier. -// DeclarationError: (727-728): Undeclared identifier. -// DeclarationError: (738-739): Undeclared identifier. -// DeclarationError: (749-750): Undeclared identifier. -// DeclarationError: (760-761): Undeclared identifier. -// DeclarationError: (771-772): Undeclared identifier. -// DeclarationError: (782-783): Undeclared identifier. -// DeclarationError: (793-794): Undeclared identifier. -// DeclarationError: (804-805): Undeclared identifier. -// DeclarationError: (815-816): Undeclared identifier. -// DeclarationError: (826-827): Undeclared identifier. -// DeclarationError: (837-838): Undeclared identifier. -// DeclarationError: (848-849): Undeclared identifier. -// DeclarationError: (859-860): Undeclared identifier. -// DeclarationError: (870-871): Undeclared identifier. -// DeclarationError: (881-882): Undeclared identifier. -// DeclarationError: (892-893): Undeclared identifier. -// DeclarationError: (903-904): Undeclared identifier. -// DeclarationError: (914-915): Undeclared identifier. -// DeclarationError: (925-926): Undeclared identifier. -// DeclarationError: (936-937): Undeclared identifier. -// DeclarationError: (947-948): Undeclared identifier. -// DeclarationError: (958-959): Undeclared identifier. -// DeclarationError: (969-970): Undeclared identifier. -// DeclarationError: (980-981): Undeclared identifier. -// DeclarationError: (991-992): Undeclared identifier. -// DeclarationError: (1002-1003): Undeclared identifier. -// DeclarationError: (1013-1014): Undeclared identifier. -// DeclarationError: (1024-1025): Undeclared identifier. -// DeclarationError: (1035-1036): Undeclared identifier. -// DeclarationError: (1046-1047): Undeclared identifier. -// DeclarationError: (1057-1058): Undeclared identifier. -// DeclarationError: (1068-1069): Undeclared identifier. -// DeclarationError: (1079-1080): Undeclared identifier. -// DeclarationError: (1090-1091): Undeclared identifier. -// DeclarationError: (1101-1102): Undeclared identifier. -// DeclarationError: (1112-1113): Undeclared identifier. -// DeclarationError: (1123-1124): Undeclared identifier. -// DeclarationError: (1134-1135): Undeclared identifier. -// DeclarationError: (1145-1146): Undeclared identifier. -// DeclarationError: (1156-1157): Undeclared identifier. -// DeclarationError: (1167-1168): Undeclared identifier. -// DeclarationError: (1178-1179): Undeclared identifier. -// DeclarationError: (1189-1190): Undeclared identifier. -// DeclarationError: (1200-1201): Undeclared identifier. -// DeclarationError: (1211-1212): Undeclared identifier. -// DeclarationError: (1222-1223): Undeclared identifier. -// DeclarationError: (1233-1234): Undeclared identifier. -// DeclarationError: (1244-1245): Undeclared identifier. -// DeclarationError: (1255-1256): Undeclared identifier. -// DeclarationError: (1266-1267): Undeclared identifier. -// DeclarationError: (1277-1278): Undeclared identifier. -// DeclarationError: (1288-1289): Undeclared identifier. -// DeclarationError: (1299-1300): Undeclared identifier. -// DeclarationError: (1310-1311): Undeclared identifier. -// DeclarationError: (1321-1322): Undeclared identifier. -// DeclarationError: (1332-1333): Undeclared identifier. -// DeclarationError: (1343-1344): Undeclared identifier. -// DeclarationError: (1354-1355): Undeclared identifier. -// DeclarationError: (1365-1366): Undeclared identifier. -// DeclarationError: (1376-1377): Undeclared identifier. -// DeclarationError: (1387-1388): Undeclared identifier. -// DeclarationError: (1398-1399): Undeclared identifier. -// DeclarationError: (1409-1410): Undeclared identifier. -// DeclarationError: (1420-1421): Undeclared identifier. -// DeclarationError: (1431-1432): Undeclared identifier. -// DeclarationError: (1442-1443): Undeclared identifier. -// DeclarationError: (1453-1454): Undeclared identifier. -// DeclarationError: (1464-1465): Undeclared identifier. -// DeclarationError: (1475-1476): Undeclared identifier. -// DeclarationError: (1486-1487): Undeclared identifier. -// DeclarationError: (1497-1498): Undeclared identifier. -// DeclarationError: (1508-1509): Undeclared identifier. -// DeclarationError: (1519-1520): Undeclared identifier. -// DeclarationError: (1530-1531): Undeclared identifier. -// DeclarationError: (1541-1542): Undeclared identifier. -// DeclarationError: (1552-1553): Undeclared identifier. -// DeclarationError: (1563-1564): Undeclared identifier. -// DeclarationError: (1574-1575): Undeclared identifier. -// DeclarationError: (1585-1586): Undeclared identifier. -// DeclarationError: (1596-1597): Undeclared identifier. -// DeclarationError: (1607-1608): Undeclared identifier. -// DeclarationError: (1618-1619): Undeclared identifier. -// DeclarationError: (1629-1630): Undeclared identifier. -// DeclarationError: (1640-1641): Undeclared identifier. -// DeclarationError: (1651-1652): Undeclared identifier. -// DeclarationError: (1662-1663): Undeclared identifier. -// DeclarationError: (1673-1674): Undeclared identifier. -// DeclarationError: (1684-1685): Undeclared identifier. -// DeclarationError: (1695-1696): Undeclared identifier. -// DeclarationError: (1706-1707): Undeclared identifier. -// DeclarationError: (1717-1718): Undeclared identifier. -// DeclarationError: (1728-1729): Undeclared identifier. -// DeclarationError: (1739-1740): Undeclared identifier. -// DeclarationError: (1750-1751): Undeclared identifier. -// DeclarationError: (1761-1762): Undeclared identifier. -// DeclarationError: (1772-1773): Undeclared identifier. -// DeclarationError: (1783-1784): Undeclared identifier. -// DeclarationError: (1794-1795): Undeclared identifier. -// DeclarationError: (1805-1806): Undeclared identifier. -// DeclarationError: (1816-1817): Undeclared identifier. -// DeclarationError: (1827-1828): Undeclared identifier. -// DeclarationError: (1838-1839): Undeclared identifier. -// DeclarationError: (1849-1850): Undeclared identifier. -// DeclarationError: (1860-1861): Undeclared identifier. -// DeclarationError: (1871-1872): Undeclared identifier. -// DeclarationError: (1882-1883): Undeclared identifier. -// DeclarationError: (1893-1894): Undeclared identifier. -// DeclarationError: (1904-1905): Undeclared identifier. -// DeclarationError: (1915-1916): Undeclared identifier. -// DeclarationError: (1926-1927): Undeclared identifier. -// DeclarationError: (1937-1938): Undeclared identifier. -// DeclarationError: (1948-1949): Undeclared identifier. -// DeclarationError: (1959-1960): Undeclared identifier. -// DeclarationError: (1970-1971): Undeclared identifier. -// DeclarationError: (1981-1982): Undeclared identifier. -// DeclarationError: (1992-1993): Undeclared identifier. -// DeclarationError: (2003-2004): Undeclared identifier. -// DeclarationError: (2014-2015): Undeclared identifier. -// DeclarationError: (2025-2026): Undeclared identifier. -// DeclarationError: (2036-2037): Undeclared identifier. -// DeclarationError: (2047-2048): Undeclared identifier. -// DeclarationError: (2058-2059): Undeclared identifier. -// DeclarationError: (2069-2070): Undeclared identifier. -// DeclarationError: (2080-2081): Undeclared identifier. -// DeclarationError: (2091-2092): Undeclared identifier. -// DeclarationError: (2102-2103): Undeclared identifier. -// DeclarationError: (2113-2114): Undeclared identifier. -// DeclarationError: (2124-2125): Undeclared identifier. -// DeclarationError: (2135-2136): Undeclared identifier. -// DeclarationError: (2146-2147): Undeclared identifier. -// DeclarationError: (2157-2158): Undeclared identifier. -// DeclarationError: (2168-2169): Undeclared identifier. -// DeclarationError: (2179-2180): Undeclared identifier. -// DeclarationError: (2190-2191): Undeclared identifier. -// DeclarationError: (2201-2202): Undeclared identifier. -// DeclarationError: (2212-2213): Undeclared identifier. -// DeclarationError: (2223-2224): Undeclared identifier. -// DeclarationError: (2234-2235): Undeclared identifier. -// DeclarationError: (2245-2246): Undeclared identifier. -// DeclarationError: (2256-2257): Undeclared identifier. -// DeclarationError: (2267-2268): Undeclared identifier. -// DeclarationError: (2278-2279): Undeclared identifier. -// DeclarationError: (2289-2290): Undeclared identifier. -// DeclarationError: (2300-2301): Undeclared identifier. -// DeclarationError: (2311-2312): Undeclared identifier. -// DeclarationError: (2322-2323): Undeclared identifier. -// DeclarationError: (2333-2334): Undeclared identifier. -// DeclarationError: (2344-2345): Undeclared identifier. -// DeclarationError: (2355-2356): Undeclared identifier. -// DeclarationError: (2366-2367): Undeclared identifier. -// DeclarationError: (2377-2378): Undeclared identifier. -// DeclarationError: (2388-2389): Undeclared identifier. -// DeclarationError: (2399-2400): Undeclared identifier. -// DeclarationError: (2410-2411): Undeclared identifier. -// DeclarationError: (2421-2422): Undeclared identifier. -// DeclarationError: (2432-2433): Undeclared identifier. -// DeclarationError: (2443-2444): Undeclared identifier. -// DeclarationError: (2454-2455): Undeclared identifier. -// DeclarationError: (2465-2466): Undeclared identifier. -// DeclarationError: (2476-2477): Undeclared identifier. -// DeclarationError: (2487-2488): Undeclared identifier. -// DeclarationError: (2498-2499): Undeclared identifier. -// DeclarationError: (2509-2510): Undeclared identifier. -// DeclarationError: (2520-2521): Undeclared identifier. -// DeclarationError: (2531-2532): Undeclared identifier. -// DeclarationError: (2542-2543): Undeclared identifier. -// DeclarationError: (2553-2554): Undeclared identifier. -// DeclarationError: (2564-2565): Undeclared identifier. -// DeclarationError: (2575-2576): Undeclared identifier. -// DeclarationError: (2586-2587): Undeclared identifier. -// DeclarationError: (2597-2598): Undeclared identifier. -// DeclarationError: (2608-2609): Undeclared identifier. -// DeclarationError: (2619-2620): Undeclared identifier. -// DeclarationError: (2630-2631): Undeclared identifier. -// DeclarationError: (2641-2642): Undeclared identifier. -// DeclarationError: (2652-2653): Undeclared identifier. -// DeclarationError: (2663-2664): Undeclared identifier. -// DeclarationError: (2674-2675): Undeclared identifier. -// DeclarationError: (2685-2686): Undeclared identifier. -// DeclarationError: (2696-2697): Undeclared identifier. -// DeclarationError: (2707-2708): Undeclared identifier. -// DeclarationError: (2718-2719): Undeclared identifier. -// DeclarationError: (2729-2730): Undeclared identifier. -// DeclarationError: (2740-2741): Undeclared identifier. -// DeclarationError: (2751-2752): Undeclared identifier. -// DeclarationError: (2762-2763): Undeclared identifier. -// DeclarationError: (2773-2774): Undeclared identifier. -// DeclarationError: (2784-2785): Undeclared identifier. -// DeclarationError: (2795-2796): Undeclared identifier. -// DeclarationError: (2806-2807): Undeclared identifier. -// DeclarationError: (2817-2818): Undeclared identifier. -// DeclarationError: (2828-2829): Undeclared identifier. -// DeclarationError: (2839-2840): Undeclared identifier. +// DeclarationError: (41-42): Undeclared identifier. +// DeclarationError: (52-53): Undeclared identifier. +// DeclarationError: (63-64): Undeclared identifier. +// DeclarationError: (74-75): Undeclared identifier. +// DeclarationError: (85-86): Undeclared identifier. +// DeclarationError: (96-97): Undeclared identifier. +// DeclarationError: (107-108): Undeclared identifier. +// DeclarationError: (118-119): Undeclared identifier. +// DeclarationError: (129-130): Undeclared identifier. +// DeclarationError: (140-141): Undeclared identifier. +// DeclarationError: (151-152): Undeclared identifier. +// DeclarationError: (162-163): Undeclared identifier. +// DeclarationError: (173-174): Undeclared identifier. +// DeclarationError: (184-185): Undeclared identifier. +// DeclarationError: (195-196): Undeclared identifier. +// DeclarationError: (206-207): Undeclared identifier. +// DeclarationError: (217-218): Undeclared identifier. +// DeclarationError: (228-229): Undeclared identifier. +// DeclarationError: (239-240): Undeclared identifier. +// DeclarationError: (250-251): Undeclared identifier. +// DeclarationError: (261-262): Undeclared identifier. +// DeclarationError: (272-273): Undeclared identifier. +// DeclarationError: (283-284): Undeclared identifier. +// DeclarationError: (294-295): Undeclared identifier. +// DeclarationError: (305-306): Undeclared identifier. +// DeclarationError: (316-317): Undeclared identifier. +// DeclarationError: (327-328): Undeclared identifier. +// DeclarationError: (338-339): Undeclared identifier. +// DeclarationError: (349-350): Undeclared identifier. +// DeclarationError: (360-361): Undeclared identifier. +// DeclarationError: (371-372): Undeclared identifier. +// DeclarationError: (382-383): Undeclared identifier. +// DeclarationError: (393-394): Undeclared identifier. +// DeclarationError: (404-405): Undeclared identifier. +// DeclarationError: (415-416): Undeclared identifier. +// DeclarationError: (426-427): Undeclared identifier. +// DeclarationError: (437-438): Undeclared identifier. +// DeclarationError: (448-449): Undeclared identifier. +// DeclarationError: (459-460): Undeclared identifier. +// DeclarationError: (470-471): Undeclared identifier. +// DeclarationError: (481-482): Undeclared identifier. +// DeclarationError: (492-493): Undeclared identifier. +// DeclarationError: (503-504): Undeclared identifier. +// DeclarationError: (514-515): Undeclared identifier. +// DeclarationError: (525-526): Undeclared identifier. +// DeclarationError: (536-537): Undeclared identifier. +// DeclarationError: (547-548): Undeclared identifier. +// DeclarationError: (558-559): Undeclared identifier. +// DeclarationError: (569-570): Undeclared identifier. +// DeclarationError: (580-581): Undeclared identifier. +// DeclarationError: (591-592): Undeclared identifier. +// DeclarationError: (602-603): Undeclared identifier. +// DeclarationError: (613-614): Undeclared identifier. +// DeclarationError: (624-625): Undeclared identifier. +// DeclarationError: (635-636): Undeclared identifier. +// DeclarationError: (646-647): Undeclared identifier. +// DeclarationError: (657-658): Undeclared identifier. +// DeclarationError: (668-669): Undeclared identifier. +// DeclarationError: (679-680): Undeclared identifier. +// DeclarationError: (690-691): Undeclared identifier. +// DeclarationError: (701-702): Undeclared identifier. +// DeclarationError: (712-713): Undeclared identifier. +// DeclarationError: (723-724): Undeclared identifier. +// DeclarationError: (734-735): Undeclared identifier. +// DeclarationError: (745-746): Undeclared identifier. +// DeclarationError: (756-757): Undeclared identifier. +// DeclarationError: (767-768): Undeclared identifier. +// DeclarationError: (778-779): Undeclared identifier. +// DeclarationError: (789-790): Undeclared identifier. +// DeclarationError: (800-801): Undeclared identifier. +// DeclarationError: (811-812): Undeclared identifier. +// DeclarationError: (822-823): Undeclared identifier. +// DeclarationError: (833-834): Undeclared identifier. +// DeclarationError: (844-845): Undeclared identifier. +// DeclarationError: (855-856): Undeclared identifier. +// DeclarationError: (866-867): Undeclared identifier. +// DeclarationError: (877-878): Undeclared identifier. +// DeclarationError: (888-889): Undeclared identifier. +// DeclarationError: (899-900): Undeclared identifier. +// DeclarationError: (910-911): Undeclared identifier. +// DeclarationError: (921-922): Undeclared identifier. +// DeclarationError: (932-933): Undeclared identifier. +// DeclarationError: (943-944): Undeclared identifier. +// DeclarationError: (954-955): Undeclared identifier. +// DeclarationError: (965-966): Undeclared identifier. +// DeclarationError: (976-977): Undeclared identifier. +// DeclarationError: (987-988): Undeclared identifier. +// DeclarationError: (998-999): Undeclared identifier. +// DeclarationError: (1009-1010): Undeclared identifier. +// DeclarationError: (1020-1021): Undeclared identifier. +// DeclarationError: (1031-1032): Undeclared identifier. +// DeclarationError: (1042-1043): Undeclared identifier. +// DeclarationError: (1053-1054): Undeclared identifier. +// DeclarationError: (1064-1065): Undeclared identifier. +// DeclarationError: (1075-1076): Undeclared identifier. +// DeclarationError: (1086-1087): Undeclared identifier. +// DeclarationError: (1097-1098): Undeclared identifier. +// DeclarationError: (1108-1109): Undeclared identifier. +// DeclarationError: (1119-1120): Undeclared identifier. +// DeclarationError: (1130-1131): Undeclared identifier. +// DeclarationError: (1141-1142): Undeclared identifier. +// DeclarationError: (1152-1153): Undeclared identifier. +// DeclarationError: (1163-1164): Undeclared identifier. +// DeclarationError: (1174-1175): Undeclared identifier. +// DeclarationError: (1185-1186): Undeclared identifier. +// DeclarationError: (1196-1197): Undeclared identifier. +// DeclarationError: (1207-1208): Undeclared identifier. +// DeclarationError: (1218-1219): Undeclared identifier. +// DeclarationError: (1229-1230): Undeclared identifier. +// DeclarationError: (1240-1241): Undeclared identifier. +// DeclarationError: (1251-1252): Undeclared identifier. +// DeclarationError: (1262-1263): Undeclared identifier. +// DeclarationError: (1273-1274): Undeclared identifier. +// DeclarationError: (1284-1285): Undeclared identifier. +// DeclarationError: (1295-1296): Undeclared identifier. +// DeclarationError: (1306-1307): Undeclared identifier. +// DeclarationError: (1317-1318): Undeclared identifier. +// DeclarationError: (1328-1329): Undeclared identifier. +// DeclarationError: (1339-1340): Undeclared identifier. +// DeclarationError: (1350-1351): Undeclared identifier. +// DeclarationError: (1361-1362): Undeclared identifier. +// DeclarationError: (1372-1373): Undeclared identifier. +// DeclarationError: (1383-1384): Undeclared identifier. +// DeclarationError: (1394-1395): Undeclared identifier. +// DeclarationError: (1405-1406): Undeclared identifier. +// DeclarationError: (1416-1417): Undeclared identifier. +// DeclarationError: (1427-1428): Undeclared identifier. +// DeclarationError: (1438-1439): Undeclared identifier. +// DeclarationError: (1449-1450): Undeclared identifier. +// DeclarationError: (1460-1461): Undeclared identifier. +// DeclarationError: (1471-1472): Undeclared identifier. +// DeclarationError: (1482-1483): Undeclared identifier. +// DeclarationError: (1493-1494): Undeclared identifier. +// DeclarationError: (1504-1505): Undeclared identifier. +// DeclarationError: (1515-1516): Undeclared identifier. +// DeclarationError: (1526-1527): Undeclared identifier. +// DeclarationError: (1537-1538): Undeclared identifier. +// DeclarationError: (1548-1549): Undeclared identifier. +// DeclarationError: (1559-1560): Undeclared identifier. +// DeclarationError: (1570-1571): Undeclared identifier. +// DeclarationError: (1581-1582): Undeclared identifier. +// DeclarationError: (1592-1593): Undeclared identifier. +// DeclarationError: (1603-1604): Undeclared identifier. +// DeclarationError: (1614-1615): Undeclared identifier. +// DeclarationError: (1625-1626): Undeclared identifier. +// DeclarationError: (1636-1637): Undeclared identifier. +// DeclarationError: (1647-1648): Undeclared identifier. +// DeclarationError: (1658-1659): Undeclared identifier. +// DeclarationError: (1669-1670): Undeclared identifier. +// DeclarationError: (1680-1681): Undeclared identifier. +// DeclarationError: (1691-1692): Undeclared identifier. +// DeclarationError: (1702-1703): Undeclared identifier. +// DeclarationError: (1713-1714): Undeclared identifier. +// DeclarationError: (1724-1725): Undeclared identifier. +// DeclarationError: (1735-1736): Undeclared identifier. +// DeclarationError: (1746-1747): Undeclared identifier. +// DeclarationError: (1757-1758): Undeclared identifier. +// DeclarationError: (1768-1769): Undeclared identifier. +// DeclarationError: (1779-1780): Undeclared identifier. +// DeclarationError: (1790-1791): Undeclared identifier. +// DeclarationError: (1801-1802): Undeclared identifier. +// DeclarationError: (1812-1813): Undeclared identifier. +// DeclarationError: (1823-1824): Undeclared identifier. +// DeclarationError: (1834-1835): Undeclared identifier. +// DeclarationError: (1845-1846): Undeclared identifier. +// DeclarationError: (1856-1857): Undeclared identifier. +// DeclarationError: (1867-1868): Undeclared identifier. +// DeclarationError: (1878-1879): Undeclared identifier. +// DeclarationError: (1889-1890): Undeclared identifier. +// DeclarationError: (1900-1901): Undeclared identifier. +// DeclarationError: (1911-1912): Undeclared identifier. +// DeclarationError: (1922-1923): Undeclared identifier. +// DeclarationError: (1933-1934): Undeclared identifier. +// DeclarationError: (1944-1945): Undeclared identifier. +// DeclarationError: (1955-1956): Undeclared identifier. +// DeclarationError: (1966-1967): Undeclared identifier. +// DeclarationError: (1977-1978): Undeclared identifier. +// DeclarationError: (1988-1989): Undeclared identifier. +// DeclarationError: (1999-2000): Undeclared identifier. +// DeclarationError: (2010-2011): Undeclared identifier. +// DeclarationError: (2021-2022): Undeclared identifier. +// DeclarationError: (2032-2033): Undeclared identifier. +// DeclarationError: (2043-2044): Undeclared identifier. +// DeclarationError: (2054-2055): Undeclared identifier. +// DeclarationError: (2065-2066): Undeclared identifier. +// DeclarationError: (2076-2077): Undeclared identifier. +// DeclarationError: (2087-2088): Undeclared identifier. +// DeclarationError: (2098-2099): Undeclared identifier. +// DeclarationError: (2109-2110): Undeclared identifier. +// DeclarationError: (2120-2121): Undeclared identifier. +// DeclarationError: (2131-2132): Undeclared identifier. +// DeclarationError: (2142-2143): Undeclared identifier. +// DeclarationError: (2153-2154): Undeclared identifier. +// DeclarationError: (2164-2165): Undeclared identifier. +// DeclarationError: (2175-2176): Undeclared identifier. +// DeclarationError: (2186-2187): Undeclared identifier. +// DeclarationError: (2197-2198): Undeclared identifier. +// DeclarationError: (2208-2209): Undeclared identifier. +// DeclarationError: (2219-2220): Undeclared identifier. +// DeclarationError: (2230-2231): Undeclared identifier. +// DeclarationError: (2241-2242): Undeclared identifier. +// DeclarationError: (2252-2253): Undeclared identifier. +// DeclarationError: (2263-2264): Undeclared identifier. +// DeclarationError: (2274-2275): Undeclared identifier. +// DeclarationError: (2285-2286): Undeclared identifier. +// DeclarationError: (2296-2297): Undeclared identifier. +// DeclarationError: (2307-2308): Undeclared identifier. +// DeclarationError: (2318-2319): Undeclared identifier. +// DeclarationError: (2329-2330): Undeclared identifier. +// DeclarationError: (2340-2341): Undeclared identifier. +// DeclarationError: (2351-2352): Undeclared identifier. +// DeclarationError: (2362-2363): Undeclared identifier. +// DeclarationError: (2373-2374): Undeclared identifier. +// DeclarationError: (2384-2385): Undeclared identifier. +// DeclarationError: (2395-2396): Undeclared identifier. +// DeclarationError: (2406-2407): Undeclared identifier. +// DeclarationError: (2417-2418): Undeclared identifier. +// DeclarationError: (2428-2429): Undeclared identifier. +// DeclarationError: (2439-2440): Undeclared identifier. +// DeclarationError: (2450-2451): Undeclared identifier. +// DeclarationError: (2461-2462): Undeclared identifier. +// DeclarationError: (2472-2473): Undeclared identifier. +// DeclarationError: (2483-2484): Undeclared identifier. +// DeclarationError: (2494-2495): Undeclared identifier. +// DeclarationError: (2505-2506): Undeclared identifier. +// DeclarationError: (2516-2517): Undeclared identifier. +// DeclarationError: (2527-2528): Undeclared identifier. +// DeclarationError: (2538-2539): Undeclared identifier. +// DeclarationError: (2549-2550): Undeclared identifier. +// DeclarationError: (2560-2561): Undeclared identifier. +// DeclarationError: (2571-2572): Undeclared identifier. +// DeclarationError: (2582-2583): Undeclared identifier. +// DeclarationError: (2593-2594): Undeclared identifier. +// DeclarationError: (2604-2605): Undeclared identifier. +// DeclarationError: (2615-2616): Undeclared identifier. +// DeclarationError: (2626-2627): Undeclared identifier. +// DeclarationError: (2637-2638): Undeclared identifier. +// DeclarationError: (2648-2649): Undeclared identifier. +// DeclarationError: (2659-2660): Undeclared identifier. +// DeclarationError: (2670-2671): Undeclared identifier. +// DeclarationError: (2681-2682): Undeclared identifier. +// DeclarationError: (2692-2693): Undeclared identifier. +// DeclarationError: (2703-2704): Undeclared identifier. +// DeclarationError: (2714-2715): Undeclared identifier. +// DeclarationError: (2725-2726): Undeclared identifier. +// DeclarationError: (2736-2737): Undeclared identifier. +// DeclarationError: (2747-2748): Undeclared identifier. +// DeclarationError: (2758-2759): Undeclared identifier. +// DeclarationError: (2769-2770): Undeclared identifier. +// DeclarationError: (2780-2781): Undeclared identifier. +// DeclarationError: (2791-2792): Undeclared identifier. +// DeclarationError: (2802-2803): Undeclared identifier. +// DeclarationError: (2813-2814): Undeclared identifier. +// DeclarationError: (2824-2825): Undeclared identifier. +// DeclarationError: (2835-2836): Undeclared identifier. +// DeclarationError: (2846-2847): Undeclared identifier. // Warning: There are more than 256 errors. Aborting. diff --git a/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol b/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol index 2c9b8a42..fe877396 100644 --- a/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol +++ b/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol @@ -1,5 +1,5 @@ contract C { - function f() { + function f() public { continue; continue; continue; @@ -265,260 +265,260 @@ contract C { } } // ---- -// SyntaxError: (34-42): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (48-56): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (62-70): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (76-84): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (90-98): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (104-112): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (118-126): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (132-140): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (146-154): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (160-168): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (174-182): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (188-196): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (202-210): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (216-224): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (230-238): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (244-252): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (258-266): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (272-280): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (286-294): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (300-308): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (314-322): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (328-336): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (342-350): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (356-364): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (370-378): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (384-392): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (398-406): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (412-420): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (426-434): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (440-448): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (454-462): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (468-476): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (482-490): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (496-504): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (510-518): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (524-532): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (538-546): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (552-560): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (566-574): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (580-588): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (594-602): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (608-616): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (622-630): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (636-644): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (650-658): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (664-672): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (678-686): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (692-700): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (706-714): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (720-728): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (734-742): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (748-756): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (762-770): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (776-784): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (790-798): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (804-812): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (818-826): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (832-840): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (846-854): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (860-868): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (874-882): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (888-896): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (902-910): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (916-924): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (930-938): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (944-952): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (958-966): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (972-980): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (986-994): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1000-1008): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1014-1022): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1028-1036): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1042-1050): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1056-1064): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1070-1078): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1084-1092): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1098-1106): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1112-1120): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1126-1134): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1140-1148): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1154-1162): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1168-1176): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1182-1190): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1196-1204): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1210-1218): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1224-1232): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1238-1246): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1252-1260): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1266-1274): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1280-1288): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1294-1302): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1308-1316): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1322-1330): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1336-1344): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1350-1358): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1364-1372): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1378-1386): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1392-1400): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1406-1414): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1420-1428): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1434-1442): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1448-1456): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1462-1470): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1476-1484): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1490-1498): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1504-1512): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1518-1526): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1532-1540): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1546-1554): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1560-1568): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1574-1582): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1588-1596): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1602-1610): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1616-1624): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1630-1638): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1644-1652): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1658-1666): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1672-1680): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1686-1694): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1700-1708): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1714-1722): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1728-1736): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1742-1750): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1756-1764): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1770-1778): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1784-1792): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1798-1806): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1812-1820): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1826-1834): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1840-1848): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1854-1862): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1868-1876): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1882-1890): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1896-1904): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1910-1918): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1924-1932): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1938-1946): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1952-1960): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1966-1974): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1980-1988): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (1994-2002): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2008-2016): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2022-2030): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2036-2044): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2050-2058): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2064-2072): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2078-2086): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2092-2100): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2106-2114): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2120-2128): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2134-2142): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2148-2156): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2162-2170): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2176-2184): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2190-2198): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2204-2212): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2218-2226): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2232-2240): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2246-2254): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2260-2268): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2274-2282): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2288-2296): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2302-2310): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2316-2324): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2330-2338): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2344-2352): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2358-2366): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2372-2380): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2386-2394): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2400-2408): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2414-2422): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2428-2436): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2442-2450): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2456-2464): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2470-2478): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2484-2492): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2498-2506): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2512-2520): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2526-2534): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2540-2548): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2554-2562): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2568-2576): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2582-2590): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2596-2604): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2610-2618): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2624-2632): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2638-2646): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2652-2660): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2666-2674): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2680-2688): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2694-2702): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2708-2716): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2722-2730): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2736-2744): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2750-2758): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2764-2772): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2778-2786): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2792-2800): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2806-2814): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2820-2828): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2834-2842): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2848-2856): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2862-2870): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2876-2884): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2890-2898): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2904-2912): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2918-2926): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2932-2940): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2946-2954): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2960-2968): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2974-2982): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (2988-2996): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3002-3010): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3016-3024): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3030-3038): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3044-3052): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3058-3066): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3072-3080): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3086-3094): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3100-3108): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3114-3122): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3128-3136): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3142-3150): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3156-3164): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3170-3178): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3184-3192): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3198-3206): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3212-3220): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3226-3234): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3240-3248): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3254-3262): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3268-3276): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3282-3290): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3296-3304): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3310-3318): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3324-3332): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3338-3346): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3352-3360): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3366-3374): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3380-3388): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3394-3402): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3408-3416): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3422-3430): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3436-3444): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3450-3458): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3464-3472): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3478-3486): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3492-3500): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3506-3514): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3520-3528): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3534-3542): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3548-3556): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3562-3570): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3576-3584): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3590-3598): "continue" has to be in a "for" or "while" loop. -// SyntaxError: (3604-3612): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (41-49): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (55-63): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (69-77): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (83-91): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (97-105): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (111-119): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (125-133): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (139-147): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (153-161): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (167-175): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (181-189): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (195-203): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (209-217): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (223-231): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (237-245): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (251-259): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (265-273): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (279-287): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (293-301): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (307-315): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (321-329): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (335-343): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (349-357): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (363-371): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (377-385): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (391-399): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (405-413): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (419-427): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (433-441): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (447-455): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (461-469): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (475-483): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (489-497): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (503-511): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (517-525): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (531-539): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (545-553): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (559-567): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (573-581): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (587-595): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (601-609): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (615-623): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (629-637): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (643-651): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (657-665): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (671-679): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (685-693): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (699-707): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (713-721): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (727-735): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (741-749): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (755-763): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (769-777): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (783-791): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (797-805): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (811-819): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (825-833): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (839-847): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (853-861): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (867-875): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (881-889): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (895-903): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (909-917): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (923-931): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (937-945): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (951-959): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (965-973): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (979-987): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (993-1001): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1007-1015): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1021-1029): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1035-1043): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1049-1057): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1063-1071): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1077-1085): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1091-1099): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1105-1113): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1119-1127): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1133-1141): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1147-1155): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1161-1169): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1175-1183): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1189-1197): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1203-1211): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1217-1225): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1231-1239): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1245-1253): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1259-1267): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1273-1281): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1287-1295): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1301-1309): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1315-1323): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1329-1337): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1343-1351): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1357-1365): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1371-1379): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1385-1393): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1399-1407): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1413-1421): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1427-1435): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1441-1449): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1455-1463): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1469-1477): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1483-1491): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1497-1505): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1511-1519): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1525-1533): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1539-1547): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1553-1561): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1567-1575): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1581-1589): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1595-1603): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1609-1617): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1623-1631): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1637-1645): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1651-1659): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1665-1673): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1679-1687): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1693-1701): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1707-1715): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1721-1729): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1735-1743): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1749-1757): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1763-1771): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1777-1785): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1791-1799): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1805-1813): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1819-1827): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1833-1841): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1847-1855): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1861-1869): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1875-1883): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1889-1897): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1903-1911): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1917-1925): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1931-1939): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1945-1953): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1959-1967): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1973-1981): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1987-1995): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2001-2009): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2015-2023): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2029-2037): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2043-2051): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2057-2065): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2071-2079): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2085-2093): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2099-2107): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2113-2121): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2127-2135): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2141-2149): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2155-2163): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2169-2177): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2183-2191): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2197-2205): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2211-2219): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2225-2233): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2239-2247): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2253-2261): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2267-2275): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2281-2289): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2295-2303): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2309-2317): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2323-2331): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2337-2345): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2351-2359): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2365-2373): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2379-2387): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2393-2401): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2407-2415): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2421-2429): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2435-2443): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2449-2457): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2463-2471): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2477-2485): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2491-2499): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2505-2513): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2519-2527): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2533-2541): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2547-2555): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2561-2569): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2575-2583): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2589-2597): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2603-2611): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2617-2625): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2631-2639): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2645-2653): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2659-2667): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2673-2681): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2687-2695): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2701-2709): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2715-2723): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2729-2737): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2743-2751): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2757-2765): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2771-2779): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2785-2793): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2799-2807): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2813-2821): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2827-2835): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2841-2849): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2855-2863): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2869-2877): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2883-2891): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2897-2905): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2911-2919): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2925-2933): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2939-2947): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2953-2961): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2967-2975): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2981-2989): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2995-3003): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3009-3017): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3023-3031): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3037-3045): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3051-3059): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3065-3073): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3079-3087): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3093-3101): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3107-3115): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3121-3129): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3135-3143): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3149-3157): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3163-3171): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3177-3185): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3191-3199): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3205-3213): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3219-3227): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3233-3241): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3247-3255): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3261-3269): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3275-3283): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3289-3297): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3303-3311): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3317-3325): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3331-3339): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3345-3353): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3359-3367): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3373-3381): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3387-3395): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3401-3409): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3415-3423): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3429-3437): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3443-3451): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3457-3465): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3471-3479): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3485-3493): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3499-3507): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3513-3521): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3527-3535): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3541-3549): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3555-3563): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3569-3577): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3583-3591): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3597-3605): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3611-3619): "continue" has to be in a "for" or "while" loop. // Warning: There are more than 256 errors. Aborting. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol deleted file mode 100644 index c8686ae8..00000000 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract C { - function f() internal returns (uint, uint, uint, uint) { - var (uint a, uint b,,) = f(); - a; b; - } -} -// ---- -// ParserError: (81-85): Expected identifier but got 'uint' diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol index 3ba85f69..224d9614 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol @@ -1,5 +1,3 @@ -pragma experimental "v0.5.0"; - contract C { function f() internal { { @@ -9,4 +7,4 @@ contract C { } } // ---- -// DeclarationError: (130-131): Undeclared identifier. +// DeclarationError: (99-100): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol index e21181de..242a1f39 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol @@ -1,5 +1,3 @@ -pragma experimental "v0.5.0"; - contract C { function f() internal { { @@ -8,6 +6,6 @@ contract C { } } // ---- -// DeclarationError: (110-111): Undeclared identifier. Did you mean "a"? -// DeclarationError: (113-114): Undeclared identifier. Did you mean "b"? -// DeclarationError: (116-117): Undeclared identifier. Did you mean "c"? +// DeclarationError: (79-80): Undeclared identifier. "a" is not (or not yet) visible at this point. +// DeclarationError: (82-83): Undeclared identifier. "b" is not (or not yet) visible at this point. +// DeclarationError: (85-86): Undeclared identifier. "c" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/001_name_references.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/001_name_references.sol new file mode 100644 index 00000000..dc304a1d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/001_name_references.sol @@ -0,0 +1,4 @@ +contract test { + uint256 variable; + function f(uint256) public returns (uint out) { f(variable); test; out; } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/002_undeclared_name.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/002_undeclared_name.sol new file mode 100644 index 00000000..afe9483f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/002_undeclared_name.sol @@ -0,0 +1,8 @@ +contract test { + uint256 variable; + function f(uint256 arg) public { + f(notfound); + } +} +// ---- +// DeclarationError: (85-93): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/003_undeclared_name_is_not_fatal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/003_undeclared_name_is_not_fatal.sol new file mode 100644 index 00000000..0f2a1526 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/003_undeclared_name_is_not_fatal.sol @@ -0,0 +1,10 @@ +contract test { + uint256 variable; + function f(uint256 arg) public { + f(notfound); + f(notfound); + } +} +// ---- +// DeclarationError: (85-93): Undeclared identifier. +// DeclarationError: (106-114): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol new file mode 100644 index 00000000..e112e16c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol @@ -0,0 +1,6 @@ +contract test { + function g() public { f(); } + function f() public {} +} +// ---- +// Warning: (53-75): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/006_type_checking_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/006_type_checking_return.sol new file mode 100644 index 00000000..d0e87139 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/006_type_checking_return.sol @@ -0,0 +1,5 @@ +contract test { + function f() public returns (bool r) { return 1 >= 2; } +} +// ---- +// Warning: (20-75): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/007_type_checking_return_wrong_number.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/007_type_checking_return_wrong_number.sol new file mode 100644 index 00000000..13c70ad9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/007_type_checking_return_wrong_number.sol @@ -0,0 +1,5 @@ +contract test { + function f() public returns (bool r1, bool r2) { return 1 >= 2; } +} +// ---- +// TypeError: (69-82): Different number of arguments in return statement than in returns declaration. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/008_type_checking_return_wrong_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/008_type_checking_return_wrong_type.sol new file mode 100644 index 00000000..a7459ae8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/008_type_checking_return_wrong_type.sol @@ -0,0 +1,5 @@ +contract test { + function f() public returns (uint256 r) { return 1 >= 2; } +} +// ---- +// TypeError: (69-75): Return argument type bool is not implicitly convertible to expected type (type of first return variable) uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol new file mode 100644 index 00000000..abe2beac --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol @@ -0,0 +1,6 @@ +contract test { + function f() public returns (bool) { return g(12, true) == 3; } + function g(uint256, bool) public returns (uint256) { } +} +// ---- +// Warning: (88-142): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/010_type_conversion_for_comparison.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/010_type_conversion_for_comparison.sol new file mode 100644 index 00000000..c0cd87d4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/010_type_conversion_for_comparison.sol @@ -0,0 +1,6 @@ +contract test { + function f() public { uint32(2) == int64(2); } +} +// ---- +// Warning: (42-63): Statement has no effect. +// Warning: (20-66): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol new file mode 100644 index 00000000..9cbce0d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol @@ -0,0 +1,5 @@ +contract test { + function f() public { int32(2) == uint64(2); } +} +// ---- +// TypeError: (42-63): Operator == not compatible with types int32 and uint64 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol new file mode 100644 index 00000000..7f858a4d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol @@ -0,0 +1,6 @@ +contract test { + function f() public { string memory x = "123456789012345678901234567890123"; } +} +// ---- +// Warning: (42-57): Unused local variable. +// Warning: (20-98): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/014_balance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/014_balance.sol new file mode 100644 index 00000000..e2c9a8bf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/014_balance.sol @@ -0,0 +1,8 @@ +contract test { + function fun() public { + uint256 x = address(0).balance; + } +} +// ---- +// Warning: (52-61): Unused local variable. +// Warning: (20-89): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/015_balance_invalid.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/015_balance_invalid.sol new file mode 100644 index 00000000..18658fbe --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/015_balance_invalid.sol @@ -0,0 +1,7 @@ +contract test { + function fun() public { + address(0).balance = 7; + } +} +// ---- +// TypeError: (52-70): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol new file mode 100644 index 00000000..8bf45c3f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol @@ -0,0 +1,12 @@ +contract test { + struct str { + mapping(uint=>uint) map; + } + str data; + function fun() public { + mapping(uint=>uint) a = data.map; + data.map = a; + } +} +// ---- +// TypeError: (164-176): Mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol new file mode 100644 index 00000000..6fbd09ae --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol @@ -0,0 +1,11 @@ +contract test { + struct str { + mapping(uint=>uint) map; + } + str data; + function fun() public { + str storage a = data; + data = a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/018_forward_function_reference.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/018_forward_function_reference.sol new file mode 100644 index 00000000..fd9ab7ed --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/018_forward_function_reference.sol @@ -0,0 +1,10 @@ +contract First { + function fun() public returns (bool) { + return Second(1).fun(1, true, 3) > 0; + } +} +contract Second { + function fun(uint, bool, uint) public returns (uint) { + if (First(2).fun() == true) return 1; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/019_comparison_bitop_precedence.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/019_comparison_bitop_precedence.sol new file mode 100644 index 00000000..eab272df --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/019_comparison_bitop_precedence.sol @@ -0,0 +1,7 @@ +contract First { + function fun() public returns (bool ret) { + return 1 & 2 == 8 & 9 && 1 ^ 2 < 4 | 6; + } +} +// ---- +// Warning: (21-117): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/020_comparison_of_function_types_lt_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/020_comparison_of_function_types_lt_1.sol new file mode 100644 index 00000000..1f288ff7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/020_comparison_of_function_types_lt_1.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (bool ret) { + return this.f < this.f; + } +} +// ---- +// TypeError: (73-88): Operator < not compatible with types function () external returns (bool) and function () external returns (bool) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/021_comparison_of_function_types_lt_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/021_comparison_of_function_types_lt_2.sol new file mode 100644 index 00000000..a6422d38 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/021_comparison_of_function_types_lt_2.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (bool ret) { + return f < f; + } +} +// ---- +// TypeError: (73-78): Operator < not compatible with types function () returns (bool) and function () returns (bool) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/022_comparison_of_function_types_gt_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/022_comparison_of_function_types_gt_1.sol new file mode 100644 index 00000000..ee865912 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/022_comparison_of_function_types_gt_1.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (bool ret) { + return this.f > this.f; + } +} +// ---- +// TypeError: (73-88): Operator > not compatible with types function () external returns (bool) and function () external returns (bool) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/023_comparison_of_function_types_gt_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/023_comparison_of_function_types_gt_2.sol new file mode 100644 index 00000000..590cc98b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/023_comparison_of_function_types_gt_2.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (bool ret) { + return f > f; + } +} +// ---- +// TypeError: (73-78): Operator > not compatible with types function () returns (bool) and function () returns (bool) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/024_comparison_of_function_types_eq.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/024_comparison_of_function_types_eq.sol new file mode 100644 index 00000000..71dbec6b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/024_comparison_of_function_types_eq.sol @@ -0,0 +1,11 @@ +contract C { + function f() public returns (bool ret) { + return f == f; + } + function g() public returns (bool ret) { + return f != f; + } +} +// ---- +// Warning: (17-86): Function state mutability can be restricted to pure +// Warning: (91-160): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol new file mode 100644 index 00000000..27651d63 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol @@ -0,0 +1,9 @@ +contract C { + mapping(uint => uint) x; + function f() public returns (bool ret) { + mapping(uint => uint) y = x; + return x == y; + } +} +// ---- +// TypeError: (139-145): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/029_create_abstract_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/029_create_abstract_contract.sol new file mode 100644 index 00000000..455f4189 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/029_create_abstract_contract.sol @@ -0,0 +1,7 @@ +contract base { function foo() public; } +contract derived { + base b; + function foo() public { b = new base(); } +} +// ---- +// TypeError: (104-112): Trying to create an instance of an abstract contract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/030_redeclare_implemented_abstract_function_as_abstract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/030_redeclare_implemented_abstract_function_as_abstract.sol new file mode 100644 index 00000000..55bdea89 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/030_redeclare_implemented_abstract_function_as_abstract.sol @@ -0,0 +1,5 @@ +contract base { function foo() public; } +contract derived is base { function foo() public {} } +contract wrong is derived { function foo() public; } +// ---- +// TypeError: (123-145): Redeclaring an already implemented function as abstract diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/039_functions_with_identical_structs_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/039_functions_with_identical_structs_in_interface.sol new file mode 100644 index 00000000..851ccf89 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/039_functions_with_identical_structs_in_interface.sol @@ -0,0 +1,11 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S1 { int i; } + struct S2 { int i; } + function f(S1) public pure {} + function f(S2) public pure {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (136-165): Function overload clash during conversion to external types for arguments. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol new file mode 100644 index 00000000..1689e6f5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol @@ -0,0 +1,10 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S1 { function() external a; } + struct S2 { bytes24 a; } + function f(S1) public pure {} + function f(S2) public pure {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol new file mode 100644 index 00000000..775258c2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol @@ -0,0 +1,9 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S { function() internal a; } + function f(S) public {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (103-104): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol new file mode 100644 index 00000000..4a95430f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol @@ -0,0 +1,9 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S { mapping(uint => uint) a; } + function f(S) public {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (105-106): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol new file mode 100644 index 00000000..09cd38b5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol @@ -0,0 +1,10 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct T { mapping(uint => uint) a; } + struct S { T[][2] b; } + function f(S) public {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (132-133): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/044_returning_multi_dimensional_arrays_new_abi.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/044_returning_multi_dimensional_arrays_new_abi.sol new file mode 100644 index 00000000..e54e27e9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/044_returning_multi_dimensional_arrays_new_abi.sol @@ -0,0 +1,7 @@ +pragma experimental ABIEncoderV2; + +contract C { + function f() public pure returns (string[][]) {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol new file mode 100644 index 00000000..daa67836 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure returns (string[][]) {} +} +// ---- +// TypeError: (51-61): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol new file mode 100644 index 00000000..26af7436 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure returns (uint[][2]) {} +} +// ---- +// TypeError: (51-60): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/047_returning_arrays_in_structs_new_abi.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/047_returning_arrays_in_structs_new_abi.sol new file mode 100644 index 00000000..81628a12 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/047_returning_arrays_in_structs_new_abi.sol @@ -0,0 +1,8 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S { string[] s; } + function f() public pure returns (S) {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol new file mode 100644 index 00000000..2f1e5a15 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol @@ -0,0 +1,6 @@ +contract C { + struct S { string[] s; } + function f() public pure returns (S x) {} +} +// ---- +// TypeError: (80-83): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol new file mode 100644 index 00000000..ec72adeb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol @@ -0,0 +1,11 @@ +contract C {} +contract Test { + function externalCall() public { + C arg; + this.g(arg); + } + function g (C c) external {} +} +// ---- +// Warning: (125-128): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (113-141): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/050_function_external_call_not_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/050_function_external_call_not_allowed_conversion.sol new file mode 100644 index 00000000..18d75948 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/050_function_external_call_not_allowed_conversion.sol @@ -0,0 +1,10 @@ +contract C {} +contract Test { + function externalCall() public { + address arg; + this.g(arg); + } + function g (C c) external {} +} +// ---- +// TypeError: (103-106): Invalid type for argument in function call. Invalid implicit conversion from address to contract C requested. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol new file mode 100644 index 00000000..aedc7b0b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol @@ -0,0 +1,13 @@ +contract C { + uint a; +} +contract Test { + C a; + function g (C c) public {} + function internalCall() public { + g(a); + } +} +// ---- +// Warning: (68-71): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (56-82): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/052_function_internal_not_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/052_function_internal_not_allowed_conversion.sol new file mode 100644 index 00000000..c16d35eb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/052_function_internal_not_allowed_conversion.sol @@ -0,0 +1,12 @@ +contract C { + uint a; +} +contract Test { + address a; + function g (C c) public {} + function internalCall() public { + g(a); + } +} +// ---- +// TypeError: (136-137): Invalid type for argument in function call. Invalid implicit conversion from address to contract C requested. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/053_hash_collision_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/053_hash_collision_in_interface.sol new file mode 100644 index 00000000..fe690e16 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/053_hash_collision_in_interface.sol @@ -0,0 +1,6 @@ +contract test { + function gsf() public { } + function tgeo() public { } +} +// ---- +// TypeError: (0-78): Function signature hash collision for tgeo() diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/054_inheritance_basic.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/054_inheritance_basic.sol new file mode 100644 index 00000000..6229a1dc --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/054_inheritance_basic.sol @@ -0,0 +1,5 @@ +contract base { uint baseMember; struct BaseType { uint element; } } +contract derived is base { + BaseType data; + function f() public { baseMember = 7; } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol new file mode 100644 index 00000000..c07e59e2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol @@ -0,0 +1,9 @@ +contract root { function rootFunction() public {} } +contract inter1 is root { function f() public {} } +contract inter2 is root { function f() public {} } +contract derived is root, inter2, inter1 { + function g() public { f(); rootFunction(); } +} +// ---- +// Warning: (16-49): Function state mutability can be restricted to pure +// Warning: (129-151): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/056_cyclic_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/056_cyclic_inheritance.sol new file mode 100644 index 00000000..0e1ec4cb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/056_cyclic_inheritance.sol @@ -0,0 +1,4 @@ +contract A is B { } +contract B is A { } +// ---- +// TypeError: (14-15): Definition of base has to precede definition of derived contract diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol new file mode 100644 index 00000000..062507ee --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol @@ -0,0 +1,6 @@ +contract B { function f() public {} } +contract C is B { function f(uint i) public {} } +// ---- +// Warning: (67-73): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (13-35): Function state mutability can be restricted to pure +// Warning: (56-84): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol new file mode 100644 index 00000000..f59da472 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol @@ -0,0 +1,7 @@ +contract A { function f(uint a) public {} } +contract B { function f() public {} } +contract C is A, B { } +// ---- +// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (13-41): Function state mutability can be restricted to pure +// Warning: (57-79): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/059_illegal_override_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/059_illegal_override_visibility.sol new file mode 100644 index 00000000..8c13a478 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/059_illegal_override_visibility.sol @@ -0,0 +1,4 @@ +contract B { function f() internal {} } +contract C is B { function f() public {} } +// ---- +// TypeError: (58-80): Overriding function visibility differs. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol new file mode 100644 index 00000000..c7e42238 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol @@ -0,0 +1,6 @@ +contract A { function f() public { uint8 x = C(0).g(); } } +contract B { function f() public {} function g() public returns (uint8) {} } +contract C is A, B { } +// ---- +// Warning: (35-42): Unused local variable. +// Warning: (95-133): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol new file mode 100644 index 00000000..8ebb46aa --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol @@ -0,0 +1,4 @@ +contract A { constructor(uint a) public { } } +contract B is A { } +// ---- +// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol new file mode 100644 index 00000000..8ebb46aa --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol @@ -0,0 +1,4 @@ +contract A { constructor(uint a) public { } } +contract B is A { } +// ---- +// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/063_implicit_derived_to_base_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/063_implicit_derived_to_base_conversion.sol new file mode 100644 index 00000000..f4667996 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/063_implicit_derived_to_base_conversion.sol @@ -0,0 +1,7 @@ +contract A { } +contract B is A { + function f() public { A a = B(1); } +} +// ---- +// Warning: (59-62): Unused local variable. +// Warning: (37-72): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/064_implicit_base_to_derived_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/064_implicit_base_to_derived_conversion.sol new file mode 100644 index 00000000..0d23ea87 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/064_implicit_base_to_derived_conversion.sol @@ -0,0 +1,6 @@ +contract A { } +contract B is A { + function f() public { B b = A(1); } +} +// ---- +// TypeError: (59-69): Type contract A is not implicitly convertible to expected type contract B. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol new file mode 100644 index 00000000..6fa92a6a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol @@ -0,0 +1,11 @@ +contract A { + function b() public {} +} + +contract B is A { + function f() public { + super.f(); + } +} +// ---- +// TypeError: (95-102): Member "f" not found or not visible after argument-dependent lookup in contract super B diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/067_function_clash_with_state_variable_accessor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/067_function_clash_with_state_variable_accessor.sol new file mode 100644 index 00000000..a99682c0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/067_function_clash_with_state_variable_accessor.sol @@ -0,0 +1,9 @@ +contract test { + function fun() public { + uint64(2); + } + uint256 foo; + function foo() public {} +} +// ---- +// DeclarationError: (90-114): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/069_base_class_state_variable_accessor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/069_base_class_state_variable_accessor.sol new file mode 100644 index 00000000..8f2c6438 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/069_base_class_state_variable_accessor.sol @@ -0,0 +1,9 @@ +// test for issue #1126 https://github.com/ethereum/cpp-ethereum/issues/1126 +contract Parent { + uint256 public m_aMember; +} +contract Child is Parent { + function foo() public returns (uint256) { return Parent.m_aMember; } +} +// ---- +// Warning: (158-226): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/070_struct_accessor_one_array_only.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/070_struct_accessor_one_array_only.sol new file mode 100644 index 00000000..6741a7fa --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/070_struct_accessor_one_array_only.sol @@ -0,0 +1,6 @@ +contract test { + struct Data { uint[15] m_array; } + Data public data; +} +// ---- +// TypeError: (58-74): Internal or recursive type is not allowed for public state variables. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/071_base_class_state_variable_internal_member.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/071_base_class_state_variable_internal_member.sol new file mode 100644 index 00000000..774ea38e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/071_base_class_state_variable_internal_member.sol @@ -0,0 +1,8 @@ +contract Parent { + uint256 internal m_aMember; +} +contract Child is Parent { + function foo() public returns (uint256) { return Parent.m_aMember; } +} +// ---- +// Warning: (83-151): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol new file mode 100644 index 00000000..949761b6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol @@ -0,0 +1,11 @@ +contract Parent1 { + uint256 internal m_aMember1; +} +contract Parent2 is Parent1 { + uint256 internal m_aMember2; +} +contract Child is Parent2 { + function foo() public returns (uint256) { return Parent2.m_aMember1; } +} +// ---- +// TypeError: (200-218): Member "m_aMember1" not found or not visible after argument-dependent lookup in type(contract Parent2) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol new file mode 100644 index 00000000..9a0ee8a3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol @@ -0,0 +1,12 @@ +contract Parent1 { + uint256 internal m_aMember1; +} +contract Parent2 is Parent1 { + uint256 internal m_aMember2; +} +contract Child is Parent2 { + function foo() public returns (uint256) { return Child.m_aMember2; } + uint256 public m_aMember3; +} +// ---- +// TypeError: (200-216): Member "m_aMember2" not found or not visible after argument-dependent lookup in type(contract Child) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol new file mode 100644 index 00000000..466e80cb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol @@ -0,0 +1,4 @@ +contract C { + uint x; + function() external { x = 2; } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol new file mode 100644 index 00000000..68d40952 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol @@ -0,0 +1,6 @@ +contract C { + uint x; + function(uint a) external { x = 2; } +} +// ---- +// TypeError: (37-45): Fallback function cannot take parameters. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol new file mode 100644 index 00000000..25878a61 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol @@ -0,0 +1,5 @@ +library C { + function() external {} +} +// ---- +// TypeError: (16-38): Libraries cannot have fallback functions. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol new file mode 100644 index 00000000..3ff7a1c4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol @@ -0,0 +1,5 @@ +contract C { + function() external returns (uint) { } +} +// ---- +// TypeError: (45-51): Fallback function cannot return values. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol new file mode 100644 index 00000000..e5746c63 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol @@ -0,0 +1,7 @@ +contract C { + uint x; + function() external { x = 2; } + function() external { x = 3; } +} +// ---- +// DeclarationError: (64-94): Only one fallback function is allowed. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol new file mode 100644 index 00000000..c8c06c6e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol @@ -0,0 +1,7 @@ +contract A { + uint x; + function() external { x = 1; } +} +contract C is A { + function() external { x = 2; } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol new file mode 100644 index 00000000..c5f9e4d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol @@ -0,0 +1,5 @@ +contract c { + event e(uint indexed a, bytes3 indexed s, bool indexed b); + function f() public { emit e(2, "abc", true); } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/081_event_too_many_indexed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/081_event_too_many_indexed.sol new file mode 100644 index 00000000..ee0af605 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/081_event_too_many_indexed.sol @@ -0,0 +1,5 @@ +contract c { + event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d); +} +// ---- +// TypeError: (17-91): More than 3 indexed arguments for event. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/082_anonymous_event_four_indexed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/082_anonymous_event_four_indexed.sol new file mode 100644 index 00000000..e8b36906 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/082_anonymous_event_four_indexed.sol @@ -0,0 +1,3 @@ +contract c { + event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d) anonymous; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/083_anonymous_event_too_many_indexed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/083_anonymous_event_too_many_indexed.sol new file mode 100644 index 00000000..d439c5b9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/083_anonymous_event_too_many_indexed.sol @@ -0,0 +1,5 @@ +contract c { + event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous; +} +// ---- +// TypeError: (17-117): More than 4 indexed arguments for anonymous event. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/084_events_with_same_name.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/084_events_with_same_name.sol new file mode 100644 index 00000000..24f633b3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/084_events_with_same_name.sol @@ -0,0 +1,4 @@ +contract TestIt { + event A(); + event A(uint i); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/085_events_with_same_name_unnamed_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/085_events_with_same_name_unnamed_arguments.sol new file mode 100644 index 00000000..cccd9d57 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/085_events_with_same_name_unnamed_arguments.sol @@ -0,0 +1,4 @@ +contract test { + event A(uint); + event A(uint, uint); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/086_events_with_same_name_different_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/086_events_with_same_name_different_types.sol new file mode 100644 index 00000000..fbeab711 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/086_events_with_same_name_different_types.sol @@ -0,0 +1,4 @@ +contract test { + event A(uint); + event A(bytes); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/087_double_event_declaration.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/087_double_event_declaration.sol new file mode 100644 index 00000000..af0280c5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/087_double_event_declaration.sol @@ -0,0 +1,6 @@ +contract test { + event A(uint i); + event A(uint i); +} +// ---- +// DeclarationError: (20-36): Event with same name and arguments defined twice. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/088_double_event_declaration_ignores_anonymous.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/088_double_event_declaration_ignores_anonymous.sol new file mode 100644 index 00000000..7d4b0ac9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/088_double_event_declaration_ignores_anonymous.sol @@ -0,0 +1,6 @@ +contract test { + event A(uint i); + event A(uint i) anonymous; +} +// ---- +// DeclarationError: (20-36): Event with same name and arguments defined twice. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/089_double_event_declaration_ignores_indexed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/089_double_event_declaration_ignores_indexed.sol new file mode 100644 index 00000000..e6aa3e5f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/089_double_event_declaration_ignores_indexed.sol @@ -0,0 +1,6 @@ +contract test { + event A(uint i); + event A(uint indexed i); +} +// ---- +// DeclarationError: (20-36): Event with same name and arguments defined twice. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol new file mode 100644 index 00000000..8cf50597 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol @@ -0,0 +1,5 @@ +contract c { + event e(uint a, bytes3 indexed s, bool indexed b); + function f() public { emit e(2, "abc", true); } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/091_event_function_inheritance_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/091_event_function_inheritance_clash.sol new file mode 100644 index 00000000..5e0f58ea --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/091_event_function_inheritance_clash.sol @@ -0,0 +1,12 @@ +contract A { + function dup() public returns (uint) { + return 1; + } +} +contract B { + event dup(); +} +contract C is A, B { +} +// ---- +// DeclarationError: (99-111): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/092_function_event_inheritance_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/092_function_event_inheritance_clash.sol new file mode 100644 index 00000000..c567f992 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/092_function_event_inheritance_clash.sol @@ -0,0 +1,12 @@ +contract B { + event dup(); +} +contract A { + function dup() public returns (uint) { + return 1; + } +} +contract C is B, A { +} +// ---- +// DeclarationError: (49-111): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/093_function_event_in_contract_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/093_function_event_in_contract_clash.sol new file mode 100644 index 00000000..7b4fcde9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/093_function_event_in_contract_clash.sol @@ -0,0 +1,8 @@ +contract A { + event dup(); + function dup() public returns (uint) { + return 1; + } +} +// ---- +// DeclarationError: (34-96): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol new file mode 100644 index 00000000..b13d5755 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol @@ -0,0 +1,7 @@ +contract base { + event e(uint a, bytes3 indexed s, bool indexed b); +} +contract c is base { + function f() public { emit e(2, "abc", true); } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/095_multiple_events_argument_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/095_multiple_events_argument_clash.sol new file mode 100644 index 00000000..79127119 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/095_multiple_events_argument_clash.sol @@ -0,0 +1,4 @@ +contract c { + event e1(uint a, uint e1, uint e2); + event e2(uint a, uint e1, uint e2); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol new file mode 100644 index 00000000..9251df73 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol @@ -0,0 +1,8 @@ +contract c { + function f() public {} +} +contract d { + function g() public { c(0).f(); } +} +// ---- +// Warning: (17-39): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol new file mode 100644 index 00000000..e13e1531 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol @@ -0,0 +1,8 @@ +contract c { + function f() internal {} +} +contract d { + function g() public { c(0).f(); } +} +// ---- +// TypeError: (83-89): Member "f" not found or not visible after argument-dependent lookup in contract c diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol new file mode 100644 index 00000000..ab7546c6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol @@ -0,0 +1,8 @@ +contract c { + uint a; +} +contract d { + function g() public { c(0).a(); } +} +// ---- +// TypeError: (66-72): Member "a" not found or not visible after argument-dependent lookup in contract c diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/099_access_to_internal_state_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/099_access_to_internal_state_variable.sol new file mode 100644 index 00000000..60aba574 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/099_access_to_internal_state_variable.sol @@ -0,0 +1,8 @@ +contract c { + uint public a; +} +contract d { + function g() public { c(0).a(); } +} +// ---- +// Warning: (51-84): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/100_error_count_in_named_args.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/100_error_count_in_named_args.sol new file mode 100644 index 00000000..a679c25a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/100_error_count_in_named_args.sol @@ -0,0 +1,11 @@ +contract test { + function a(uint a, uint b) public returns (uint r) { + r = a + b; + } + function b() public returns (uint r) { + r = a({a: 1}); + } +} +// ---- +// Warning: (31-37): This declaration shadows an existing declaration. +// TypeError: (153-162): Wrong argument count for function call: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/101_empty_in_named_args.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/101_empty_in_named_args.sol new file mode 100644 index 00000000..9da11d6f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/101_empty_in_named_args.sol @@ -0,0 +1,11 @@ +contract test { + function a(uint a, uint b) public returns (uint r) { + r = a + b; + } + function b() public returns (uint r) { + r = a({}); + } +} +// ---- +// Warning: (31-37): This declaration shadows an existing declaration. +// TypeError: (153-158): Wrong argument count for function call: 0 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/102_duplicate_parameter_names_in_named_args.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/102_duplicate_parameter_names_in_named_args.sol new file mode 100644 index 00000000..fab4beff --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/102_duplicate_parameter_names_in_named_args.sol @@ -0,0 +1,11 @@ +contract test { + function a(uint a, uint b) public returns (uint r) { + r = a + b; + } + function b() public returns (uint r) { + r = a({a: 1, a: 2}); + } +} +// ---- +// Warning: (31-37): This declaration shadows an existing declaration. +// TypeError: (159-160): Duplicate named argument. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/103_invalid_parameter_names_in_named_args.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/103_invalid_parameter_names_in_named_args.sol new file mode 100644 index 00000000..bed15186 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/103_invalid_parameter_names_in_named_args.sol @@ -0,0 +1,11 @@ +contract test { + function a(uint a, uint b) public returns (uint r) { + r = a + b; + } + function b() public returns (uint r) { + r = a({a: 1, c: 2}); + } +} +// ---- +// Warning: (31-37): This declaration shadows an existing declaration. +// TypeError: (153-168): Named argument "c" does not match function declaration. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol new file mode 100644 index 00000000..824543ef --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol @@ -0,0 +1,5 @@ +contract test { + function f(uint) public { } +} +// ---- +// Warning: (20-47): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol new file mode 100644 index 00000000..636d325f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol @@ -0,0 +1,7 @@ +contract test { + function f(uint[] constant a) public { } +} +// ---- +// TypeError: (31-48): Illegal use of "constant" specifier. +// TypeError: (31-48): Constants of non-value type not yet implemented. +// TypeError: (31-48): Uninitialized "constant" variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol new file mode 100644 index 00000000..a2ffc6e1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol @@ -0,0 +1,5 @@ +contract test { + function f() public returns (bool) { } +} +// ---- +// Warning: (20-58): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/107_empty_name_input_parameter_with_named_one.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/107_empty_name_input_parameter_with_named_one.sol new file mode 100644 index 00000000..e0efa0a0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/107_empty_name_input_parameter_with_named_one.sol @@ -0,0 +1,7 @@ +contract test { + function f(uint, uint k) public returns (uint ret_k) { + return k; + } +} +// ---- +// Warning: (20-98): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/108_empty_name_return_parameter_with_named_one.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/108_empty_name_return_parameter_with_named_one.sol new file mode 100644 index 00000000..39ae7877 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/108_empty_name_return_parameter_with_named_one.sol @@ -0,0 +1,7 @@ +contract test { + function f() public returns (uint ret_k, uint) { + return 5; + } +} +// ---- +// TypeError: (77-85): Different number of arguments in return statement than in returns declaration. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol new file mode 100644 index 00000000..9b36fa70 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol @@ -0,0 +1,7 @@ +contract c { + constructor() public { + a = 115792089237316195423570985008687907853269984665640564039458; + } + uint256 a; +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol new file mode 100644 index 00000000..dc4cab8a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol @@ -0,0 +1,8 @@ +contract c { + constructor() public { + a = 115792089237316195423570985008687907853269984665640564039458 ether; + } + uint256 a; +} +// ---- +// TypeError: (52-118): Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol new file mode 100644 index 00000000..2a9e6204 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol @@ -0,0 +1,5 @@ +contract test { + function f() public returns (uint d) { return 2 ** 10000000000; } +} +// ---- +// TypeError: (66-82): Operator ** not compatible with types int_const 2 and int_const 10000000000 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol new file mode 100644 index 00000000..0d91fcab --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol @@ -0,0 +1,8 @@ +contract test { + function f() pure public returns(uint) { + uint8 x = 100; + return 10**x; + } +} +// ---- +// Warning: (99-104): Result of exponentiation has type uint8 and thus might overflow. Silence this warning by converting the literal to the expected type. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/114_exp_warn_literal_base_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/114_exp_warn_literal_base_2.sol new file mode 100644 index 00000000..eb430b9a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/114_exp_warn_literal_base_2.sol @@ -0,0 +1,6 @@ +contract test { + function f() pure public returns(uint) { + uint8 x = 100; + return uint8(10)**x; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/115_exp_warn_literal_base_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/115_exp_warn_literal_base_3.sol new file mode 100644 index 00000000..01c0fc06 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/115_exp_warn_literal_base_3.sol @@ -0,0 +1,5 @@ +contract test { + function f() pure public returns(uint) { + return 2**80; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol new file mode 100644 index 00000000..c6a4052e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol @@ -0,0 +1,8 @@ +contract test { + function f() pure public returns(uint) { + uint8 x = 100; + return 10 << x; + } +} +// ---- +// Warning: (99-106): Result of shift has type uint8 and thus might overflow. Silence this warning by converting the literal to the expected type. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/117_shift_warn_literal_base_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/117_shift_warn_literal_base_2.sol new file mode 100644 index 00000000..954d1943 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/117_shift_warn_literal_base_2.sol @@ -0,0 +1,6 @@ +contract test { + function f() pure public returns(uint) { + uint8 x = 100; + return uint8(10) << x; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/118_shift_warn_literal_base_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/118_shift_warn_literal_base_3.sol new file mode 100644 index 00000000..5fbaa806 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/118_shift_warn_literal_base_3.sol @@ -0,0 +1,5 @@ +contract test { + function f() pure public returns(uint) { + return 2 << 80; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/119_shift_warn_literal_base_4.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/119_shift_warn_literal_base_4.sol new file mode 100644 index 00000000..19869157 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/119_shift_warn_literal_base_4.sol @@ -0,0 +1,6 @@ +contract test { + function f() pure public returns(uint) { + uint8 x = 100; + return 10 >> x; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol new file mode 100644 index 00000000..98bc8e66 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol @@ -0,0 +1,8 @@ +contract test { + enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } + constructor() public + { + choices = ActionChoices.GoStraight; + } + ActionChoices choices; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/125_enum_member_access_accross_contracts.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/125_enum_member_access_accross_contracts.sol new file mode 100644 index 00000000..3bed62d6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/125_enum_member_access_accross_contracts.sol @@ -0,0 +1,10 @@ +contract Interface { + enum MyEnum { One, Two } +} +contract Impl { + function test() public returns (Interface.MyEnum) { + return Interface.MyEnum.One; + } +} +// ---- +// Warning: (72-166): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol new file mode 100644 index 00000000..079bf0c8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol @@ -0,0 +1,9 @@ +contract test { + enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } + constructor() public { + choices = ActionChoices.RunAroundWavingYourHands; + } + ActionChoices choices; +} +// ---- +// TypeError: (121-159): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol new file mode 100644 index 00000000..68510a0a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol @@ -0,0 +1,9 @@ +contract test { + enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } + constructor() public { + choices = Sit; + } + ActionChoices choices; +} +// ---- +// DeclarationError: (121-124): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol new file mode 100644 index 00000000..0948d550 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol @@ -0,0 +1,10 @@ +contract test { + enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } + constructor() public { + a = uint256(ActionChoices.GoStraight); + b = uint64(ActionChoices.Sit); + } + uint256 a; + uint64 b; +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol new file mode 100644 index 00000000..2639decf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol @@ -0,0 +1,10 @@ +contract test { + enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } + constructor() public { + a = 2; + b = ActionChoices(a); + } + uint256 a; + ActionChoices b; +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol new file mode 100644 index 00000000..01c5e93f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol @@ -0,0 +1,9 @@ +contract test { + enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } + constructor() public { + a = ActionChoices.GoStraight; + } + uint256 a; +} +// ---- +// TypeError: (115-139): Type enum test.ActionChoices is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol new file mode 100644 index 00000000..4e21b9aa --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol @@ -0,0 +1,9 @@ +contract test { + enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } + constructor() public { + b = ActionChoices.Sit; + } + uint64 b; +} +// ---- +// TypeError: (115-132): Type enum test.ActionChoices is not implicitly convertible to expected type uint64. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol new file mode 100644 index 00000000..5b9ba813 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol @@ -0,0 +1,9 @@ +contract test { + enum Paper { Up, Down, Left, Right } + enum Ground { North, South, West, East } + constructor() public { + Ground(Paper.Up); + } +} +// ---- +// TypeError: (137-153): Explicit type conversion not allowed from "enum test.Paper" to "enum test.Ground". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/133_enum_duplicate_values.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/133_enum_duplicate_values.sol new file mode 100644 index 00000000..996a9b78 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/133_enum_duplicate_values.sol @@ -0,0 +1,5 @@ + contract test { + enum ActionChoices { GoLeft, GoRight, GoLeft, Sit } + } +// ---- +// DeclarationError: (66-72): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/134_enum_name_resolution_under_current_contract_name.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/134_enum_name_resolution_under_current_contract_name.sol new file mode 100644 index 00000000..4a16eee1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/134_enum_name_resolution_under_current_contract_name.sol @@ -0,0 +1,12 @@ +contract A { + enum Foo { + First, + Second + } + + function a() public { + A.Foo; + } +} +// ---- +// Warning: (69-111): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/135_private_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/135_private_visibility.sol new file mode 100644 index 00000000..faafc631 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/135_private_visibility.sol @@ -0,0 +1,8 @@ +contract base { + function f() private {} +} +contract derived is base { + function g() public { f(); } +} +// ---- +// DeclarationError: (99-100): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol new file mode 100644 index 00000000..fc89c033 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol @@ -0,0 +1,8 @@ +contract base { + function f() private {} +} +contract derived is base { + function g() public { base.f(); } +} +// ---- +// TypeError: (99-105): Member "f" not found or not visible after argument-dependent lookup in type(contract base) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/137_external_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/137_external_visibility.sol new file mode 100644 index 00000000..214ad60a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/137_external_visibility.sol @@ -0,0 +1,6 @@ +contract c { + function f() external {} + function g() public { f(); } +} +// ---- +// DeclarationError: (68-69): Undeclared identifier. "f" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/138_similar_name_suggestions_expected.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/138_similar_name_suggestions_expected.sol new file mode 100644 index 00000000..ef6e933a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/138_similar_name_suggestions_expected.sol @@ -0,0 +1,6 @@ +contract c { + function func() public {} + function g() public { fun(); } +} +// ---- +// DeclarationError: (69-72): Undeclared identifier. Did you mean "func"? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/139_no_name_suggestion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/139_no_name_suggestion.sol new file mode 100644 index 00000000..40827dca --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/139_no_name_suggestion.sol @@ -0,0 +1,5 @@ +contract c { + function g() public { fun(); } +} +// ---- +// DeclarationError: (39-42): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/140_multiple_similar_suggestions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/140_multiple_similar_suggestions.sol new file mode 100644 index 00000000..34b4604d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/140_multiple_similar_suggestions.sol @@ -0,0 +1,11 @@ +contract c { + function g() public { + uint var1 = 1; + uint var2 = 1; + uint var3 = 1; + uint var4 = 1; + uint var5 = varx; + } +} +// ---- +// DeclarationError: (151-155): Undeclared identifier. Did you mean "var1", "var2", "var3", "var4" or "var5"? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/141_multiple_scopes_suggestions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/141_multiple_scopes_suggestions.sol new file mode 100644 index 00000000..f9471146 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/141_multiple_scopes_suggestions.sol @@ -0,0 +1,9 @@ +contract c { + uint log9 = 2; + function g() public { + uint log8 = 3; + uint var1 = lgox; + } +} +// ---- +// DeclarationError: (101-105): Undeclared identifier. Did you mean "log8", "log9", "log0", "log1", "log2", "log3" or "log4"? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/142_inheritence_suggestions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/142_inheritence_suggestions.sol new file mode 100644 index 00000000..4231e1bd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/142_inheritence_suggestions.sol @@ -0,0 +1,8 @@ +contract a { function func() public {} } +contract c is a { + function g() public { + uint var1 = fun(); + } +} +// ---- +// DeclarationError: (105-108): Undeclared identifier. Did you mean "func"? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/143_no_spurious_identifier_suggestions_with_submatch.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/143_no_spurious_identifier_suggestions_with_submatch.sol new file mode 100644 index 00000000..db9f07c6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/143_no_spurious_identifier_suggestions_with_submatch.sol @@ -0,0 +1,8 @@ +contract c { + function g() public { + uint va = 1; + uint vb = vaxyz; + } +} +// ---- +// DeclarationError: (78-83): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/144_no_spurious_identifier_suggestions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/144_no_spurious_identifier_suggestions.sol new file mode 100644 index 00000000..2316cb3d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/144_no_spurious_identifier_suggestions.sol @@ -0,0 +1,8 @@ +contract c { + function g() public { + uint va = 1; + uint vb = x; + } +} +// ---- +// DeclarationError: (78-79): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol new file mode 100644 index 00000000..2d1baa20 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol @@ -0,0 +1,8 @@ +contract base { + function f() external {} +} +contract derived is base { + function g() public { base.f(); } +} +// ---- +// TypeError: (100-106): Member "f" not found or not visible after argument-dependent lookup in type(contract base) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/146_external_argument_assign.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/146_external_argument_assign.sol new file mode 100644 index 00000000..d2c0245c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/146_external_argument_assign.sol @@ -0,0 +1,5 @@ +contract c { + function f(uint a) external { a = 1; } +} +// ---- +// TypeError: (47-48): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/147_external_argument_increment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/147_external_argument_increment.sol new file mode 100644 index 00000000..2bfba42b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/147_external_argument_increment.sol @@ -0,0 +1,5 @@ +contract c { + function f(uint a) external { a++; } +} +// ---- +// TypeError: (47-48): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/148_external_argument_delete.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/148_external_argument_delete.sol new file mode 100644 index 00000000..30eb204e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/148_external_argument_delete.sol @@ -0,0 +1,5 @@ +contract c { + function f(uint a) external { delete a; } +} +// ---- +// TypeError: (54-55): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol new file mode 100644 index 00000000..871af310 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol @@ -0,0 +1,8 @@ +contract Vehicle { + function f(bytes) external returns (uint256 r) {r = 1;} +} +contract Bike is Vehicle { + function f(bytes) external returns (uint256 r) {r = 42;} +} +// ---- +// Warning: (23-78): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/150_array_with_nonconstant_length.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/150_array_with_nonconstant_length.sol new file mode 100644 index 00000000..49a1851c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/150_array_with_nonconstant_length.sol @@ -0,0 +1,5 @@ +contract c { + function f(uint a) public { uint8[a] x; } +} +// ---- +// TypeError: (51-52): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/151_array_with_negative_length.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/151_array_with_negative_length.sol new file mode 100644 index 00000000..b87160b0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/151_array_with_negative_length.sol @@ -0,0 +1,5 @@ +contract c { + function f(uint a) public { uint8[-1] x; } +} +// ---- +// TypeError: (51-53): Array with negative length specified. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/152_array_copy_with_different_types1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/152_array_copy_with_different_types1.sol new file mode 100644 index 00000000..a0e71847 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/152_array_copy_with_different_types1.sol @@ -0,0 +1,7 @@ +contract c { + bytes a; + uint[] b; + function f() public { b = a; } +} +// ---- +// TypeError: (70-71): Type bytes storage ref is not implicitly convertible to expected type uint256[] storage ref. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/153_array_copy_with_different_types2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/153_array_copy_with_different_types2.sol new file mode 100644 index 00000000..8d1cb1ef --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/153_array_copy_with_different_types2.sol @@ -0,0 +1,7 @@ +contract c { + uint32[] a; + uint8[] b; + function f() public { b = a; } +} +// ---- +// TypeError: (74-75): Type uint32[] storage ref is not implicitly convertible to expected type uint8[] storage ref. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/154_array_copy_with_different_types_conversion_possible.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/154_array_copy_with_different_types_conversion_possible.sol new file mode 100644 index 00000000..b15a9350 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/154_array_copy_with_different_types_conversion_possible.sol @@ -0,0 +1,5 @@ +contract c { + uint32[] a; + uint8[] b; + function f() public { a = b; } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/155_array_copy_with_different_types_static_dynamic.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/155_array_copy_with_different_types_static_dynamic.sol new file mode 100644 index 00000000..025593a5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/155_array_copy_with_different_types_static_dynamic.sol @@ -0,0 +1,5 @@ +contract c { + uint32[] a; + uint8[80] b; + function f() public { a = b; } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/156_array_copy_with_different_types_dynamic_static.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/156_array_copy_with_different_types_dynamic_static.sol new file mode 100644 index 00000000..90aa53a0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/156_array_copy_with_different_types_dynamic_static.sol @@ -0,0 +1,7 @@ +contract c { + uint[] a; + uint[80] b; + function f() public { b = a; } +} +// ---- +// TypeError: (73-74): Type uint256[] storage ref is not implicitly convertible to expected type uint256[80] storage ref. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/157_array_of_undeclared_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/157_array_of_undeclared_type.sol new file mode 100644 index 00000000..1409db5e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/157_array_of_undeclared_type.sol @@ -0,0 +1,5 @@ +contract c { + a[] public foo; +} +// ---- +// DeclarationError: (17-18): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/158_storage_variable_initialization_with_incorrect_type_int.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/158_storage_variable_initialization_with_incorrect_type_int.sol new file mode 100644 index 00000000..b1ef153e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/158_storage_variable_initialization_with_incorrect_type_int.sol @@ -0,0 +1,5 @@ +contract c { + uint8 a = 1000; +} +// ---- +// TypeError: (27-31): Type int_const 1000 is not implicitly convertible to expected type uint8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/159_storage_variable_initialization_with_incorrect_type_string.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/159_storage_variable_initialization_with_incorrect_type_string.sol new file mode 100644 index 00000000..75736d98 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/159_storage_variable_initialization_with_incorrect_type_string.sol @@ -0,0 +1,5 @@ +contract c { + uint a = "abc"; +} +// ---- +// TypeError: (26-31): Type literal_string "abc" is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/160_test_byte_is_alias_of_byte1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/160_test_byte_is_alias_of_byte1.sol new file mode 100644 index 00000000..9977c839 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/160_test_byte_is_alias_of_byte1.sol @@ -0,0 +1,7 @@ +contract c { + bytes arr; + function f() public { byte a = arr[0];} +} +// ---- +// Warning: (54-60): Unused local variable. +// Warning: (32-71): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol new file mode 100644 index 00000000..957322af --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol @@ -0,0 +1,5 @@ +contract Foo { + bytes32 a = 7; +} +// ---- +// Warning: (31-32): Decimal literal assigned to bytesXX variable will be left-aligned. Use an explicit conversion to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol new file mode 100644 index 00000000..bc32580a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol @@ -0,0 +1,3 @@ +contract Foo { + bytes32 a = 0x1234; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol new file mode 100644 index 00000000..af921869 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol @@ -0,0 +1,3 @@ +contract Foo { + bytes32 a = bytes32(7); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/164_assigning_value_to_const_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/164_assigning_value_to_const_variable.sol new file mode 100644 index 00000000..4e543e70 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/164_assigning_value_to_const_variable.sol @@ -0,0 +1,6 @@ +contract Foo { + function changeIt() public { x = 9; } + uint constant x = 56; +} +// ---- +// TypeError: (48-49): Cannot assign to a constant variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol new file mode 100644 index 00000000..0de15dfb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol @@ -0,0 +1,5 @@ +contract C { + address constant x = msg.sender; +} +// ---- +// TypeError: (38-48): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol new file mode 100644 index 00000000..dc0a6e63 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; + +contract C { + address constant x = msg.sender; +} +// ---- +// TypeError: (69-79): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/167_constant_string_literal_disallows_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/167_constant_string_literal_disallows_assignment.sol new file mode 100644 index 00000000..3f19ea3b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/167_constant_string_literal_disallows_assignment.sol @@ -0,0 +1,10 @@ +contract Test { + string constant x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca"; + function f() public { + // Even if this is made possible in the future, we should not allow assignment + // to elements of constant arrays. + x[0] = "f"; + } +} +// ---- +// TypeError: (261-265): Index access for string is not possible. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/168_assignment_to_const_var_involving_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/168_assignment_to_const_var_involving_conversion.sol new file mode 100644 index 00000000..fb31e199 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/168_assignment_to_const_var_involving_conversion.sol @@ -0,0 +1,3 @@ +contract C { + C constant x = C(0x123); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/169_assignment_to_const_var_involving_expression.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/169_assignment_to_const_var_involving_expression.sol new file mode 100644 index 00000000..692aad9f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/169_assignment_to_const_var_involving_expression.sol @@ -0,0 +1,3 @@ +contract C { + uint constant x = 0x123 + 0x456; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/170_assignment_to_const_var_involving_keccak.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/170_assignment_to_const_var_involving_keccak.sol new file mode 100644 index 00000000..54f022bb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/170_assignment_to_const_var_involving_keccak.sol @@ -0,0 +1,3 @@ +contract C { + bytes32 constant x = keccak256("abc"); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/171_assignment_to_const_array_vars.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/171_assignment_to_const_array_vars.sol new file mode 100644 index 00000000..b9e9aa7a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/171_assignment_to_const_array_vars.sol @@ -0,0 +1,5 @@ +contract C { + uint[3] constant x = [uint(1), 2, 3]; +} +// ---- +// TypeError: (17-53): Constants of non-value type not yet implemented. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/172_assignment_to_const_string_bytes.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/172_assignment_to_const_string_bytes.sol new file mode 100644 index 00000000..f0e1528c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/172_assignment_to_const_string_bytes.sol @@ -0,0 +1,5 @@ +contract C { + bytes constant a = "\x00\x01\x02"; + bytes constant b = hex"000102"; + string constant c = "hello"; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/173_constant_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/173_constant_struct.sol new file mode 100644 index 00000000..07bf0439 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/173_constant_struct.sol @@ -0,0 +1,6 @@ +contract C { + struct S { uint x; uint[] y; } + S constant x = S(5, new uint[](4)); +} +// ---- +// TypeError: (52-86): Constants of non-value type not yet implemented. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/174_address_is_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/174_address_is_constant.sol new file mode 100644 index 00000000..10850e16 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/174_address_is_constant.sol @@ -0,0 +1,3 @@ +contract C { + address constant x = 0x1212121212121212121212121212121212121212; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/175_uninitialized_const_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/175_uninitialized_const_variable.sol new file mode 100644 index 00000000..13496d8b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/175_uninitialized_const_variable.sol @@ -0,0 +1,5 @@ +contract Foo { + uint constant y; +} +// ---- +// TypeError: (19-34): Uninitialized "constant" variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/176_overloaded_function_cannot_resolve.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/176_overloaded_function_cannot_resolve.sol new file mode 100644 index 00000000..bcf25948 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/176_overloaded_function_cannot_resolve.sol @@ -0,0 +1,7 @@ +contract test { + function f() public returns (uint) { return 1; } + function f(uint a) public returns (uint) { return a; } + function g() public returns (uint) { return f(3, 5); } +} +// ---- +// TypeError: (176-177): No matching declaration found after argument-dependent lookup. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/177_ambiguous_overloaded_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/177_ambiguous_overloaded_function.sol new file mode 100644 index 00000000..759e02f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/177_ambiguous_overloaded_function.sol @@ -0,0 +1,8 @@ +contract test { + function f(uint8 a) public returns (uint) { return a; } + function f(uint a) public returns (uint) { return 2 * a; } + // literal 1 can be both converted to uint and uint8, so the call is ambiguous. + function g() public returns (uint) { return f(1); } +} +// ---- +// TypeError: (271-272): No unique declaration found after argument-dependent lookup. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol new file mode 100644 index 00000000..07fc1c43 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol @@ -0,0 +1,6 @@ +contract test { + function f(uint a) public returns (uint) { return 2 * a; } + function g() public returns (uint) { function (uint) returns (uint) x = f; return x(7); } +} +// ---- +// Warning: (20-78): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol new file mode 100644 index 00000000..9ed864f1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol @@ -0,0 +1,7 @@ +contract test { + function f() public returns (uint) { return 1; } + function f(uint a) public returns (uint) { return 2 * a; } + function g() public returns (uint) { function (uint) returns (uint) x = f; return x(7); } +} +// ---- +// TypeError: (208-209): No matching declaration found after variable lookup. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/180_external_types_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/180_external_types_clash.sol new file mode 100644 index 00000000..91ddcd9b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/180_external_types_clash.sol @@ -0,0 +1,9 @@ +contract base { + enum a { X } + function f(a) public { } +} +contract test is base { + function f(uint8 a) public { } +} +// ---- +// TypeError: (37-61): Function overload clash during conversion to external types for arguments. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/181_override_changes_return_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/181_override_changes_return_types.sol new file mode 100644 index 00000000..c887f259 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/181_override_changes_return_types.sol @@ -0,0 +1,8 @@ +contract base { + function f(uint a) public returns (uint) { } +} +contract test is base { + function f(uint a) public returns (uint8) { } +} +// ---- +// TypeError: (95-140): Overriding function return types differ. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/182_equal_overload.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/182_equal_overload.sol new file mode 100644 index 00000000..cb9eb3fa --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/182_equal_overload.sol @@ -0,0 +1,7 @@ +contract C { + function test(uint a) public returns (uint b) { } + function test(uint a) external {} +} +// ---- +// DeclarationError: (17-66): Function with same name and arguments defined twice. +// TypeError: (17-66): Overriding function visibility differs. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol new file mode 100644 index 00000000..5440b425 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol @@ -0,0 +1,5 @@ +contract C { + string s = "\xa0\x00"; +} +// ---- +// TypeError: (28-38): Type literal_string (contains invalid UTF-8 sequence at position 0) is not implicitly convertible to expected type string storage ref. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol new file mode 100644 index 00000000..401c46e2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol @@ -0,0 +1,5 @@ +contract C { + string s = string("\xa0\x00"); +} +// ---- +// TypeError: (28-46): Explicit type conversion not allowed from "literal_string (contains invalid UTF-8 sequence at position 0)" to "string storage pointer". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol new file mode 100644 index 00000000..5e406d0c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol @@ -0,0 +1,3 @@ +contract C { + string s = "\xf0\x9f\xa6\x84"; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol new file mode 100644 index 00000000..9d51e06b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol @@ -0,0 +1,6 @@ +contract C { + string s; + function f() public { bytes1 a = s[2]; } +} +// ---- +// TypeError: (64-68): Index access for string is not possible. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol new file mode 100644 index 00000000..9e714d68 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol @@ -0,0 +1,6 @@ +contract C { + string s; + function f() public { uint a = s.length; } +} +// ---- +// TypeError: (62-70): Member "length" not found or not visible after argument-dependent lookup in string storage ref diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/190_negative_integers_to_signed_out_of_bound.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/190_negative_integers_to_signed_out_of_bound.sol new file mode 100644 index 00000000..2e8503af --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/190_negative_integers_to_signed_out_of_bound.sol @@ -0,0 +1,5 @@ +contract test { + int8 public i = -129; +} +// ---- +// TypeError: (36-40): Type int_const -129 is not implicitly convertible to expected type int8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/191_negative_integers_to_signed_min.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/191_negative_integers_to_signed_min.sol new file mode 100644 index 00000000..211cfee2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/191_negative_integers_to_signed_min.sol @@ -0,0 +1,3 @@ +contract test { + int8 public i = -128; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/192_positive_integers_to_signed_out_of_bound.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/192_positive_integers_to_signed_out_of_bound.sol new file mode 100644 index 00000000..d56045c2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/192_positive_integers_to_signed_out_of_bound.sol @@ -0,0 +1,5 @@ +contract test { + int8 public j = 128; +} +// ---- +// TypeError: (36-39): Type int_const 128 is not implicitly convertible to expected type int8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/193_positive_integers_to_signed_out_of_bound_max.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/193_positive_integers_to_signed_out_of_bound_max.sol new file mode 100644 index 00000000..66701339 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/193_positive_integers_to_signed_out_of_bound_max.sol @@ -0,0 +1,3 @@ +contract test { + int8 public j = 127; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/194_negative_integers_to_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/194_negative_integers_to_unsigned.sol new file mode 100644 index 00000000..3702f09b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/194_negative_integers_to_unsigned.sol @@ -0,0 +1,5 @@ +contract test { + uint8 public x = -1; +} +// ---- +// TypeError: (37-39): Type int_const -1 is not implicitly convertible to expected type uint8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/195_positive_integers_to_unsigned_out_of_bound.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/195_positive_integers_to_unsigned_out_of_bound.sol new file mode 100644 index 00000000..81216229 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/195_positive_integers_to_unsigned_out_of_bound.sol @@ -0,0 +1,5 @@ +contract test { + uint8 public x = 700; +} +// ---- +// TypeError: (37-40): Type int_const 700 is not implicitly convertible to expected type uint8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol new file mode 100644 index 00000000..db42786d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol @@ -0,0 +1,3 @@ +contract test { function() external { uint x = 1; uint y = 2; x || y; } } +// ---- +// TypeError: (62-68): Operator || not compatible with types uint256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol new file mode 100644 index 00000000..94d1c691 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol @@ -0,0 +1,3 @@ +contract test { function() external { uint x = 1; uint y = 2; x && y; } } +// ---- +// TypeError: (62-68): Operator && not compatible with types uint256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol new file mode 100644 index 00000000..68fe6e94 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol @@ -0,0 +1,3 @@ +contract test { function() external { uint x = 1; !x; } } +// ---- +// TypeError: (50-52): Unary operator ! cannot be applied to type uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol new file mode 100644 index 00000000..fbeadfb6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol @@ -0,0 +1,3 @@ +contract test { function() external { uint x = 3; int y = -4; x ** y; } } +// ---- +// TypeError: (62-68): Operator ** not compatible with types uint256 and int256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol new file mode 100644 index 00000000..75e92085 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol @@ -0,0 +1,3 @@ +contract test { function() external { uint x = 3; int y = -4; y ** x; } } +// ---- +// TypeError: (62-68): Operator ** not compatible with types int256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol new file mode 100644 index 00000000..93e5f065 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol @@ -0,0 +1,3 @@ +contract test { function() external { int x = -3; int y = -4; x ** y; } } +// ---- +// TypeError: (62-68): Operator ** not compatible with types int256 and int256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol new file mode 100644 index 00000000..711b794c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol @@ -0,0 +1,3 @@ +contract test { bytes a; bytes b; function() external { a == b; } } +// ---- +// TypeError: (56-62): Operator == not compatible with types bytes storage ref and bytes storage ref diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol new file mode 100644 index 00000000..a74850b3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol @@ -0,0 +1,10 @@ +contract test { + struct s {uint a;} + s x; + s y; + function() external { + x == y; + } +} +// ---- +// TypeError: (79-85): Operator == not compatible with types struct test.s storage ref and struct test.s storage ref diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/204_overwrite_memory_location_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/204_overwrite_memory_location_external.sol new file mode 100644 index 00000000..16d71ca4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/204_overwrite_memory_location_external.sol @@ -0,0 +1,5 @@ +contract C { + function f(uint[] memory a) external {} +} +// ---- +// TypeError: (28-43): Location has to be calldata for external functions (remove the "memory" or "storage" keyword). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/205_overwrite_storage_location_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/205_overwrite_storage_location_external.sol new file mode 100644 index 00000000..99c9827d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/205_overwrite_storage_location_external.sol @@ -0,0 +1,5 @@ +contract C { + function f(uint[] storage a) external {} +} +// ---- +// TypeError: (28-44): Location has to be calldata for external functions (remove the "memory" or "storage" keyword). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/206_storage_location_local_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/206_storage_location_local_variables.sol new file mode 100644 index 00000000..868d7bc8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/206_storage_location_local_variables.sol @@ -0,0 +1,9 @@ +contract C { + uint[] m_x; + function f() public view { + uint[] storage x = m_x; + uint[] memory y; + x;y; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol new file mode 100644 index 00000000..5220ee22 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + mapping(uint=>uint)[] memory x; + } +} +// ---- +// TypeError: (47-77): Type mapping(uint256 => uint256)[] memory is only valid in storage. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol new file mode 100644 index 00000000..febe39e6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol @@ -0,0 +1,9 @@ +contract C { + uint[] data; + function f(uint[] x) public { + uint[] storage dataRef = data; + dataRef = x; + } +} +// ---- +// TypeError: (121-122): Type uint256[] memory is not implicitly convertible to expected type uint256[] storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/209_storage_assign_to_different_local_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/209_storage_assign_to_different_local_variable.sol new file mode 100644 index 00000000..aabdcd88 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/209_storage_assign_to_different_local_variable.sol @@ -0,0 +1,12 @@ +contract C { + uint[] data; + uint8[] otherData; + function f() public { + uint8[] storage x = otherData; + uint[] storage y = data; + y = x; + // note that data = otherData works + } +} +// ---- +// TypeError: (163-164): Type uint8[] storage pointer is not implicitly convertible to expected type uint256[] storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol new file mode 100644 index 00000000..6b25cdfe --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + mapping(uint => uint) x; + x; + } +} +// ---- +// TypeError: (47-70): Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/211_uninitialized_mapping_array_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/211_uninitialized_mapping_array_variable.sol new file mode 100644 index 00000000..edae7549 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/211_uninitialized_mapping_array_variable.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + mapping(uint => uint)[] storage x; + x; + } +} +// ---- +// DeclarationError: (52-85): Uninitialized storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol new file mode 100644 index 00000000..7a6fb1c7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol @@ -0,0 +1,9 @@ +contract C { + uint[] data; + function f() public { + uint[] storage x = data; + delete x; + } +} +// ---- +// TypeError: (97-105): Unary operator delete cannot be applied to type uint256[] storage pointer diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/214_assignment_mem_storage_variable_directly.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/214_assignment_mem_storage_variable_directly.sol new file mode 100644 index 00000000..08737f2d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/214_assignment_mem_storage_variable_directly.sol @@ -0,0 +1,6 @@ +contract C { + uint[] data; + function f(uint[] x) public { + data = x; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/215_function_argument_mem_to_storage.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/215_function_argument_mem_to_storage.sol new file mode 100644 index 00000000..4d75732a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/215_function_argument_mem_to_storage.sol @@ -0,0 +1,9 @@ +contract C { + function f(uint[] storage x) private { + } + function g(uint[] x) public { + f(x); + } +} +// ---- +// TypeError: (106-107): Invalid type for argument in function call. Invalid implicit conversion from uint256[] memory to uint256[] storage pointer requested. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol new file mode 100644 index 00000000..157ef4dd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol @@ -0,0 +1,10 @@ +contract C { + function f(uint[] storage x) private { + g(x); + } + function g(uint[] x) public { + } +} +// ---- +// Warning: (91-99): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (80-115): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/217_mem_array_assignment_changes_base_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/217_mem_array_assignment_changes_base_type.sol new file mode 100644 index 00000000..3755b935 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/217_mem_array_assignment_changes_base_type.sol @@ -0,0 +1,10 @@ +contract C { + function f(uint8[] memory x) private { + // Such an assignment is possible in storage, but not in memory + // (because it would incur an otherwise unnecessary copy). + // This requirement might be lifted, though. + uint[] memory y = x; + } +} +// ---- +// TypeError: (256-275): Type uint8[] memory is not implicitly convertible to expected type uint256[] memory. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/219_memory_arrays_not_resizeable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/219_memory_arrays_not_resizeable.sol new file mode 100644 index 00000000..93d8cd42 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/219_memory_arrays_not_resizeable.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + uint[] memory x; + x.length = 2; + } +} +// ---- +// TypeError: (72-80): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/220_struct_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/220_struct_constructor.sol new file mode 100644 index 00000000..50585c11 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/220_struct_constructor.sol @@ -0,0 +1,9 @@ +contract C { + struct S { uint a; bool x; } + function f() public { + S memory s = S(1, true); + } +} +// ---- +// Warning: (80-90): Unused local variable. +// Warning: (50-110): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/221_struct_constructor_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/221_struct_constructor_nested.sol new file mode 100644 index 00000000..00222682 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/221_struct_constructor_nested.sol @@ -0,0 +1,11 @@ +contract C { + struct X { uint x1; uint x2; } + struct S { uint s1; uint[3] s2; X s3; } + function f() public { + uint[3] memory s2; + S memory s = S(1, s2, X(4, 5)); + } +} +// ---- +// Warning: (153-163): Unused local variable. +// Warning: (96-190): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/222_struct_named_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/222_struct_named_constructor.sol new file mode 100644 index 00000000..8ab8ee46 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/222_struct_named_constructor.sol @@ -0,0 +1,9 @@ +contract C { + struct S { uint a; bool x; } + function f() public { + S memory s = S({a: 1, x: true}); + } +} +// ---- +// Warning: (80-90): Unused local variable. +// Warning: (50-118): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/223_literal_strings.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/223_literal_strings.sol new file mode 100644 index 00000000..1dadcc4d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/223_literal_strings.sol @@ -0,0 +1,9 @@ +contract Foo { + function f() public { + string memory long = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; + string memory short = "123"; + long; short; + } +} +// ---- +// Warning: (19-238): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/224_string_bytes_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/224_string_bytes_conversion.sol new file mode 100644 index 00000000..137aa893 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/224_string_bytes_conversion.sol @@ -0,0 +1,17 @@ +contract Test { + string s; + bytes b; + function h(string _s) external { bytes(_s).length; } + function i(string _s) internal { bytes(_s).length; } + function j() internal { bytes(s).length; } + function k(bytes _b) external { string(_b); } + function l(bytes _b) internal { string(_b); } + function m() internal { string(b); } +} +// ---- +// Warning: (47-99): Function state mutability can be restricted to pure +// Warning: (104-156): Function state mutability can be restricted to pure +// Warning: (161-203): Function state mutability can be restricted to view +// Warning: (208-253): Function state mutability can be restricted to pure +// Warning: (258-303): Function state mutability can be restricted to pure +// Warning: (308-344): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/225_inheriting_from_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/225_inheriting_from_library.sol new file mode 100644 index 00000000..eff7bf86 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/225_inheriting_from_library.sol @@ -0,0 +1,4 @@ +library Lib {} +contract Test is Lib {} +// ---- +// TypeError: (32-35): Libraries cannot be inherited from. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/226_inheriting_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/226_inheriting_library.sol new file mode 100644 index 00000000..2d601c1c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/226_inheriting_library.sol @@ -0,0 +1,4 @@ +contract Test {} +library Lib is Test {} +// ---- +// TypeError: (17-39): Library is not allowed to inherit. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/227_library_having_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/227_library_having_variables.sol new file mode 100644 index 00000000..804ef3d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/227_library_having_variables.sol @@ -0,0 +1,3 @@ +library Lib { uint x; } +// ---- +// TypeError: (14-20): Library cannot have non-constant state variables diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/228_valid_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/228_valid_library.sol new file mode 100644 index 00000000..de6b0b3e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/228_valid_library.sol @@ -0,0 +1 @@ +library Lib { uint constant x = 9; } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/229_call_to_library_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/229_call_to_library_function.sol new file mode 100644 index 00000000..c007d9a1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/229_call_to_library_function.sol @@ -0,0 +1,10 @@ +library Lib { + function min(uint, uint) public returns (uint); +} +contract Test { + function f() public { + uint t = Lib.min(12, 7); + } +} +// ---- +// Warning: (118-124): Unused local variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol new file mode 100644 index 00000000..8624b0b0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol @@ -0,0 +1,5 @@ +contract Test { + function f() public { Test x = new Test(); } +} +// ---- +// TypeError: (51-59): Circular reference for contract creation (cannot create instance of derived or same contract). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/231_array_out_of_bound_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/231_array_out_of_bound_access.sol new file mode 100644 index 00000000..7230a0a6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/231_array_out_of_bound_access.sol @@ -0,0 +1,9 @@ +contract c { + uint[2] dataArray; + function set5th() public returns (bool) { + dataArray[5] = 2; + return true; + } +} +// ---- +// TypeError: (90-102): Out of bounds array access. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/232_literal_string_to_storage_pointer.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/232_literal_string_to_storage_pointer.sol new file mode 100644 index 00000000..a586dc80 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/232_literal_string_to_storage_pointer.sol @@ -0,0 +1,6 @@ +contract C { + function f() public { string x = "abc"; } +} +// ---- +// Warning: (39-47): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. +// TypeError: (39-55): Type literal_string "abc" is not implicitly convertible to expected type string storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/233_non_initialized_references.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/233_non_initialized_references.sol new file mode 100644 index 00000000..a0b6f71e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/233_non_initialized_references.sol @@ -0,0 +1,11 @@ +contract C { + struct s { + uint a; + } + function f() public { + s storage x; + x.a = 2; + } +} +// ---- +// DeclarationError: (84-95): Uninitialized storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/235_abi_encode_with_large_integer_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/235_abi_encode_with_large_integer_constant.sol new file mode 100644 index 00000000..fd9717f1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/235_abi_encode_with_large_integer_constant.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public { abi.encode(2**500); } +} +// ---- +// TypeError: (55-61): Invalid rational number (too large or division by zero). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/236_cyclic_binary_dependency.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/236_cyclic_binary_dependency.sol new file mode 100644 index 00000000..c287507d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/236_cyclic_binary_dependency.sol @@ -0,0 +1,5 @@ +contract A { function f() public { new B(); } } +contract B { function f() public { new C(); } } +contract C { function f() public { new A(); } } +// ---- +// TypeError: (131-136): Circular reference for contract creation (cannot create instance of derived or same contract). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/237_cyclic_binary_dependency_via_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/237_cyclic_binary_dependency_via_inheritance.sol new file mode 100644 index 00000000..00ee536e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/237_cyclic_binary_dependency_via_inheritance.sol @@ -0,0 +1,5 @@ +contract A is B { } +contract B { function f() public { new C(); } } +contract C { function f() public { new A(); } } +// ---- +// TypeError: (14-15): Definition of base has to precede definition of derived contract diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol new file mode 100644 index 00000000..0da5c7ee --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol @@ -0,0 +1,19 @@ +contract C { + function three() public returns (uint, uint, uint); + function two() public returns (uint, uint); + function none() public; + function f() public { + (uint a,) = three(); + (uint b, uint c,) = two(); + (,uint d) = three(); + (,uint e, uint g) = two(); + var (,,) = three(); + var () = none(); + a;b;c;d;e;g; + } +} +// ---- +// Warning: (179-198): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (208-233): Different number of components on the left hand side (3) than on the right hand side (2). +// Warning: (243-262): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (272-297): Different number of components on the left hand side (3) than on the right hand side (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol new file mode 100644 index 00000000..0ccbb327 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol @@ -0,0 +1,7 @@ +contract C { + function one() public returns (uint); + function f() public { (uint a, uint b, ) = one(); } +} +// ---- +// Warning: (81-107): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (81-107): Not enough components (1) in value to assign all variables (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol new file mode 100644 index 00000000..8d5de125 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol @@ -0,0 +1,7 @@ +contract C { + function one() public returns (uint); + function f() public { (uint a, , ) = one(); } +} +// ---- +// Warning: (81-101): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (81-101): Not enough components (1) in value to assign all variables (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol new file mode 100644 index 00000000..993df9b9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol @@ -0,0 +1,7 @@ +contract C { + function one() public returns (uint); + function f() public { (, , uint a) = one(); } +} +// ---- +// Warning: (81-101): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (81-101): Not enough components (1) in value to assign all variables (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol new file mode 100644 index 00000000..0697b789 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol @@ -0,0 +1,7 @@ +contract C { + function one() public returns (uint); + function f() public { (, uint a, uint b) = one(); } +} +// ---- +// Warning: (81-107): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (81-107): Not enough components (1) in value to assign all variables (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol new file mode 100644 index 00000000..3112f67a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol @@ -0,0 +1,13 @@ +contract C { + function f() public { + uint a = (1); + (uint b,) = (uint8(1),); + (uint c, uint d) = (uint32(1), 2 + a); + (uint e,) = (uint64(1), 2, b); + a;b;c;d;e; + } +} +// ---- +// Warning: (69-92): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (149-178): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (17-204): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/245_tuples_empty_components.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/245_tuples_empty_components.sol new file mode 100644 index 00000000..7815edea --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/245_tuples_empty_components.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + (1,,2); + } +} +// ---- +// TypeError: (47-53): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/246_multi_variable_declaration_wildcards_fail_5.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/246_multi_variable_declaration_wildcards_fail_5.sol new file mode 100644 index 00000000..3d2d0705 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/246_multi_variable_declaration_wildcards_fail_5.sol @@ -0,0 +1,6 @@ +contract C { + function one() public returns (uint); + function f() public { var (,) = one(); } +} +// ---- +// TypeError: (81-96): Wildcard both at beginning and end of variable declaration list is only allowed if the number of components is equal. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol new file mode 100644 index 00000000..cc5953db --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol @@ -0,0 +1,7 @@ +contract C { + function two() public returns (uint, uint); + function f() public { (uint a, uint b, uint c) = two(); } +} +// ---- +// Warning: (87-119): Different number of components on the left hand side (3) than on the right hand side (2). +// TypeError: (87-119): Not enough components (2) in value to assign all variables (3). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol new file mode 100644 index 00000000..bcdbde02 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (uint a, uint b) { + (a, b) += (1, 1); + } +} +// ---- +// TypeError: (72-88): Compound assignment is not allowed for tuple types. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/250_member_access_parser_ambiguity.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/250_member_access_parser_ambiguity.sol new file mode 100644 index 00000000..f5252180 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/250_member_access_parser_ambiguity.sol @@ -0,0 +1,17 @@ +contract C { + struct R { uint[10][10] y; } + struct S { uint a; uint b; uint[20][20][20] c; R d; } + S data; + function f() public { + C.S x = data; + C.S memory y; + C.S[10] memory z; + C.S[10]; + y.a = 2; + x.c[1][2][3] = 9; + x.d.y[2][2] = 3; + } +} +// ---- +// Warning: (150-155): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. +// Warning: (194-210): Unused local variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/251_using_for_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/251_using_for_library.sol new file mode 100644 index 00000000..c7dcdbcd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/251_using_for_library.sol @@ -0,0 +1,4 @@ +library D { } +contract C { + using D for uint; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/252_using_for_not_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/252_using_for_not_library.sol new file mode 100644 index 00000000..4693b27f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/252_using_for_not_library.sol @@ -0,0 +1,6 @@ +contract D { } +contract C { + using D for uint; +} +// ---- +// TypeError: (38-39): Library name expected. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/253_using_for_function_exists.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/253_using_for_function_exists.sol new file mode 100644 index 00000000..9e570805 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/253_using_for_function_exists.sol @@ -0,0 +1,10 @@ +library D { function double(uint self) public returns (uint) { return 2*self; } } +contract C { + using D for uint; + function f(uint a) public { + a.double; + } +} +// ---- +// Warning: (12-79): Function state mutability can be restricted to pure +// Warning: (121-172): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/254_using_for_function_on_int.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/254_using_for_function_on_int.sol new file mode 100644 index 00000000..a8e23d0f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/254_using_for_function_on_int.sol @@ -0,0 +1,9 @@ +library D { function double(uint self) public returns (uint) { return 2*self; } } +contract C { + using D for uint; + function f(uint a) public returns (uint) { + return a.double(); + } +} +// ---- +// Warning: (12-79): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/255_using_for_function_on_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/255_using_for_function_on_struct.sol new file mode 100644 index 00000000..2c3deb4c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/255_using_for_function_on_struct.sol @@ -0,0 +1,8 @@ +library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } } +contract C { + using D for D.s; + D.s x; + function f(uint a) public returns (uint) { + return x.mul(a); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol new file mode 100644 index 00000000..155281f5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol @@ -0,0 +1,14 @@ +library D { + struct s { uint a; } + function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } + function mul(s storage, bytes32) public returns (bytes32) { } +} +contract C { + using D for D.s; + D.s x; + function f(uint a) public returns (uint) { + return x.mul(a); + } +} +// ---- +// Warning: (128-189): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/257_using_for_by_name.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/257_using_for_by_name.sol new file mode 100644 index 00000000..b3eab987 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/257_using_for_by_name.sol @@ -0,0 +1,8 @@ +library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } } +contract C { + using D for D.s; + D.s x; + function f(uint a) public returns (uint) { + return x.mul({x: a}); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol new file mode 100644 index 00000000..84e42072 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol @@ -0,0 +1,9 @@ +library D { function double(bytes32 self) public returns (uint) { return 2; } } +contract C { + using D for uint; + function f(uint a) public returns (uint) { + return a.double(); + } +} +// ---- +// TypeError: (177-185): Member "double" not found or not visible after argument-dependent lookup in uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol new file mode 100644 index 00000000..fae918b7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol @@ -0,0 +1,11 @@ +library D { function double(uint self) public returns (uint) { return 2; } } +contract C { + using D for uint; + function f(uint16 a) public returns (uint) { + // This is an error because the function is only bound to uint. + // Had it been bound to *, it would have worked. + return a.double(); + } +} +// ---- +// TypeError: (305-313): Member "double" not found or not visible after argument-dependent lookup in uint16 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol new file mode 100644 index 00000000..e06ba2d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol @@ -0,0 +1,8 @@ +pragma experimental ABIEncoderV2; +library c { + struct S { uint x; } + function f() public returns (S ) {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// Warning: (75-110): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol new file mode 100644 index 00000000..ced4705f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol @@ -0,0 +1,10 @@ +library D { function double(bytes32 self) public returns (uint) { return 2; } } +contract C { + using D for *; + function f(uint a) public returns (uint) { + // Bound to a, but self type does not match. + return a.double(); + } +} +// ---- +// TypeError: (227-235): Member "double" not found or not visible after argument-dependent lookup in uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol new file mode 100644 index 00000000..c3cc5232 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol @@ -0,0 +1,13 @@ +library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } } +contract C { + using D for D.s; + D.s x; + function f(uint a) public returns (uint) { + function (D.s storage, uint) returns (uint) g = x.mul; + g(x, a); + g(a); + } +} +// ---- +// TypeError: (218-271): Type function (struct D.s storage pointer,uint256) returns (uint256) is not implicitly convertible to expected type function (struct D.s storage pointer,uint256) returns (uint256). +// TypeError: (298-302): Wrong argument count for function call: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol new file mode 100644 index 00000000..71f43992 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol @@ -0,0 +1,14 @@ +library L { + struct R { uint[10][10] y; } + struct S { uint a; uint b; uint[20][20][20] c; R d; } +} +contract C { + function f(uint size) public { + L.S[][] memory x = new L.S[][](10); + uint[] memory y = new uint[](20); + bytes memory z = new bytes(size); + x;y;z; + } +} +// ---- +// Warning: (122-301): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol new file mode 100644 index 00000000..f0bb557b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint size) public { + mapping(uint => uint) x = new mapping(uint => uint)[](4); + } +} +// ---- +// TypeError: (86-109): Type cannot live outside storage. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol new file mode 100644 index 00000000..c4b2c692 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint size) public { + uint x = new uint(7); + } +} +// ---- +// TypeError: (65-73): Contract or array type expected. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol new file mode 100644 index 00000000..078255e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint size) public { + uint[] memory x = new uint[](); + } +} +// ---- +// TypeError: (74-86): Wrong argument count for function call: 0 arguments given but expected 1. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol new file mode 100644 index 00000000..35671e6f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol @@ -0,0 +1,9 @@ +contract C { + struct S { uint a; uint b; } + + function f() public { + S memory s = S({a: 1}); + } +} +// ---- +// TypeError: (94-103): Wrong argument count for struct constructor: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol new file mode 100644 index 00000000..97e68aa3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol @@ -0,0 +1,4 @@ +contract M { + function f(uint[]) public; + function f(int[]) public; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol new file mode 100644 index 00000000..023404f7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol @@ -0,0 +1,11 @@ + contract C { + function f() public returns (uint) { + uint8 x = 7; + uint16 y = 8; + uint32 z = 9; + uint32[3] memory ending = [x, y, z]; + return (ending[1]); + } + } +// ---- +// Warning: (25-229): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol new file mode 100644 index 00000000..d7765d7b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol @@ -0,0 +1,10 @@ +contract C { + function f() public returns (string) { + string memory x = "Hello"; + string memory y = "World"; + string[2] memory z = [x, y]; + return (z[0]); + } +} +// ---- +// Warning: (17-191): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol new file mode 100644 index 00000000..e7036bdf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol @@ -0,0 +1,8 @@ +contract C { + function f() public returns (uint) { + uint8[4] memory z = [1,2,3,5]; + return (z[0]); + } +} +// ---- +// Warning: (17-121): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol new file mode 100644 index 00000000..dd39af85 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol @@ -0,0 +1,8 @@ +contract C { + function f() public returns (string) { + string[2] memory z = ["Hello", "World"]; + return (z[0]); + } +} +// ---- +// Warning: (17-133): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol new file mode 100644 index 00000000..4d3e6aed --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (uint) { + return ([4,5,6][1]); + } +} +// ---- +// Warning: (17-88): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol new file mode 100644 index 00000000..fbc028c5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (string) { + return (["foo", "man", "choo"][1]); + } +} +// ---- +// Warning: (17-105): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol new file mode 100644 index 00000000..bdf033a3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol @@ -0,0 +1,12 @@ +contract C { + struct S { + uint a; + string b; + } + function f() public { + S[2] memory x = [S({a: 1, b: "fish"}), S({a: 2, b: "fish"})]; + } +} +// ---- +// Warning: (102-115): Unused local variable. +// Warning: (72-169): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol new file mode 100644 index 00000000..6c8aabd5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + uint[3] x = [45, 'foo', true]; + } +} +// ---- +// Warning: (47-56): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. +// TypeError: (59-76): Unable to deduce common type for array elements. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol new file mode 100644 index 00000000..e613758b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + uint8[4][4] memory dyn = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]; + } +} +// ---- +// Warning: (47-69): Unused local variable. +// Warning: (17-135): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol new file mode 100644 index 00000000..5a39f550 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + [1, 2, 3]++; + [1, 2, 3] = [4, 5, 6]; + } +} +// ---- +// TypeError: (47-56): Inline array type cannot be declared as LValue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/279_break_not_in_loop.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/279_break_not_in_loop.sol new file mode 100644 index 00000000..6b88da44 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/279_break_not_in_loop.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + if (true) + break; + } +} +// ---- +// SyntaxError: (69-74): "break" has to be in a "for" or "while" loop. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/280_continue_not_in_loop.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/280_continue_not_in_loop.sol new file mode 100644 index 00000000..b0e8cda9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/280_continue_not_in_loop.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + if (true) + continue; + } +} +// ---- +// SyntaxError: (69-77): "continue" has to be in a "for" or "while" loop. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/281_continue_not_in_loop_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/281_continue_not_in_loop_2.sol new file mode 100644 index 00000000..845faf86 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/281_continue_not_in_loop_2.sol @@ -0,0 +1,10 @@ +contract C { + function f() public { + while (true) + { + } + continue; + } +} +// ---- +// SyntaxError: (88-96): "continue" has to be in a "for" or "while" loop. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/282_invalid_different_types_for_conditional_expression.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/282_invalid_different_types_for_conditional_expression.sol new file mode 100644 index 00000000..e4e75e3f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/282_invalid_different_types_for_conditional_expression.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + true ? true : 2; + } +} +// ---- +// TypeError: (47-62): True expression's type bool doesn't match false expression's type uint8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/283_left_value_in_conditional_expression_not_supported_yet.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/283_left_value_in_conditional_expression_not_supported_yet.sol new file mode 100644 index 00000000..ef8f9930 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/283_left_value_in_conditional_expression_not_supported_yet.sol @@ -0,0 +1,10 @@ +contract C { + function f() public { + uint x; + uint y; + (true ? x : y) = 1; + } +} +// ---- +// TypeError: (80-92): Conditional expression as left value is not supported yet. +// TypeError: (80-92): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/284_conditional_expression_with_different_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/284_conditional_expression_with_different_struct.sol new file mode 100644 index 00000000..049d9e21 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/284_conditional_expression_with_different_struct.sol @@ -0,0 +1,15 @@ +contract C { + struct s1 { + uint x; + } + struct s2 { + uint x; + } + function f() public { + s1 memory x; + s2 memory y; + true ? x : y; + } +} +// ---- +// TypeError: (165-177): True expression's type struct C.s1 memory doesn't match false expression's type struct C.s2 memory. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/285_conditional_expression_with_different_function_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/285_conditional_expression_with_different_function_type.sol new file mode 100644 index 00000000..963fb7da --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/285_conditional_expression_with_different_function_type.sol @@ -0,0 +1,10 @@ +contract C { + function x(bool) public {} + function y() public {} + + function f() public { + true ? x : y; + } +} +// ---- +// TypeError: (106-118): True expression's type function (bool) doesn't match false expression's type function (). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/286_conditional_expression_with_different_enum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/286_conditional_expression_with_different_enum.sol new file mode 100644 index 00000000..8c312624 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/286_conditional_expression_with_different_enum.sol @@ -0,0 +1,13 @@ +contract C { + enum small { A, B, C, D } + enum big { A, B, C, D } + + function f() public { + small x; + big y; + + true ? x : y; + } +} +// ---- +// TypeError: (139-151): True expression's type enum C.small doesn't match false expression's type enum C.big. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/287_conditional_expression_with_different_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/287_conditional_expression_with_different_mapping.sol new file mode 100644 index 00000000..8139f3ed --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/287_conditional_expression_with_different_mapping.sol @@ -0,0 +1,10 @@ +contract C { + mapping(uint8 => uint8) table1; + mapping(uint32 => uint8) table2; + + function f() public { + true ? table1 : table2; + } +} +// ---- +// TypeError: (121-143): True expression's type mapping(uint8 => uint8) doesn't match false expression's type mapping(uint32 => uint8). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol new file mode 100644 index 00000000..41e72d60 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol @@ -0,0 +1,91 @@ +contract C { + struct s1 { + uint x; + } + s1 struct_x; + s1 struct_y; + + function fun_x() public {} + function fun_y() public {} + + enum small { A, B, C, D } + + mapping(uint8 => uint8) table1; + mapping(uint8 => uint8) table2; + + function f() public { + // integers + uint x; + uint y; + uint g = true ? x : y; + g += 1; // Avoid unused var warning + + // integer constants + uint h = true ? 1 : 3; + h += 1; // Avoid unused var warning + + // string literal + string memory i = true ? "hello" : "world"; + i = "used"; //Avoid unused var warning + } + function f2() public { + // bool + bool j = true ? true : false; + j = j && true; // Avoid unused var warning + + // real is not there yet. + + // array + byte[2] memory a; + byte[2] memory b; + byte[2] memory k = true ? a : b; + k[0] = byte(0); //Avoid unused var warning + + bytes memory e; + bytes memory f; + bytes memory l = true ? e : f; + l[0] = byte(0); // Avoid unused var warning + + // fixed bytes + bytes2 c; + bytes2 d; + bytes2 m = true ? c : d; + m &= m; + + } + function f3() public { + // contract doesn't fit in here + + // struct + struct_x = true ? struct_x : struct_y; + + // function + function () r = true ? fun_x : fun_y; + r(); // Avoid unused var warning + // enum + small enum_x; + small enum_y; + enum_x = true ? enum_x : enum_y; + + // tuple + (uint n, uint o) = true ? (1, 2) : (3, 4); + (n, o) = (o, n); // Avoid unused var warning + // mapping + mapping(uint8 => uint8) p = true ? table1 : table2; + p[0] = 0; // Avoid unused var warning + // typetype + uint32 q = true ? uint32(1) : uint32(2); + q += 1; // Avoid unused var warning + // modifier doesn't fit in here + + // magic doesn't fit in here + + // module doesn't fit in here + } +} +// ---- +// Warning: (1005-1019): This declaration shadows an existing declaration. +// Warning: (90-116): Function state mutability can be restricted to pure +// Warning: (121-147): Function state mutability can be restricted to pure +// Warning: (257-642): Function state mutability can be restricted to pure +// Warning: (647-1227): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/289_uint7_and_uintM_as_identifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/289_uint7_and_uintM_as_identifier.sol new file mode 100644 index 00000000..58e84090 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/289_uint7_and_uintM_as_identifier.sol @@ -0,0 +1,12 @@ +contract test { +string uintM = "Hello 4 you"; + function f() public { + uint8 uint7 = 3; + uint7 = 5; + string memory intM; + uint bytesM = 21; + intM; bytesM; + } +} +// ---- +// Warning: (50-197): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol new file mode 100644 index 00000000..1b6bbae7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol @@ -0,0 +1,11 @@ +contract test { + function f() public { + uintM something = 3; + intM should = 4; + bytesM fail = "now"; + } +} +// ---- +// DeclarationError: (50-55): Identifier not found or not unique. +// DeclarationError: (79-83): Identifier not found or not unique. +// DeclarationError: (104-110): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol new file mode 100644 index 00000000..2f3143d5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol @@ -0,0 +1,9 @@ +contract test { + modifier mod() { _; } + + function f() public { + mod g; + } +} +// ---- +// TypeError: (77-80): Name has to refer to a struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol new file mode 100644 index 00000000..9187c19d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol @@ -0,0 +1,10 @@ +contract test { + modifier mod() { _; } + + function f() public { + mod g; + g = f; + } +} +// ---- +// TypeError: (77-80): Name has to refer to a struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol new file mode 100644 index 00000000..390eccd9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol @@ -0,0 +1,10 @@ +contract test { + function foo() public { + } + + function f() public { + foo g; + } +} +// ---- +// TypeError: (85-88): Name has to refer to a struct, enum or contract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/294_long_uint_variable_fails.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/294_long_uint_variable_fails.sol new file mode 100644 index 00000000..1e608320 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/294_long_uint_variable_fails.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + uint99999999999999999999999999 something = 3; + } +} +// ---- +// DeclarationError: (50-80): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/295_bytes10abc_is_identifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/295_bytes10abc_is_identifier.sol new file mode 100644 index 00000000..8b65fc65 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/295_bytes10abc_is_identifier.sol @@ -0,0 +1,8 @@ +contract test { + function f() public { + bytes32 bytes10abc = "abc"; + } +} +// ---- +// Warning: (50-68): Unused local variable. +// Warning: (20-83): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/296_int10abc_is_identifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/296_int10abc_is_identifier.sol new file mode 100644 index 00000000..2678cfb9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/296_int10abc_is_identifier.sol @@ -0,0 +1,9 @@ +contract test { + function f() public { + uint uint10abc = 3; + int int10abc = 4; + uint10abc; int10abc; + } +} +// ---- +// Warning: (20-130): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol new file mode 100644 index 00000000..918544cc --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol @@ -0,0 +1,8 @@ +library L { function l() public {} } +contract test { + function f() public { + L.l.value; + } +} +// ---- +// TypeError: (87-96): Member "value" not found or not visible after argument-dependent lookup in function () - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/298_invalid_fixed_types_0x7_mxn.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/298_invalid_fixed_types_0x7_mxn.sol new file mode 100644 index 00000000..ea9e5d0f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/298_invalid_fixed_types_0x7_mxn.sol @@ -0,0 +1,5 @@ +contract test { + fixed0x7 a = .3; +} +// ---- +// DeclarationError: (20-28): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/299_invalid_fixed_types_long_invalid_identifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/299_invalid_fixed_types_long_invalid_identifier.sol new file mode 100644 index 00000000..9ce2b106 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/299_invalid_fixed_types_long_invalid_identifier.sol @@ -0,0 +1,5 @@ +contract test { + fixed99999999999999999999999999999999999999x7 b = 9.5; +} +// ---- +// DeclarationError: (20-65): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/300_invalid_fixed_types_7x8_mxn.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/300_invalid_fixed_types_7x8_mxn.sol new file mode 100644 index 00000000..7c511d2f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/300_invalid_fixed_types_7x8_mxn.sol @@ -0,0 +1,5 @@ +contract test { + fixed7x8 c = 3.12345678; +} +// ---- +// DeclarationError: (20-28): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol new file mode 100644 index 00000000..82e4a0d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol @@ -0,0 +1,9 @@ +library L { function l() public {} } +contract test { + function f() public { + L x; + x.l(); + } +} +// ---- +// TypeError: (100-103): Member "l" not found or not visible after argument-dependent lookup in library L diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/302_invalid_fixed_type_long.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/302_invalid_fixed_type_long.sol new file mode 100644 index 00000000..12679631 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/302_invalid_fixed_type_long.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + fixed8x888888888888888888888888888888888888888888888888888 b; + } +} +// ---- +// DeclarationError: (50-108): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/303_fixed_type_int_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/303_fixed_type_int_conversion.sol new file mode 100644 index 00000000..ddf1e5fb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/303_fixed_type_int_conversion.sol @@ -0,0 +1,11 @@ +contract test { + function f() public { + uint64 a = 3; + int64 b = 4; + fixed c = b; + ufixed d = a; + c; d; + } +} +// ---- +// Warning: (20-147): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/304_fixed_type_rational_int_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/304_fixed_type_rational_int_conversion.sol new file mode 100644 index 00000000..16d2cbad --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/304_fixed_type_rational_int_conversion.sol @@ -0,0 +1,9 @@ +contract test { + function f() public { + fixed c = 3; + ufixed d = 4; + c; d; + } +} +// ---- +// Warning: (20-104): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/305_fixed_type_rational_fraction_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/305_fixed_type_rational_fraction_conversion.sol new file mode 100644 index 00000000..27029860 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/305_fixed_type_rational_fraction_conversion.sol @@ -0,0 +1,9 @@ +contract test { + function f() public { + fixed a = 4.5; + ufixed d = 2.5; + a; d; + } +} +// ---- +// Warning: (20-108): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/306_invalid_int_implicit_conversion_from_fixed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/306_invalid_int_implicit_conversion_from_fixed.sol new file mode 100644 index 00000000..c0a56314 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/306_invalid_int_implicit_conversion_from_fixed.sol @@ -0,0 +1,9 @@ +contract test { + function f() public { + fixed a = 4.5; + int b = a; + a; b; + } +} +// ---- +// TypeError: (73-82): Type fixed128x18 is not implicitly convertible to expected type int256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/307_rational_unary_minus_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/307_rational_unary_minus_operation.sol new file mode 100644 index 00000000..7827e57b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/307_rational_unary_minus_operation.sol @@ -0,0 +1,7 @@ +contract test { + function f() pure public { + ufixed16x2 a = 3.25; + fixed16x2 b = -3.25; + a; b; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol new file mode 100644 index 00000000..eb7c6ea9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol @@ -0,0 +1,9 @@ +contract test { + function f() pure public { + ufixed16x2 a = +3.25; + fixed16x2 b = -3.25; + a; b; + } +} +// ---- +// Warning: (70-75): Use of unary + is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/309_rational_unary_plus_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/309_rational_unary_plus_assignment.sol new file mode 100644 index 00000000..a5bdd6c8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/309_rational_unary_plus_assignment.sol @@ -0,0 +1,8 @@ +contract test { + function f(uint x) pure public { + uint y = +x; + y; + } +} +// ---- +// Warning: (70-72): Use of unary + is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/310_rational_unary_plus_operation_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/310_rational_unary_plus_operation_v050.sol new file mode 100644 index 00000000..140655af --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/310_rational_unary_plus_operation_v050.sol @@ -0,0 +1,10 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + ufixed16x2 a = +3.25; + fixed16x2 b = -3.25; + a; b; + } +} +// ---- +// SyntaxError: (100-105): Use of unary + is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/311_rational_unary_plus_assignment_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/311_rational_unary_plus_assignment_v050.sol new file mode 100644 index 00000000..7e5c0feb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/311_rational_unary_plus_assignment_v050.sol @@ -0,0 +1,9 @@ +pragma experimental "v0.5.0"; +contract test { + function f(uint x) pure public { + uint y = +x; + y; + } +} +// ---- +// SyntaxError: (100-102): Use of unary + is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/312_leading_zero_rationals_convert.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/312_leading_zero_rationals_convert.sol new file mode 100644 index 00000000..9fe7c6f7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/312_leading_zero_rationals_convert.sol @@ -0,0 +1,9 @@ +contract A { + function f() pure public { + ufixed16x2 a = 0.5; + ufixed256x52 b = 0.0000000000000006661338147750939242541790008544921875; + fixed16x2 c = -0.5; + fixed256x52 d = -0.0000000000000006661338147750939242541790008544921875; + a; b; c; d; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol new file mode 100644 index 00000000..441cf81e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol @@ -0,0 +1,13 @@ +contract test { + function f() public { + ufixed256x1 a = 123456781234567979695948382928485849359686494864095409282048094275023098123.5; + ufixed256x77 b = 0.920890746623327805482905058466021565416131529487595827354393978494366605267637; + ufixed224x78 c = 0.000000000001519884736399797998492268541131529487595827354393978494366605267646; + fixed256x1 d = -123456781234567979695948382928485849359686494864095409282048094275023098123.5; + fixed256x76 e = -0.93322335481643744342575580035176794825198893968114429702091846411734101080123; + fixed256x79 g = -0.0001178860664374434257558003517679482519889396811442970209184641173410108012309; + a; b; c; d; e; g; + } +} +// ---- +// Warning: (20-707): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/314_fixed_type_zero_handling.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/314_fixed_type_zero_handling.sol new file mode 100644 index 00000000..5f0d2909 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/314_fixed_type_zero_handling.sol @@ -0,0 +1,8 @@ +contract test { + function f() public { + fixed16x2 a = 0; a; + ufixed32x1 b = 0; b; + } +} +// ---- +// Warning: (20-104): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/315_fixed_type_invalid_implicit_conversion_size.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/315_fixed_type_invalid_implicit_conversion_size.sol new file mode 100644 index 00000000..79698228 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/315_fixed_type_invalid_implicit_conversion_size.sol @@ -0,0 +1,8 @@ +contract test { + function f() public { + ufixed a = 11/4; + ufixed248x8 b = a; b; + } +} +// ---- +// TypeError: (75-92): Type ufixed128x18 is not implicitly convertible to expected type ufixed248x8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/316_fixed_type_invalid_implicit_conversion_lost_data.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/316_fixed_type_invalid_implicit_conversion_lost_data.sol new file mode 100644 index 00000000..76c0284e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/316_fixed_type_invalid_implicit_conversion_lost_data.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + ufixed256x1 a = 1/3; a; + } +} +// ---- +// TypeError: (50-69): Type rational_const 1 / 3 is not implicitly convertible to expected type ufixed256x1. Try converting to type ufixed256x77 or use an explicit conversion. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/317_fixed_type_valid_explicit_conversions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/317_fixed_type_valid_explicit_conversions.sol new file mode 100644 index 00000000..38801457 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/317_fixed_type_valid_explicit_conversions.sol @@ -0,0 +1,9 @@ +contract test { + function f() public { + ufixed256x80 a = ufixed256x80(1/3); a; + ufixed248x80 b = ufixed248x80(1/3); b; + ufixed8x1 c = ufixed8x1(1/3); c; + } +} +// ---- +// Warning: (20-182): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/318_invalid_array_declaration_with_rational.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/318_invalid_array_declaration_with_rational.sol new file mode 100644 index 00000000..3dd779ec --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/318_invalid_array_declaration_with_rational.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + uint[3.5] a; a; + } +} +// ---- +// TypeError: (55-58): Array with fractional length specified. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/319_invalid_array_declaration_with_signed_fixed_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/319_invalid_array_declaration_with_signed_fixed_type.sol new file mode 100644 index 00000000..83f0950d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/319_invalid_array_declaration_with_signed_fixed_type.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + uint[fixed(3.5)] a; a; + } +} +// ---- +// TypeError: (55-65): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/320_invalid_array_declaration_with_unsigned_fixed_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/320_invalid_array_declaration_with_unsigned_fixed_type.sol new file mode 100644 index 00000000..26d5a85e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/320_invalid_array_declaration_with_unsigned_fixed_type.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + uint[ufixed(3.5)] a; a; + } +} +// ---- +// TypeError: (55-66): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/321_rational_to_bytes_implicit_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/321_rational_to_bytes_implicit_conversion.sol new file mode 100644 index 00000000..d209eb76 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/321_rational_to_bytes_implicit_conversion.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + bytes32 c = 3.2; c; + } +} +// ---- +// TypeError: (50-65): Type rational_const 16 / 5 is not implicitly convertible to expected type bytes32. Try converting to type ufixed8x1 or use an explicit conversion. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/322_fixed_to_bytes_implicit_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/322_fixed_to_bytes_implicit_conversion.sol new file mode 100644 index 00000000..86736481 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/322_fixed_to_bytes_implicit_conversion.sol @@ -0,0 +1,8 @@ +contract test { + function f() public { + fixed a = 3.25; + bytes32 c = a; c; + } +} +// ---- +// TypeError: (74-87): Type fixed128x18 is not implicitly convertible to expected type bytes32. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/323_mapping_with_fixed_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/323_mapping_with_fixed_literal.sol new file mode 100644 index 00000000..8e28d4e1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/323_mapping_with_fixed_literal.sol @@ -0,0 +1,6 @@ +contract test { + mapping(ufixed8x1 => string) fixedString; + function f() public { + fixedString[0.5] = "Half"; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/324_fixed_points_inside_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/324_fixed_points_inside_structs.sol new file mode 100644 index 00000000..8aa0abc2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/324_fixed_points_inside_structs.sol @@ -0,0 +1,7 @@ +contract test { + struct myStruct { + ufixed a; + int b; + } + myStruct a = myStruct(3.125, 3); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol new file mode 100644 index 00000000..c46297c3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol @@ -0,0 +1,8 @@ +contract test { + function f() public { + fixed[3] memory a = [fixed(3.5), fixed(-4.25), fixed(967.125)]; + } +} +// ---- +// Warning: (50-67): Unused local variable. +// Warning: (20-119): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol new file mode 100644 index 00000000..bdc3c2c1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol @@ -0,0 +1,8 @@ +contract test { + function f() public { + ufixed128x3[4] memory a = [ufixed128x3(3.5), 4.125, 2.5, 4.0]; + } +} +// ---- +// Warning: (50-73): Unused local variable. +// Warning: (20-118): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/327_rational_index_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/327_rational_index_access.sol new file mode 100644 index 00000000..46e58521 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/327_rational_index_access.sol @@ -0,0 +1,8 @@ +contract test { + function f() public { + uint[] memory a; + a[.5]; + } +} +// ---- +// TypeError: (77-79): Type rational_const 1 / 2 is not implicitly convertible to expected type uint256. Try converting to type ufixed8x1 or use an explicit conversion. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/328_rational_to_fixed_literal_expression.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/328_rational_to_fixed_literal_expression.sol new file mode 100644 index 00000000..35456fa6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/328_rational_to_fixed_literal_expression.sol @@ -0,0 +1,15 @@ +contract test { + function f() public { + ufixed64x8 a = 3.5 * 3; + ufixed64x8 b = 4 - 2.5; + ufixed64x8 c = 11 / 4; + ufixed240x5 d = 599 + 0.21875; + ufixed256x80 e = ufixed256x80(35.245 % 12.9); + ufixed256x80 f = ufixed256x80(1.2 % 2); + fixed g = 2 ** -2; + a; b; c; d; e; f; g; + } +} +// ---- +// Warning: (238-252): This declaration shadows an existing declaration. +// Warning: (20-339): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol new file mode 100644 index 00000000..b835e309 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + fixed g = 2 ** -2.2; + } +} +// ---- +// TypeError: (60-69): Operator ** not compatible with types int_const 2 and rational_const -11 / 5 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol new file mode 100644 index 00000000..04ddf0fd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + ufixed b = 3 ** 2.5; + } +} +// ---- +// TypeError: (61-69): Operator ** not compatible with types int_const 3 and rational_const 5 / 2 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol new file mode 100644 index 00000000..4e0894c5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + 2 ** (1/2); + } +} +// ---- +// TypeError: (50-60): Operator ** not compatible with types int_const 2 and rational_const 1 / 2 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol new file mode 100644 index 00000000..bc127bf5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + 42 ** (-1/4); + } +} +// ---- +// TypeError: (50-62): Operator ** not compatible with types int_const 42 and rational_const -1 / 4 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol new file mode 100644 index 00000000..0fd5f331 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + ufixed a = 3 ** ufixed(1.5); + } +} +// ---- +// TypeError: (61-77): Operator ** not compatible with types int_const 3 and ufixed128x18 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol new file mode 100644 index 00000000..03d10f7c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + ufixed c = 42 ** fixed(-1/4); + } +} +// ---- +// TypeError: (61-78): Operator ** not compatible with types int_const 42 and fixed128x18 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol new file mode 100644 index 00000000..44a6ab5e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + ~fixed(3.5); + } +} +// ---- +// TypeError: (50-61): Unary operator ~ cannot be applied to type fixed128x18 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol new file mode 100644 index 00000000..29871b04 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + fixed(1.5) | 3; + } +} +// ---- +// TypeError: (50-64): Operator | not compatible with types fixed128x18 and int_const 3 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol new file mode 100644 index 00000000..1fa7f38f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + fixed(1.75) ^ 3; + } +} +// ---- +// TypeError: (50-65): Operator ^ not compatible with types fixed128x18 and int_const 3 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol new file mode 100644 index 00000000..5a433a61 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + fixed(1.75) & 3; + } +} +// ---- +// TypeError: (50-65): Operator & not compatible with types fixed128x18 and int_const 3 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/342_missing_bool_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/342_missing_bool_conversion.sol new file mode 100644 index 00000000..5546a099 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/342_missing_bool_conversion.sol @@ -0,0 +1,7 @@ +contract test { + function b(uint a) public { + bool(a == 1); + } +} +// ---- +// Warning: (20-75): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/343_integer_and_fixed_interaction.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/343_integer_and_fixed_interaction.sol new file mode 100644 index 00000000..af4d048b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/343_integer_and_fixed_interaction.sol @@ -0,0 +1,8 @@ +contract test { + function f() public { + ufixed a = uint64(1) + ufixed(2); + } +} +// ---- +// Warning: (50-58): Unused local variable. +// Warning: (20-89): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/344_one_divided_by_three_integer_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/344_one_divided_by_three_integer_conversion.sol new file mode 100644 index 00000000..ffc168eb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/344_one_divided_by_three_integer_conversion.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + uint a = 1/3; + } +} +// ---- +// TypeError: (50-62): Type rational_const 1 / 3 is not implicitly convertible to expected type uint256. Try converting to type ufixed256x77 or use an explicit conversion. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol new file mode 100644 index 00000000..7f640505 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol @@ -0,0 +1,8 @@ +contract test { + function g() public returns (uint) {} + function f() public { + g(); + } +} +// ---- +// Warning: (20-57): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/346_unused_return_value_send.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/346_unused_return_value_send.sol new file mode 100644 index 00000000..929e54b2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/346_unused_return_value_send.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + address(0x12).send(1); + } +} +// ---- +// Warning: (50-71): Failure condition of 'send' ignored. Consider using 'transfer' instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/347_unused_return_value_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/347_unused_return_value_call.sol new file mode 100644 index 00000000..994a5bdf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/347_unused_return_value_call.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + address(0x12).call("abc"); + } +} +// ---- +// Warning: (50-75): Return value of low-level calls not used. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol new file mode 100644 index 00000000..1ac7c6f3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + address(0x12).call.value(2)("abc"); + } +} +// ---- +// Warning: (50-84): Return value of low-level calls not used. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/350_unused_return_value_delegatecall.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/350_unused_return_value_delegatecall.sol new file mode 100644 index 00000000..701b6e7d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/350_unused_return_value_delegatecall.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + address(0x12).delegatecall("abc"); + } +} +// ---- +// Warning: (50-83): Return value of low-level calls not used. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/351_callcode_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/351_callcode_deprecated.sol new file mode 100644 index 00000000..554f2e11 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/351_callcode_deprecated.sol @@ -0,0 +1,7 @@ +contract test { + function f() pure public { + address(0x12).callcode; + } +} +// ---- +// TypeError: (55-77): "callcode" has been deprecated in favour of "delegatecall". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol new file mode 100644 index 00000000..c0e29b38 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + address(0x12).callcode; + } +} +// ---- +// TypeError: (85-107): "callcode" has been deprecated in favour of "delegatecall". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/353_callcode_not_deprecated_as_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/353_callcode_not_deprecated_as_function.sol new file mode 100644 index 00000000..714014f8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/353_callcode_not_deprecated_as_function.sol @@ -0,0 +1,5 @@ +contract test { + function callcode() pure public { + test.callcode(); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/354_payable_in_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/354_payable_in_library.sol new file mode 100644 index 00000000..410842cb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/354_payable_in_library.sol @@ -0,0 +1,5 @@ +library test { + function f() payable public {} +} +// ---- +// TypeError: (19-49): Library functions cannot be payable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/355_payable_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/355_payable_external.sol new file mode 100644 index 00000000..3b75e1b7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/355_payable_external.sol @@ -0,0 +1,3 @@ +contract test { + function f() payable external {} +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol new file mode 100644 index 00000000..f6ccf6b6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol @@ -0,0 +1,5 @@ +contract test { + function f() payable internal {} +} +// ---- +// TypeError: (20-52): Internal functions cannot be payable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol new file mode 100644 index 00000000..7b00ea6c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol @@ -0,0 +1,5 @@ +contract test { + function f() payable private {} +} +// ---- +// TypeError: (20-51): Internal functions cannot be payable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/358_illegal_override_payable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/358_illegal_override_payable.sol new file mode 100644 index 00000000..6696772e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/358_illegal_override_payable.sol @@ -0,0 +1,4 @@ +contract B { function f() payable public {} } +contract C is B { function f() public {} } +// ---- +// TypeError: (64-86): Overriding function changes state mutability from "payable" to "nonpayable". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/359_illegal_override_payable_nonpayable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/359_illegal_override_payable_nonpayable.sol new file mode 100644 index 00000000..99b45fdd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/359_illegal_override_payable_nonpayable.sol @@ -0,0 +1,4 @@ +contract B { function f() public {} } +contract C is B { function f() payable public {} } +// ---- +// TypeError: (56-86): Overriding function changes state mutability from "nonpayable" to "payable". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/360_function_variable_mixin.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/360_function_variable_mixin.sol new file mode 100644 index 00000000..583e0d46 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/360_function_variable_mixin.sol @@ -0,0 +1,12 @@ +// bug #1798 (cpp-ethereum), related to #1286 (solidity) +contract attribute { + bool ok = false; +} +contract func { + function ok() public returns (bool) { return true; } +} +contract attr_func is attribute, func { + function checkOk() public returns (bool) { return ok(); } +} +// ---- +// DeclarationError: (121-173): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol new file mode 100644 index 00000000..8ef4d579 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol @@ -0,0 +1,6 @@ +contract receiver { function pay() payable public {} } +contract test { + function f() public { (new receiver()).pay.value(10)(); } + receiver r = new receiver(); + function g() public { r.pay.value(10)(); } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/362_calling_nonpayable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/362_calling_nonpayable.sol new file mode 100644 index 00000000..d47ea2bd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/362_calling_nonpayable.sol @@ -0,0 +1,6 @@ +contract receiver { function nopay() public {} } +contract test { + function f() public { (new receiver()).nopay.value(10)(); } +} +// ---- +// TypeError: (91-119): Member "value" not found or not visible after argument-dependent lookup in function () external - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol new file mode 100644 index 00000000..27381904 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol @@ -0,0 +1,11 @@ +contract C { + constructor() public { } +} +contract D { + function f() public returns (uint) { + (new C).value(2)(); + return 2; + } +} +// ---- +// TypeError: (106-119): Member "value" not found or not visible after argument-dependent lookup in function () returns (contract C) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol new file mode 100644 index 00000000..cc2839cd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol @@ -0,0 +1,6 @@ +contract test { + struct S { uint x; } + constructor(uint k) public { S[k]; } +} +// ---- +// TypeError: (76-77): Integer constant expected. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol new file mode 100644 index 00000000..415acb3c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol @@ -0,0 +1,14 @@ +library B { + function b() public {} +} + +contract A { + using B for bytes; + + function a() public { + bytes memory x; + x.b(); + } +} +// ---- +// TypeError: (137-140): Member "b" not found or not visible after argument-dependent lookup in bytes memory diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol new file mode 100644 index 00000000..9c941a68 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol @@ -0,0 +1,5 @@ +contract C { + uint public a = 0x42 << -8; +} +// ---- +// TypeError: (33-43): Operator << not compatible with types int_const 66 and int_const -8 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol new file mode 100644 index 00000000..55f385c6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol @@ -0,0 +1,5 @@ +contract C { + uint public a = 0x42 >> -8; +} +// ---- +// TypeError: (33-43): Operator >> not compatible with types int_const 66 and int_const -8 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol new file mode 100644 index 00000000..e23c7a84 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol @@ -0,0 +1,5 @@ +contract C { + uint public a = 0x42 << 0x100000000; +} +// ---- +// TypeError: (33-52): Operator << not compatible with types int_const 66 and int_const 4294967296 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol new file mode 100644 index 00000000..5533644f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol @@ -0,0 +1,5 @@ +contract C { + uint public a = 0x42 >> 0x100000000; +} +// ---- +// TypeError: (33-52): Operator >> not compatible with types int_const 66 and int_const 4294967296 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol new file mode 100644 index 00000000..38d9b051 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol @@ -0,0 +1,5 @@ +contract C { + uint public a = 0x42 >> (1 / 2); +} +// ---- +// TypeError: (33-48): Operator >> not compatible with types int_const 66 and rational_const 1 / 2 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol new file mode 100644 index 00000000..273e1844 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol @@ -0,0 +1,10 @@ +contract test { + function f() public { + assembly { + 1 + } + } +} +// ---- +// Warning: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// DeclarationError: (59-84): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol new file mode 100644 index 00000000..bda090b4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol @@ -0,0 +1,10 @@ +contract test { + function f() public { + assembly { + pop + } + } +} +// ---- +// Warning: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead. +// DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol new file mode 100644 index 00000000..4cda64e7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol @@ -0,0 +1,9 @@ +pragma experimental "v0.5.0"; +contract c { + uint8 x; + function f() public { + assembly { pop(x) } + } +} +// ---- +// TypeError: (105-106): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol new file mode 100644 index 00000000..d6dcc4d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol @@ -0,0 +1,14 @@ +pragma experimental "v0.5.0"; +contract test { + modifier m { + uint a = 1; + assembly { + a := 2 + } + _; + } + function f() public m { + } +} +// ---- +// Warning: (152-181): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol new file mode 100644 index 00000000..9a2065e2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract test { + uint x = 1; + function f() public { + assembly { + x := 2 + } + } +} +// ---- +// TypeError: (119-120): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol new file mode 100644 index 00000000..b99179ef --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol @@ -0,0 +1,14 @@ +pragma experimental "v0.5.0"; +contract test { + uint x = 1; + modifier m { + assembly { + x := 2 + } + _; + } + function f() public m { + } +} +// ---- +// TypeError: (110-111): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol new file mode 100644 index 00000000..866232dd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract test { + uint constant x = 1; + function f() public { + assembly { + x := 2 + } + } +} +// ---- +// TypeError: (128-129): Constant variables not supported by inline assembly. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol new file mode 100644 index 00000000..a41858a0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract test { + uint constant x = 1; + function f() public { + assembly { + let y := x + } + } +} +// ---- +// TypeError: (137-138): Constant variables not supported by inline assembly. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol new file mode 100644 index 00000000..93004ef6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract test { + function f() public { + uint a; + assembly { + function g() -> x { x := a } + } + } +} +// ---- +// DeclarationError: (144-145): Cannot access local Solidity variables from inside an inline assembly function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol new file mode 100644 index 00000000..913ea725 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol @@ -0,0 +1,12 @@ +pragma experimental "v0.5.0"; +contract test { + uint[] r; + function f() public { + uint[] storage a = r; + assembly { + function g() -> x { x := a_offset } + } + } +} +// ---- +// DeclarationError: (172-180): Cannot access local Solidity variables from inside an inline assembly function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol new file mode 100644 index 00000000..7528f355 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol @@ -0,0 +1,9 @@ +pragma experimental "v0.5.0"; +contract test { + uint a; + function f() pure public { + assembly { + function g() -> x { x := a_slot } + } + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/384_inline_assembly_constant_variable_via_offset.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/384_inline_assembly_constant_variable_via_offset.sol new file mode 100644 index 00000000..6470a210 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/384_inline_assembly_constant_variable_via_offset.sol @@ -0,0 +1,10 @@ +contract test { + uint constant x = 2; + function f() pure public { + assembly { + let r := x_offset + } + } +} +// ---- +// TypeError: (112-120): Constant variables not supported by inline assembly. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol new file mode 100644 index 00000000..d95fd978 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol @@ -0,0 +1,10 @@ +pragma experimental "v0.5.0"; +contract C { + function f(bytes bytesAsCalldata) external { + assembly { + let x := bytesAsCalldata + } + } +} +// ---- +// TypeError: (132-147): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol new file mode 100644 index 00000000..a5f0f96c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract C { + function f() pure public { + assembly { + 1 + } + } +} +// ---- +// SyntaxError: (105-106): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// DeclarationError: (91-116): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol new file mode 100644 index 00000000..7b68c60b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol @@ -0,0 +1,10 @@ +contract C { + function f() pure public { + assembly { + 1 + } + } +} +// ---- +// Warning: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// DeclarationError: (61-86): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol new file mode 100644 index 00000000..4a7aca8a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol @@ -0,0 +1,12 @@ +pragma experimental "v0.5.0"; +contract C { + function f() view public { + assembly { + address + pop + } + } +} +// ---- +// SyntaxError: (105-112): The use of non-functional instructions is deprecated. Please use functional notation instead. +// SyntaxError: (125-128): The use of non-functional instructions is deprecated. Please use functional notation instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol new file mode 100644 index 00000000..c44412cf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol @@ -0,0 +1,11 @@ +contract C { + function f() view public { + assembly { + address + pop + } + } +} +// ---- +// Warning: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead. +// Warning: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol new file mode 100644 index 00000000..77a73ebc --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract C { + function f() pure public { + assembly { + label: + } + } +} +// ---- +// SyntaxError: (105-110): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead. +// SyntaxError: (105-110): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol new file mode 100644 index 00000000..15bd6660 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol @@ -0,0 +1,10 @@ +contract C { + function f() pure public { + assembly { + label: + } + } +} +// ---- +// Warning: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead. +// Warning: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol new file mode 100644 index 00000000..0c98ada1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol @@ -0,0 +1,10 @@ +pragma experimental "v0.5.0"; +contract C { + function f() pure public { + assembly { + jump(2) + } + } +} +// ---- +// SyntaxError: (105-112): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol new file mode 100644 index 00000000..c3c82ce8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol @@ -0,0 +1,10 @@ +contract C { + function f() pure public { + assembly { + jump(2) + } + } +} +// ---- +// Warning: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. +// TypeError: (75-82): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol new file mode 100644 index 00000000..f72fe741 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract C { + function f() pure public { + assembly { + mload(0) + } + } +} +// ---- +// SyntaxError: (105-113): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// DeclarationError: (91-123): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol new file mode 100644 index 00000000..56043ccf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol @@ -0,0 +1,10 @@ +contract C { + function f() pure public { + assembly { + mload(0) + } + } +} +// ---- +// Warning: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// DeclarationError: (61-93): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/396_invalid_mobile_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/396_invalid_mobile_type.sol new file mode 100644 index 00000000..536dd317 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/396_invalid_mobile_type.sol @@ -0,0 +1,8 @@ + contract C { + function f() public { + // Invalid number + [1, 78901234567890123456789012345678901234567890123456789345678901234567890012345678012345678901234567]; + } + } +// ---- +// TypeError: (93-191): Invalid rational number. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol new file mode 100644 index 00000000..4e1f62e1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol @@ -0,0 +1,7 @@ +contract C { + function f() view public { + msg.value; + } +} +// ---- +// Warning: (52-61): "msg.value" used in non-payable function. Do you want to add the "payable" modifier to this function? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/398_does_not_warn_msg_value_in_payable_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/398_does_not_warn_msg_value_in_payable_function.sol new file mode 100644 index 00000000..f14e86ed --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/398_does_not_warn_msg_value_in_payable_function.sol @@ -0,0 +1,5 @@ +contract C { + function f() payable public { + msg.value; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/399_does_not_warn_msg_value_in_internal_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/399_does_not_warn_msg_value_in_internal_function.sol new file mode 100644 index 00000000..8492e691 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/399_does_not_warn_msg_value_in_internal_function.sol @@ -0,0 +1,5 @@ +contract C { + function f() view internal { + msg.value; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/400_does_not_warn_msg_value_in_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/400_does_not_warn_msg_value_in_library.sol new file mode 100644 index 00000000..ce59047e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/400_does_not_warn_msg_value_in_library.sol @@ -0,0 +1,5 @@ +library C { + function f() view public { + msg.value; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/401_does_not_warn_msg_value_in_modifier_following_non_payable_public_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/401_does_not_warn_msg_value_in_modifier_following_non_payable_public_function.sol new file mode 100644 index 00000000..dc1da7c4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/401_does_not_warn_msg_value_in_modifier_following_non_payable_public_function.sol @@ -0,0 +1,4 @@ +contract c { + function f() pure public { } + modifier m() { msg.value; _; } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/402_assignment_to_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/402_assignment_to_constant.sol new file mode 100644 index 00000000..7433bdea --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/402_assignment_to_constant.sol @@ -0,0 +1,6 @@ +contract c { + uint constant a = 1; + function f() public { a = 2; } +} +// ---- +// TypeError: (64-65): Cannot assign to a constant variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol new file mode 100644 index 00000000..8af8098c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol @@ -0,0 +1,10 @@ +pragma experimental ABIEncoderV2; +contract C { + struct S { uint a; T[] sub; } + struct T { uint[] x; } + function f() public returns (uint, S) { + } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// Warning: (112-157): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/404_read_returned_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/404_read_returned_struct.sol new file mode 100644 index 00000000..dd16eae4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/404_read_returned_struct.sol @@ -0,0 +1,12 @@ +pragma experimental ABIEncoderV2; +contract A { + struct T { + int x; + int y; + } + function g() public returns (T) { + return this.g(); + } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol new file mode 100644 index 00000000..81cc7d0d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol @@ -0,0 +1,6 @@ +contract C { + function f() public { + (0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E).transfer(2); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol new file mode 100644 index 00000000..fe4691c2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E; + x; + } +} +// ---- +// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol new file mode 100644 index 00000000..6f4ac730 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + address x = 0xfa0bfc97e48458494ccd857e1a85dc91f7f0046e; + x; + } +} +// ---- +// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol new file mode 100644 index 00000000..da5dc380 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + address x = 0xA0bFc97E48458494Ccd857e1A85DC91F7F0046E; + x; + } +} +// ---- +// SyntaxError: (64-105): This looks like an address but is not exactly 40 hex digits. It is 39 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol new file mode 100644 index 00000000..749612c9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E0; + x; + } +} +// ---- +// SyntaxError: (64-107): This looks like an address but is not exactly 40 hex digits. It is 41 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/410_string_literal_not_convertible_to_address_as_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/410_string_literal_not_convertible_to_address_as_assignment.sol new file mode 100644 index 00000000..13bd1a8f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/410_string_literal_not_convertible_to_address_as_assignment.sol @@ -0,0 +1,6 @@ +// A previous implementation claimed the string would be an address +contract AddrString { + address public test = "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c"; +} +// ---- +// TypeError: (116-160): Type literal_string "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c" is not implicitly convertible to expected type address. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/411_string_literal_not_convertible_to_address_as_return_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/411_string_literal_not_convertible_to_address_as_return_value.sol new file mode 100644 index 00000000..d6b7b987 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/411_string_literal_not_convertible_to_address_as_return_value.sol @@ -0,0 +1,8 @@ +// A previous implementation claimed the string would be an address +contract AddrString { + function f() public returns (address) { + return "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c"; + } +} +// ---- +// TypeError: (149-193): Return argument type literal_string "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c" is not implicitly convertible to expected type (type of first return variable) address. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol new file mode 100644 index 00000000..8e5d81e2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol @@ -0,0 +1,11 @@ +// This tests a crash that occured because we did not stop for fatal errors. +contract C { + struct S { + ftring a; + } + S public s; + function s() public s { + } +} +// ---- +// DeclarationError: (113-119): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol new file mode 100644 index 00000000..9c42bc8f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol @@ -0,0 +1,12 @@ +contract C { + function f() public { + address addr; + uint balance = addr.balance; + bool callRet = addr.call(""); + bool delegatecallRet = addr.delegatecall(""); + bool sendRet = addr.send(1); + addr.transfer(1); + balance; callRet; delegatecallRet; sendRet; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/414_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/414_interface.sol new file mode 100644 index 00000000..77baf7bf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/414_interface.sol @@ -0,0 +1,2 @@ +interface I { +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol new file mode 100644 index 00000000..a5d6561e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol @@ -0,0 +1,5 @@ +interface I { + function() external; + function f() external; +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol new file mode 100644 index 00000000..24b26c04 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol @@ -0,0 +1,7 @@ +interface I { + function f() public { + } +} +// ---- +// TypeError: (18-45): Functions in interfaces cannot have an implementation. +// Warning: (18-45): Functions in interfaces should be declared external. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/417_interface_events.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/417_interface_events.sol new file mode 100644 index 00000000..5959f50d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/417_interface_events.sol @@ -0,0 +1,3 @@ +interface I { + event E(); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/418_interface_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/418_interface_inheritance.sol new file mode 100644 index 00000000..92683cda --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/418_interface_inheritance.sol @@ -0,0 +1,6 @@ +interface A { +} +interface I is A { +} +// ---- +// TypeError: (31-32): Interfaces cannot inherit. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol new file mode 100644 index 00000000..c74d52d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol @@ -0,0 +1,9 @@ +interface I { + struct A { + // This is currently expected to break, but it *may* change in the future. + int dummy; + } +} +// ---- +// TypeError: (18-136): Structs cannot be defined in interfaces. +// TypeError: (120-129): Variables cannot be declared in interfaces. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/420_interface_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/420_interface_variables.sol new file mode 100644 index 00000000..a4292c41 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/420_interface_variables.sol @@ -0,0 +1,5 @@ +interface I { + uint a; +} +// ---- +// TypeError: (18-24): Variables cannot be declared in interfaces. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol new file mode 100644 index 00000000..05e2dcfd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol @@ -0,0 +1,5 @@ +interface I { + function f(uint a) public returns (bool); +} +// ---- +// Warning: (18-59): Functions in interfaces should be declared external. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol new file mode 100644 index 00000000..5513817d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol @@ -0,0 +1,5 @@ +interface I { + enum A { B, C } +} +// ---- +// TypeError: (18-33): Enumerable cannot be declared in interfaces. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol new file mode 100644 index 00000000..d576bb60 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol @@ -0,0 +1,8 @@ +interface I { + function f() external; +} +contract C is I { + function f() public { + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol new file mode 100644 index 00000000..a3dca996 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol @@ -0,0 +1,11 @@ +interface I { + event A(); + function f() external; + function g() external; + function() external; +} +contract C is I { + function f() public { + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/425_interface_implement_public_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/425_interface_implement_public_contract.sol new file mode 100644 index 00000000..d8540288 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/425_interface_implement_public_contract.sol @@ -0,0 +1,7 @@ +interface I { + function f() external; +} +contract C is I { + function f() public { + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol new file mode 100644 index 00000000..510c0d01 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + throw; + } +} +// ---- +// Warning: (52-57): "throw" is deprecated in favour of "revert()", "require()" and "assert()". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol new file mode 100644 index 00000000..170d47d9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract C { + function f() pure public { + throw; + } +} +// ---- +// SyntaxError: (82-87): "throw" is deprecated in favour of "revert()", "require()" and "assert()". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/428_bare_revert.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/428_bare_revert.sol new file mode 100644 index 00000000..8e7817ff --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/428_bare_revert.sol @@ -0,0 +1,8 @@ +contract C { + function f(uint x) pure public { + if (x > 7) + revert; + } +} +// ---- +// TypeError: (81-87): No matching declaration found after variable lookup. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/429_revert_with_reason.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/429_revert_with_reason.sol new file mode 100644 index 00000000..36c238be --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/429_revert_with_reason.sol @@ -0,0 +1,8 @@ +contract C { + function f(uint x) pure public { + if (x > 7) + revert("abc"); + else + revert(); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/430_bare_selfdestruct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/430_bare_selfdestruct.sol new file mode 100644 index 00000000..9adc3d39 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/430_bare_selfdestruct.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public { selfdestruct; } +} +// ---- +// Warning: (44-56): Statement has no effect. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/431_bare_assert.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/431_bare_assert.sol new file mode 100644 index 00000000..38cea057 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/431_bare_assert.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public { assert; } +} +// ---- +// Warning: (44-50): Statement has no effect. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/432_bare_require.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/432_bare_require.sol new file mode 100644 index 00000000..62fe8baf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/432_bare_require.sol @@ -0,0 +1,6 @@ +contract C { + // This is different because it does have overloads. + function f() pure public { require; } +} +// ---- +// TypeError: (101-108): No matching declaration found after variable lookup. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/433_pure_statement_in_for_loop.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/433_pure_statement_in_for_loop.sol new file mode 100644 index 00000000..8cb090bb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/433_pure_statement_in_for_loop.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + for (uint x = 0; x < 10; true) + x++; + } +} +// ---- +// Warning: (77-81): Statement has no effect. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/434_pure_statement_check_for_regular_for_loop.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/434_pure_statement_check_for_regular_for_loop.sol new file mode 100644 index 00000000..319e4202 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/434_pure_statement_check_for_regular_for_loop.sol @@ -0,0 +1,6 @@ +contract C { + function f() pure public { + for (uint x = 0; true; x++) + {} + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/435_warn_unused_local.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/435_warn_unused_local.sol new file mode 100644 index 00000000..7d7f5728 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/435_warn_unused_local.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + uint a; + } +} +// ---- +// Warning: (52-58): Unused local variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/436_warn_unused_local_assigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/436_warn_unused_local_assigned.sol new file mode 100644 index 00000000..b3d28374 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/436_warn_unused_local_assigned.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + uint a = 1; + } +} +// ---- +// Warning: (52-58): Unused local variable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol new file mode 100644 index 00000000..8a36eaad --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint a) pure public { + } +} +// ---- +// Warning: (28-34): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/438_unused_unnamed_function_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/438_unused_unnamed_function_parameter.sol new file mode 100644 index 00000000..5d059b93 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/438_unused_unnamed_function_parameter.sol @@ -0,0 +1,4 @@ +contract C { + function f(uint) pure public { + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol new file mode 100644 index 00000000..b1422c4f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol @@ -0,0 +1,6 @@ +contract C { + function f() pure public returns (uint a) { + } +} +// ---- +// Warning: (51-57): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol new file mode 100644 index 00000000..af67f491 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public returns (uint a) { + return; + } +} +// ---- +// Warning: (51-57): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/441_unused_unnamed_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/441_unused_unnamed_return_parameter.sol new file mode 100644 index 00000000..8c47484b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/441_unused_unnamed_return_parameter.sol @@ -0,0 +1,4 @@ +contract C { + function f() pure public returns (uint) { + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/442_named_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/442_named_return_parameter.sol new file mode 100644 index 00000000..a2faf06a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/442_named_return_parameter.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public returns (uint a) { + a = 1; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/443_named_return_parameter_with_explicit_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/443_named_return_parameter_with_explicit_return.sol new file mode 100644 index 00000000..93851e7c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/443_named_return_parameter_with_explicit_return.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public returns (uint a) { + return 1; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/444_unnamed_return_parameter_with_explicit_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/444_unnamed_return_parameter_with_explicit_return.sol new file mode 100644 index 00000000..b552a745 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/444_unnamed_return_parameter_with_explicit_return.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public returns (uint) { + return 1; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/445_no_unused_warning_interface_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/445_no_unused_warning_interface_arguments.sol new file mode 100644 index 00000000..203217ce --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/445_no_unused_warning_interface_arguments.sol @@ -0,0 +1,3 @@ +interface I { + function f(uint a) pure external returns (uint b); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/446_no_unused_warning_abstract_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/446_no_unused_warning_abstract_arguments.sol new file mode 100644 index 00000000..fbb6e079 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/446_no_unused_warning_abstract_arguments.sol @@ -0,0 +1,3 @@ +contract C { + function f(uint a) pure public returns (uint b); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/447_no_unused_warnings.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/447_no_unused_warnings.sol new file mode 100644 index 00000000..f549308a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/447_no_unused_warnings.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint a) pure public returns (uint b) { + uint c = 1; + b = a + c; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/449_no_unused_inline_asm.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/449_no_unused_inline_asm.sol new file mode 100644 index 00000000..2b39b9fd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/449_no_unused_inline_asm.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + uint a; + assembly { + a := 1 + } + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/450_shadowing_builtins_with_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/450_shadowing_builtins_with_functions.sol new file mode 100644 index 00000000..33ccb356 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/450_shadowing_builtins_with_functions.sol @@ -0,0 +1,5 @@ +contract C { + function keccak256() pure public {} +} +// ---- +// Warning: (17-52): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/451_shadowing_builtins_with_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/451_shadowing_builtins_with_variables.sol new file mode 100644 index 00000000..1d6f098e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/451_shadowing_builtins_with_variables.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + uint msg; + msg; + } +} +// ---- +// Warning: (52-60): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/452_shadowing_builtins_with_storage_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/452_shadowing_builtins_with_storage_variables.sol new file mode 100644 index 00000000..d5635887 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/452_shadowing_builtins_with_storage_variables.sol @@ -0,0 +1,5 @@ +contract C { + uint msg; +} +// ---- +// Warning: (17-25): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/453_shadowing_builtin_at_global_scope.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/453_shadowing_builtin_at_global_scope.sol new file mode 100644 index 00000000..0946dc57 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/453_shadowing_builtin_at_global_scope.sol @@ -0,0 +1,4 @@ +contract msg { +} +// ---- +// Warning: (0-16): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/454_shadowing_builtins_with_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/454_shadowing_builtins_with_parameters.sol new file mode 100644 index 00000000..454929d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/454_shadowing_builtins_with_parameters.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint require) pure public { + require = 2; + } +} +// ---- +// Warning: (28-40): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/455_shadowing_builtins_with_return_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/455_shadowing_builtins_with_return_parameters.sol new file mode 100644 index 00000000..7931053f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/455_shadowing_builtins_with_return_parameters.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public returns (uint require) { + require = 2; + } +} +// ---- +// Warning: (51-63): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/456_shadowing_builtins_with_events.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/456_shadowing_builtins_with_events.sol new file mode 100644 index 00000000..e5b635df --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/456_shadowing_builtins_with_events.sol @@ -0,0 +1,5 @@ +contract C { + event keccak256(); +} +// ---- +// Warning: (17-35): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/457_shadowing_builtins_ignores_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/457_shadowing_builtins_ignores_struct.sol new file mode 100644 index 00000000..4c70b4ce --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/457_shadowing_builtins_ignores_struct.sol @@ -0,0 +1,5 @@ +contract C { + struct a { + uint msg; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/458_shadowing_builtins_ignores_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/458_shadowing_builtins_ignores_constructor.sol new file mode 100644 index 00000000..86c0b4f0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/458_shadowing_builtins_ignores_constructor.sol @@ -0,0 +1,3 @@ +contract C { + constructor() public {} +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/459_function_overload_is_not_shadowing.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/459_function_overload_is_not_shadowing.sol new file mode 100644 index 00000000..1b44b5c6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/459_function_overload_is_not_shadowing.sol @@ -0,0 +1,4 @@ +contract C { + function f() pure public {} + function f(uint) pure public {} +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/460_function_override_is_not_shadowing.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/460_function_override_is_not_shadowing.sol new file mode 100644 index 00000000..c765ff00 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/460_function_override_is_not_shadowing.sol @@ -0,0 +1,4 @@ +contract D { function f() pure public {} } +contract C is D { + function f(uint) pure public {} +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/461_event_parameter_cannot_shadow_state_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/461_event_parameter_cannot_shadow_state_variable.sol new file mode 100644 index 00000000..6e1f654d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/461_event_parameter_cannot_shadow_state_variable.sol @@ -0,0 +1,4 @@ +contract C { + address a; + event E(address a); +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol new file mode 100644 index 00000000..188d00e0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol @@ -0,0 +1,9 @@ +contract C { + struct S { uint a; bool x; } + S public s; + constructor() public { + 3({a: 1, x: true}); + } +} +// ---- +// TypeError: (97-115): Type is not callable diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol new file mode 100644 index 00000000..2b2ef39e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol @@ -0,0 +1,17 @@ +// This used to be a test for a.transfer to generate a warning +// because A's fallback function is not payable. + +contract A { + function() external {} +} + +contract B { + A a; + + function() external { + a.transfer(100); + } +} +// ---- +// Warning: (213-223): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// TypeError: (213-223): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol new file mode 100644 index 00000000..67398de7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol @@ -0,0 +1,15 @@ +// This used to be a test for a.transfer to generate a warning +// because A does not have a payable fallback function. + +contract A {} + +contract B { + A a; + + function() external { + a.transfer(100); + } +} +// ---- +// Warning: (192-202): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// TypeError: (192-202): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol new file mode 100644 index 00000000..1a4b2e81 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol @@ -0,0 +1,17 @@ +// This used to be a test for a.send to generate a warning +// because A does not have a payable fallback function. + +contract A { + function() external {} +} + +contract B { + A a; + + function() external { + require(a.send(100)); + } +} +// ---- +// Warning: (224-230): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead. +// TypeError: (224-230): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol new file mode 100644 index 00000000..2b7f8dae --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol @@ -0,0 +1,16 @@ +// This used to be a test for a.transfer to generate a warning +// because A does not have a payable fallback function. + +contract A { + function() payable external {} +} + +contract B { + A a; + + function() external { + a.transfer(100); + } +} +// ---- +// Warning: (228-238): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol new file mode 100644 index 00000000..65b4a236 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol @@ -0,0 +1,11 @@ +contract A { + function transfer() pure public {} +} + +contract B { + A a; + + function() external { + a.transfer(); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/470_specified_storage_no_warn.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/470_specified_storage_no_warn.sol new file mode 100644 index 00000000..490a0032 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/470_specified_storage_no_warn.sol @@ -0,0 +1,8 @@ +contract C { + struct S { uint a; string b; } + S x; + function f() view public { + S storage y = x; + y; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_warn.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_warn.sol new file mode 100644 index 00000000..aa16a6b4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_warn.sol @@ -0,0 +1,10 @@ +contract C { + struct S { uint a; } + S x; + function f() view public { + S y = x; + y; + } +} +// ---- +// Warning: (86-89): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/472_unspecified_storage_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/472_unspecified_storage_v050.sol new file mode 100644 index 00000000..179c9931 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/472_unspecified_storage_v050.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract C { + struct S { uint a; } + S x; + function f() view public { + S y = x; + y; + } +} +// ---- +// TypeError: (116-119): Data location must be specified as either "memory" or "storage". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/473_storage_location_non_array_or_struct_disallowed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/473_storage_location_non_array_or_struct_disallowed.sol new file mode 100644 index 00000000..6c9f50af --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/473_storage_location_non_array_or_struct_disallowed.sol @@ -0,0 +1,5 @@ +contract C { + function f(uint storage a) public { } +} +// ---- +// TypeError: (28-42): Data location can only be given for array or struct types. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/474_storage_location_non_array_or_struct_disallowed_is_not_fatal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/474_storage_location_non_array_or_struct_disallowed_is_not_fatal.sol new file mode 100644 index 00000000..a2f47407 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/474_storage_location_non_array_or_struct_disallowed_is_not_fatal.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint storage a) public { + a = f; + } +} +// ---- +// TypeError: (28-42): Data location can only be given for array or struct types. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/475_implicit_conversion_disallowed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/475_implicit_conversion_disallowed.sol new file mode 100644 index 00000000..232e701d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/475_implicit_conversion_disallowed.sol @@ -0,0 +1,8 @@ +contract C { + function f() public returns (bytes4) { + uint32 tmp = 1; + return tmp; + } +} +// ---- +// TypeError: (95-98): Return argument type uint32 is not implicitly convertible to expected type (type of first return variable) bytes4. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/476_too_large_arrays_for_calldata_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/476_too_large_arrays_for_calldata_external.sol new file mode 100644 index 00000000..de8b7501 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/476_too_large_arrays_for_calldata_external.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint[85678901234] a) pure external { + } +} +// ---- +// TypeError: (28-47): Array is too large to be encoded. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/477_too_large_arrays_for_calldata_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/477_too_large_arrays_for_calldata_internal.sol new file mode 100644 index 00000000..ab57f489 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/477_too_large_arrays_for_calldata_internal.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint[85678901234] a) pure internal { + } +} +// ---- +// TypeError: (28-47): Array is too large to be encoded. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/478_too_large_arrays_for_calldata_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/478_too_large_arrays_for_calldata_public.sol new file mode 100644 index 00000000..1493f3ca --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/478_too_large_arrays_for_calldata_public.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint[85678901234] a) pure public { + } +} +// ---- +// TypeError: (28-47): Array is too large to be encoded. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/479_explicit_literal_to_memory_string_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/479_explicit_literal_to_memory_string_assignment.sol new file mode 100644 index 00000000..508a9439 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/479_explicit_literal_to_memory_string_assignment.sol @@ -0,0 +1,6 @@ +contract C { + function f() pure public { + string memory x = "abc"; + x; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/480_explicit_literal_to_storage_string_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/480_explicit_literal_to_storage_string_assignment.sol new file mode 100644 index 00000000..ee56204a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/480_explicit_literal_to_storage_string_assignment.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + string storage x = "abc"; + } +} +// ---- +// TypeError: (52-76): Type literal_string "abc" is not implicitly convertible to expected type string storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/481_explicit_literal_to_unspecified_string_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/481_explicit_literal_to_unspecified_string_assignment.sol new file mode 100644 index 00000000..9801b831 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/481_explicit_literal_to_unspecified_string_assignment.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + string x = "abc"; + } +} +// ---- +// Warning: (52-60): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. +// TypeError: (52-68): Type literal_string "abc" is not implicitly convertible to expected type string storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol new file mode 100644 index 00000000..a83eee72 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + string("abc"); + } +} +// ---- +// TypeError: (52-65): Explicit type conversion not allowed from "literal_string "abc"" to "string storage pointer". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/483_modifiers_access_storage_pointer.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/483_modifiers_access_storage_pointer.sol new file mode 100644 index 00000000..be1920e9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/483_modifiers_access_storage_pointer.sol @@ -0,0 +1,7 @@ +contract C { + struct S { uint a; } + modifier m(S storage x) { + x; + _; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol new file mode 100644 index 00000000..9ed2b70f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view returns (bytes4) { + return f.selector; + } +} +// ---- +// TypeError: (76-86): Member "selector" not found or not visible after argument-dependent lookup in function () view returns (bytes4) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol new file mode 100644 index 00000000..0876a4f7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol @@ -0,0 +1,9 @@ +contract C { + function g() pure internal { + } + function f() public view returns (bytes4) { + return g.selector; + } +} +// ---- +// TypeError: (115-125): Member "selector" not found or not visible after argument-dependent lookup in function () pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol new file mode 100644 index 00000000..d0ccc724 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol @@ -0,0 +1,8 @@ +contract C { + function f() public view returns (bytes4) { + function () g; + return g.selector; + } +} +// ---- +// TypeError: (99-109): Member "selector" not found or not visible after argument-dependent lookup in function () diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/487_function_types_selector_4.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/487_function_types_selector_4.sol new file mode 100644 index 00000000..4c3c72e8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/487_function_types_selector_4.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure external returns (bytes4) { + return this.f.selector; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol new file mode 100644 index 00000000..5f601db2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol @@ -0,0 +1,8 @@ +contract C { + function h() pure external { + } + function f() pure external returns (bytes4) { + return this.h.selector; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/489_function_types_selector_6.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/489_function_types_selector_6.sol new file mode 100644 index 00000000..0114e282 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/489_function_types_selector_6.sol @@ -0,0 +1,8 @@ +contract C { + function h() pure external { + } + function f() view external returns (bytes4) { + function () pure external g = this.h; + return g.selector; + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol new file mode 100644 index 00000000..9ee7d9bb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol @@ -0,0 +1,9 @@ +contract C { + function h() pure external { + } + function f() view external returns (bytes4) { + function () pure external g = this.h; + return g.selector; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol new file mode 100644 index 00000000..7921a1fa --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol @@ -0,0 +1,9 @@ +contract C { + constructor() public { + this.f(); + } + function f() pure public { + } +} +// ---- +// Warning: (48-52): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol new file mode 100644 index 00000000..90275804 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol @@ -0,0 +1,11 @@ +// This checks for a bug that caused a crash because of continued analysis. +contract C { + mapping (uint => uint) m; + function f() public { + m(1) = 2; + } +} +// ---- +// TypeError: (153-157): Type is not callable +// TypeError: (153-157): Expression has to be an lvalue. +// TypeError: (160-161): Type int_const 2 is not implicitly convertible to expected type tuple(). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol new file mode 100644 index 00000000..b99431f9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + keccak256.gas(); + } +} +// ---- +// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol new file mode 100644 index 00000000..23c90acb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + sha256.gas(); + } +} +// ---- +// TypeError: (47-57): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol new file mode 100644 index 00000000..5884e212 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + ripemd160.gas(); + } +} +// ---- +// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes20) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol new file mode 100644 index 00000000..0a874f5d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + ecrecover.gas(); + } +} +// ---- +// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes32,uint8,bytes32,bytes32) pure returns (address) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/497_gasleft.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/497_gasleft.sol new file mode 100644 index 00000000..20f33887 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/497_gasleft.sol @@ -0,0 +1,3 @@ +contract C { + function f() public view returns (uint256 val) { return gasleft(); } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol new file mode 100644 index 00000000..5efecd22 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol @@ -0,0 +1,5 @@ +contract C { + function f() public view returns (uint256 val) { return msg.gas; } +} +// ---- +// TypeError: (73-80): "msg.gas" has been deprecated in favor of "gasleft()" diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/500_gasleft_shadowing_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/500_gasleft_shadowing_1.sol new file mode 100644 index 00000000..66b88c49 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/500_gasleft_shadowing_1.sol @@ -0,0 +1,6 @@ +contract C { + function gasleft() public pure returns (bytes32 val) { return "abc"; } + function f() public pure returns (bytes32 val) { return gasleft(); } +} +// ---- +// Warning: (17-87): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/501_gasleft_shadowing_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/501_gasleft_shadowing_2.sol new file mode 100644 index 00000000..2679c89d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/501_gasleft_shadowing_2.sol @@ -0,0 +1,6 @@ +contract C { + uint gasleft; + function f() public { gasleft = 42; } +} +// ---- +// Warning: (17-29): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol new file mode 100644 index 00000000..61e51eff --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + keccak256.value(); + } +} +// ---- +// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol new file mode 100644 index 00000000..11141a9b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + sha256.value(); + } +} +// ---- +// TypeError: (47-59): Member "value" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol new file mode 100644 index 00000000..d120f3dd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + ripemd160.value(); + } +} +// ---- +// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes20) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/505_builtin_ecrecover_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/505_builtin_ecrecover_reject_value.sol new file mode 100644 index 00000000..e0215901 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/505_builtin_ecrecover_reject_value.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + ecrecover.value(); + } +} +// ---- +// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function (bytes32,uint8,bytes32,bytes32) pure returns (address) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/506_large_storage_array_fine.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/506_large_storage_array_fine.sol new file mode 100644 index 00000000..13e6dd80 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/506_large_storage_array_fine.sol @@ -0,0 +1,3 @@ +contract C { + uint[2**64 - 1] x; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/507_large_storage_array_simple.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/507_large_storage_array_simple.sol new file mode 100644 index 00000000..3f8ee996 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/507_large_storage_array_simple.sol @@ -0,0 +1,5 @@ +contract C { + uint[2**64] x; +} +// ---- +// Warning: (17-30): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/508_large_storage_arrays_combined.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/508_large_storage_arrays_combined.sol new file mode 100644 index 00000000..917dcec1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/508_large_storage_arrays_combined.sol @@ -0,0 +1,5 @@ +contract C { + uint[200][200][2**30][][2**30] x; +} +// ---- +// Warning: (17-49): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/509_large_storage_arrays_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/509_large_storage_arrays_struct.sol new file mode 100644 index 00000000..656201f4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/509_large_storage_arrays_struct.sol @@ -0,0 +1,6 @@ +contract C { + struct S { uint[2**30] x; uint[2**50] y; } + S[2**20] x; +} +// ---- +// Warning: (64-74): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/510_large_storage_array_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/510_large_storage_array_mapping.sol new file mode 100644 index 00000000..046a27f7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/510_large_storage_array_mapping.sol @@ -0,0 +1,5 @@ +contract C { + mapping(uint => uint[2**100]) x; +} +// ---- +// Warning: (17-48): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/511_library_function_without_implementation_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/511_library_function_without_implementation_public.sol new file mode 100644 index 00000000..fe5e4955 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/511_library_function_without_implementation_public.sol @@ -0,0 +1,4 @@ +library L { + // This can be used as an "interface", hence it is allowed. + function f() public; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/512_library_function_without_implementation_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/512_library_function_without_implementation_internal.sol new file mode 100644 index 00000000..d5dfb260 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/512_library_function_without_implementation_internal.sol @@ -0,0 +1,5 @@ +library L { + function f() internal; +} +// ---- +// TypeError: (16-38): Internal library function must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/513_library_function_without_implementation_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/513_library_function_without_implementation_private.sol new file mode 100644 index 00000000..70585e8c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/513_library_function_without_implementation_private.sol @@ -0,0 +1,5 @@ +library L { + function f() private; +} +// ---- +// TypeError: (16-37): Internal library function must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/514_using_for_with_non_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/514_using_for_with_non_library.sol new file mode 100644 index 00000000..ab139dd5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/514_using_for_with_non_library.sol @@ -0,0 +1,10 @@ +// This tests a crash that was resolved by making the first error fatal. +library L { + struct S { uint d; } + using S for S; + function f(S _s) internal { + _s.d = 1; + } +} +// ---- +// TypeError: (120-121): Library name expected. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/515_experimental_pragma_empty.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/515_experimental_pragma_empty.sol new file mode 100644 index 00000000..66afb7a2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/515_experimental_pragma_empty.sol @@ -0,0 +1,3 @@ +pragma experimental; +// ---- +// SyntaxError: (0-20): Experimental feature name is missing. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/516_experimental_pragma_unknown_number_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/516_experimental_pragma_unknown_number_literal.sol new file mode 100644 index 00000000..445c6f54 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/516_experimental_pragma_unknown_number_literal.sol @@ -0,0 +1,3 @@ +pragma experimental 123; +// ---- +// SyntaxError: (0-24): Unsupported experimental feature name. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/517_experimental_pragma_unknown_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/517_experimental_pragma_unknown_string_literal.sol new file mode 100644 index 00000000..48d8b968 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/517_experimental_pragma_unknown_string_literal.sol @@ -0,0 +1,3 @@ +pragma experimental unsupportedName; +// ---- +// SyntaxError: (0-36): Unsupported experimental feature name. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/518_experimental_pragma_unknown_quoted_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/518_experimental_pragma_unknown_quoted_string_literal.sol new file mode 100644 index 00000000..6405f062 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/518_experimental_pragma_unknown_quoted_string_literal.sol @@ -0,0 +1,3 @@ +pragma experimental "unsupportedName"; +// ---- +// SyntaxError: (0-38): Unsupported experimental feature name. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/519_experimental_pragma_empy_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/519_experimental_pragma_empy_string_literal.sol new file mode 100644 index 00000000..1a1fde9c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/519_experimental_pragma_empy_string_literal.sol @@ -0,0 +1,3 @@ +pragma experimental ""; +// ---- +// SyntaxError: (0-23): Empty experimental feature name is invalid. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/520_experimental_pragma_multiple_same_line.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/520_experimental_pragma_multiple_same_line.sol new file mode 100644 index 00000000..2eb2bf2a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/520_experimental_pragma_multiple_same_line.sol @@ -0,0 +1,3 @@ +pragma experimental unsupportedName unsupportedName; +// ---- +// SyntaxError: (0-52): Stray arguments. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/521_experimental_pragma_test_warning.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/521_experimental_pragma_test_warning.sol new file mode 100644 index 00000000..5f6962f4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/521_experimental_pragma_test_warning.sol @@ -0,0 +1,3 @@ +pragma experimental __test; +// ---- +// Warning: (0-27): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/522_experimental_pragma_duplicate.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/522_experimental_pragma_duplicate.sol new file mode 100644 index 00000000..ba772a21 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/522_experimental_pragma_duplicate.sol @@ -0,0 +1,5 @@ +pragma experimental __test; +pragma experimental __test; +// ---- +// Warning: (0-27): Experimental features are turned on. Do not use experimental features on live deployments. +// SyntaxError: (28-55): Duplicate experimental feature name. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/523_reject_interface_creation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/523_reject_interface_creation.sol new file mode 100644 index 00000000..35bba5b3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/523_reject_interface_creation.sol @@ -0,0 +1,8 @@ +interface I {} +contract C { + function f() public { + new I(); + } +} +// ---- +// TypeError: (62-67): Cannot instantiate an interface. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/524_accept_library_creation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/524_accept_library_creation.sol new file mode 100644 index 00000000..6a5e97af --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/524_accept_library_creation.sol @@ -0,0 +1,6 @@ +library L {} +contract C { + function f() public { + new L(); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol new file mode 100644 index 00000000..d65c639f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol @@ -0,0 +1,4 @@ +interface I {} +contract C is I(2) {} +// ---- +// TypeError: (29-33): Wrong argument count for constructor call: 1 arguments given but expected 0. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol new file mode 100644 index 00000000..6ac551e1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol @@ -0,0 +1,3 @@ +contract C { + function () external { } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol new file mode 100644 index 00000000..f13a87ec --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol @@ -0,0 +1,4 @@ +pragma experimental "v0.5.0"; +contract C { + function () external { } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol new file mode 100644 index 00000000..2d425037 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol @@ -0,0 +1,4 @@ +contract C { + function () internal { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol new file mode 100644 index 00000000..6c8b23c8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; +contract C { + function () internal { } +} +// ---- +// TypeError: (47-71): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol new file mode 100644 index 00000000..2105c815 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol @@ -0,0 +1,4 @@ +contract C { + function () private { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol new file mode 100644 index 00000000..be381909 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; +contract C { + function () private { } +} +// ---- +// TypeError: (47-70): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol new file mode 100644 index 00000000..42585137 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol @@ -0,0 +1,4 @@ +contract C { + function () public { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol new file mode 100644 index 00000000..d0beffda --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; +contract C { + function () public { } +} +// ---- +// TypeError: (47-69): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/530_tuple_invalid_literal_too_large_for_uint.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/530_tuple_invalid_literal_too_large_for_uint.sol new file mode 100644 index 00000000..bbfe2206 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/530_tuple_invalid_literal_too_large_for_uint.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + uint x; + (x, ) = (1E111); + } +} +// ---- +// TypeError: (76-83): Type int_const 1000...(104 digits omitted)...0000 is not implicitly convertible to expected type tuple(uint256,). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/531_tuple_invalid_literal_too_large_unassigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/531_tuple_invalid_literal_too_large_unassigned.sol new file mode 100644 index 00000000..6b9cbf79 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/531_tuple_invalid_literal_too_large_unassigned.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + uint x; + (x, ) = (1, 1E111); + } +} +// ---- +// TypeError: (80-85): Invalid rational number. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/532_tuple_invalid_literal_too_large_for_uint_multi.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/532_tuple_invalid_literal_too_large_for_uint_multi.sol new file mode 100644 index 00000000..a26f9c04 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/532_tuple_invalid_literal_too_large_for_uint_multi.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + uint x; + (x, ) = (1E111, 1); + } +} +// ---- +// TypeError: (77-82): Invalid rational number. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/533_tuple_invalid_literal_too_large_exp.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/533_tuple_invalid_literal_too_large_exp.sol new file mode 100644 index 00000000..9384ec53 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/533_tuple_invalid_literal_too_large_exp.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + (2**270, 1); + } +} +// ---- +// TypeError: (53-59): Invalid rational number. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/534_tuple_invalid_literal_too_large_expression.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/534_tuple_invalid_literal_too_large_expression.sol new file mode 100644 index 00000000..3c322444 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/534_tuple_invalid_literal_too_large_expression.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + ((2**270) / 2**100, 1); + } +} +// ---- +// Warning: (52-74): Statement has no effect. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol new file mode 100644 index 00000000..157ea36b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol @@ -0,0 +1,18 @@ +contract C { + function balance() public returns (uint) { + this.balance; // to avoid pureness warning + return 1; + } + function transfer(uint amount) public { + address(this).transfer(amount); // to avoid pureness warning + } +} +contract D { + function f() public { + uint x = (new C()).balance(); + x; + (new C()).transfer(5); + } +} +// ---- +// Warning: (17-134): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/536_array_length_invalid_expression_negative_bool.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/536_array_length_invalid_expression_negative_bool.sol new file mode 100644 index 00000000..c92861eb --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/536_array_length_invalid_expression_negative_bool.sol @@ -0,0 +1,5 @@ +contract C { + uint[-true] ids; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/537_array_length_invalid_expression_int_divides_bool.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/537_array_length_invalid_expression_int_divides_bool.sol new file mode 100644 index 00000000..92e3c3cf --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/537_array_length_invalid_expression_int_divides_bool.sol @@ -0,0 +1,5 @@ +contract C { + uint[true/1] ids; +} +// ---- +// TypeError: (22-28): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/538_array_length_invalid_expression_bool_divides_int.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/538_array_length_invalid_expression_bool_divides_int.sol new file mode 100644 index 00000000..26add45c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/538_array_length_invalid_expression_bool_divides_int.sol @@ -0,0 +1,5 @@ +contract C { + uint[1/true] ids; +} +// ---- +// TypeError: (22-28): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/539_array_length_invalid_expression_scientific_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/539_array_length_invalid_expression_scientific_literal.sol new file mode 100644 index 00000000..a0d58f4a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/539_array_length_invalid_expression_scientific_literal.sol @@ -0,0 +1,5 @@ +contract C { + uint[1.111111E1111111111111] ids; +} +// ---- +// TypeError: (22-44): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/540_array_length_invalid_expression_division_by_zero.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/540_array_length_invalid_expression_division_by_zero.sol new file mode 100644 index 00000000..38a80867 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/540_array_length_invalid_expression_division_by_zero.sol @@ -0,0 +1,5 @@ +contract C { + uint[3/0] ids; +} +// ---- +// TypeError: (22-25): Operator / not compatible with types int_const 3 and int_const 0 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/541_warn_about_address_members_on_contract_balance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/541_warn_about_address_members_on_contract_balance.sol new file mode 100644 index 00000000..4acb0dc2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/541_warn_about_address_members_on_contract_balance.sol @@ -0,0 +1,7 @@ +contract C { + function f() view public { + this.balance; + } +} +// ---- +// Warning: (52-64): Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).balance" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/542_warn_about_address_members_on_contract_transfer.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/542_warn_about_address_members_on_contract_transfer.sol new file mode 100644 index 00000000..45ee1f5b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/542_warn_about_address_members_on_contract_transfer.sol @@ -0,0 +1,8 @@ +contract C { + function f() view public { + this.transfer; + } +} +// ---- +// Warning: (52-65): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// TypeError: (52-65): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/543_warn_about_address_members_on_contract_send.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/543_warn_about_address_members_on_contract_send.sol new file mode 100644 index 00000000..99b7b8b2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/543_warn_about_address_members_on_contract_send.sol @@ -0,0 +1,8 @@ +contract C { + function f() view public { + this.send; + } +} +// ---- +// Warning: (52-61): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead. +// TypeError: (52-61): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/544_warn_about_address_members_on_contract_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/544_warn_about_address_members_on_contract_call.sol new file mode 100644 index 00000000..446410ba --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/544_warn_about_address_members_on_contract_call.sol @@ -0,0 +1,7 @@ +contract C { + function f() view public { + this.call; + } +} +// ---- +// Warning: (52-61): Using contract member "call" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).call" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/545_warn_about_address_members_on_contract_callcode.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/545_warn_about_address_members_on_contract_callcode.sol new file mode 100644 index 00000000..43ee4d88 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/545_warn_about_address_members_on_contract_callcode.sol @@ -0,0 +1,8 @@ +contract C { + function f() view public { + this.callcode; + } +} +// ---- +// Warning: (52-65): Using contract member "callcode" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).callcode" instead. +// TypeError: (52-65): "callcode" has been deprecated in favour of "delegatecall". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/546_warn_about_address_members_on_contract_delegatecall.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/546_warn_about_address_members_on_contract_delegatecall.sol new file mode 100644 index 00000000..7cbd832a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/546_warn_about_address_members_on_contract_delegatecall.sol @@ -0,0 +1,7 @@ +contract C { + function f() view public { + this.delegatecall; + } +} +// ---- +// Warning: (52-69): Using contract member "delegatecall" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).delegatecall" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/547_warn_about_address_members_on_non_this_contract_balance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/547_warn_about_address_members_on_non_this_contract_balance.sol new file mode 100644 index 00000000..3ba59a9f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/547_warn_about_address_members_on_non_this_contract_balance.sol @@ -0,0 +1,8 @@ +contract C { + function f() view public { + C c; + c.balance; + } +} +// ---- +// Warning: (65-74): Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).balance" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/548_warn_about_address_members_on_non_this_contract_transfer.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/548_warn_about_address_members_on_non_this_contract_transfer.sol new file mode 100644 index 00000000..17455124 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/548_warn_about_address_members_on_non_this_contract_transfer.sol @@ -0,0 +1,9 @@ +contract C { + function f() view public { + C c; + c.transfer; + } +} +// ---- +// Warning: (65-75): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// TypeError: (65-75): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/549_warn_about_address_members_on_non_this_contract_send.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/549_warn_about_address_members_on_non_this_contract_send.sol new file mode 100644 index 00000000..ca0630c4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/549_warn_about_address_members_on_non_this_contract_send.sol @@ -0,0 +1,9 @@ +contract C { + function f() view public { + C c; + c.send; + } +} +// ---- +// Warning: (65-71): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead. +// TypeError: (65-71): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/550_warn_about_address_members_on_non_this_contract_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/550_warn_about_address_members_on_non_this_contract_call.sol new file mode 100644 index 00000000..c06e0f61 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/550_warn_about_address_members_on_non_this_contract_call.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + C c; + c.call; + } +} +// ---- +// Warning: (65-71): Using contract member "call" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).call" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/551_warn_about_address_members_on_non_this_contract_callcode.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/551_warn_about_address_members_on_non_this_contract_callcode.sol new file mode 100644 index 00000000..3c1e0280 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/551_warn_about_address_members_on_non_this_contract_callcode.sol @@ -0,0 +1,9 @@ +contract C { + function f() pure public { + C c; + c.callcode; + } +} +// ---- +// Warning: (65-75): Using contract member "callcode" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).callcode" instead. +// TypeError: (65-75): "callcode" has been deprecated in favour of "delegatecall". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/552_warn_about_address_members_on_non_this_contract_delegatecall.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/552_warn_about_address_members_on_non_this_contract_delegatecall.sol new file mode 100644 index 00000000..8e286945 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/552_warn_about_address_members_on_non_this_contract_delegatecall.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + C c; + c.delegatecall; + } +} +// ---- +// Warning: (65-79): Using contract member "delegatecall" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).delegatecall" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol new file mode 100644 index 00000000..7c4ad16a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract C { + function f() public { + this.balance; + } +} +// ---- +// TypeError: (77-89): Member "balance" not found or not visible after argument-dependent lookup in contract C diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol new file mode 100644 index 00000000..74bdabd2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract C { + function f() public { + this.transfer; + } +} +// ---- +// TypeError: (77-90): Member "transfer" not found or not visible after argument-dependent lookup in contract C diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol new file mode 100644 index 00000000..0852e47e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract C { + function f() public { + this.send; + } +} +// ---- +// TypeError: (77-86): Member "send" not found or not visible after argument-dependent lookup in contract C diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol new file mode 100644 index 00000000..b9a226ad --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract C { + function f() public { + this.call; + } +} +// ---- +// TypeError: (77-86): Member "call" not found or not visible after argument-dependent lookup in contract C diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol new file mode 100644 index 00000000..95198a94 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract C { + function f() public { + this.callcode; + } +} +// ---- +// TypeError: (77-90): Member "callcode" not found or not visible after argument-dependent lookup in contract C diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol new file mode 100644 index 00000000..b7a7053e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract C { + function f() public { + this.delegatecall; + } +} +// ---- +// TypeError: (77-94): Member "delegatecall" not found or not visible after argument-dependent lookup in contract C diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/559_no_warning_for_using_members_that_look_like_address_members.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/559_no_warning_for_using_members_that_look_like_address_members.sol new file mode 100644 index 00000000..9355853a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/559_no_warning_for_using_members_that_look_like_address_members.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; +contract C { + function transfer(uint) public; + function f() public { + this.transfer(10); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/560_event_emit_simple.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/560_event_emit_simple.sol new file mode 100644 index 00000000..445c9949 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/560_event_emit_simple.sol @@ -0,0 +1,6 @@ +contract C { + event e(); + function f() public { + emit e(); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/561_event_emit_complex.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/561_event_emit_complex.sol new file mode 100644 index 00000000..19448615 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/561_event_emit_complex.sol @@ -0,0 +1,7 @@ +contract C { + event e(uint a, string b); + function f() public { + emit e(2, "abc"); + emit e({b: "abc", a: 8}); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/562_event_emit_foreign_class.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/562_event_emit_foreign_class.sol new file mode 100644 index 00000000..afac609a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/562_event_emit_foreign_class.sol @@ -0,0 +1,7 @@ +contract A { event e(uint a, string b); } +contract C is A { + function f() public { + emit A.e(2, "abc"); + emit A.e({b: "abc", a: 8}); + } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol new file mode 100644 index 00000000..e9a56671 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol @@ -0,0 +1,8 @@ +contract C { + event e(); + function f() public { + e(); + } +} +// ---- +// TypeError: (62-65): Event invocations have to be prefixed by "emit". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol new file mode 100644 index 00000000..e148d65a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol @@ -0,0 +1,9 @@ +pragma experimental "v0.5.0"; +contract C { + event e(); + function f() public { + e(); + } +} +// ---- +// TypeError: (92-95): Event invocations have to be prefixed by "emit". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/567_require_visibility_specifiers_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/567_require_visibility_specifiers_v050.sol new file mode 100644 index 00000000..ec7c0937 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/567_require_visibility_specifiers_v050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; +contract C { + function f() pure { } +} +// ---- +// SyntaxError: (47-68): No visibility specified. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/568_blockhash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/568_blockhash.sol new file mode 100644 index 00000000..f6cc63a5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/568_blockhash.sol @@ -0,0 +1,3 @@ +contract C { + function f() public view returns (bytes32) { return blockhash(3); } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol new file mode 100644 index 00000000..b8f5d6a8 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view returns (bytes32) { + return block.blockhash(3); + } +} +// ---- +// TypeError: (77-92): "block.blockhash()" has been deprecated in favor of "blockhash()" diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol index 626e865e..2b35ffda 100644 --- a/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol +++ b/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol @@ -1,8 +1,8 @@ contract c { - function f() { c[10] a = 7; uint8[10 * 2] x; } + function f() public { c[10] a = 7; uint8[10 * 2] x; } } // ---- -// Warning: (32-39): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. -// Warning: (45-60): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. -// TypeError: (32-43): Type int_const 7 is not implicitly convertible to expected type contract c[10] storage pointer. -// Warning: (45-60): Uninitialized storage pointer. Did you mean '<type> memory x'? +// Warning: (39-46): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. +// Warning: (52-67): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. +// TypeError: (39-50): Type int_const 7 is not implicitly convertible to expected type contract c[10] storage pointer. +// DeclarationError: (52-67): Uninitialized storage pointer. Did you mean '<type> memory x'? diff --git a/test/libsolidity/syntaxTests/parsing/calling_function.sol b/test/libsolidity/syntaxTests/parsing/calling_function.sol index 4c4fc1fc..9e88c451 100644 --- a/test/libsolidity/syntaxTests/parsing/calling_function.sol +++ b/test/libsolidity/syntaxTests/parsing/calling_function.sol @@ -1,9 +1,7 @@ contract test { - function f() { + function f() public { function() returns(function() returns(function() returns(function() returns(uint)))) x; uint y; y = x()()()(); } } -// ---- -// Warning: (20-175): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol index c7d11ed6..0e348f5b 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol @@ -1,9 +1,8 @@ contract A { - function f() { + function f() public { uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6; } } // ---- -// Warning: (17-93): No visibility specified. Defaulting to "public". -// Warning: (40-46): Unused local variable. -// Warning: (17-93): Function state mutability can be restricted to pure +// Warning: (47-53): Unused local variable. +// Warning: (17-100): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol index 90974e96..40aaa917 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol @@ -1,11 +1,10 @@ contract A { - function f() { + function f() public { uint x = true ? 1 : 0; uint y = false ? 0 : 1; } } // ---- -// Warning: (17-100): No visibility specified. Defaulting to "public". -// Warning: (40-46): Unused local variable. -// Warning: (71-77): Unused local variable. -// Warning: (17-100): Function state mutability can be restricted to pure +// Warning: (47-53): Unused local variable. +// Warning: (78-84): Unused local variable. +// Warning: (17-107): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol index 6f8040d6..7489aaf9 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol @@ -1,11 +1,8 @@ contract A { - function f() { + function f() public pure { uint y = 1; - uint x = 3 < 0 ? x = 3 : 6; + uint x = 3 < 0 ? y = 3 : 6; true ? x = 3 : 4; } } // ---- -// Warning: (17-119): No visibility specified. Defaulting to "public". -// Warning: (40-46): Unused local variable. -// Warning: (17-119): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol index 35da69c6..705fbadf 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol @@ -1,11 +1,10 @@ contract A { - function f() { + function f() public { uint x = 3 > 0 ? 3 : 0; uint y = (3 > 0) ? 3 : 0; } } // ---- -// Warning: (17-103): No visibility specified. Defaulting to "public". -// Warning: (40-46): Unused local variable. -// Warning: (72-78): Unused local variable. -// Warning: (17-103): Function state mutability can be restricted to pure +// Warning: (47-53): Unused local variable. +// Warning: (79-85): Unused local variable. +// Warning: (17-110): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol index eb4c7091..bbabf957 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol @@ -1,5 +1,5 @@ contract A { - function f() { + function f() public { uint x = 3; uint y = 1; uint z = (x > y) ? x : y; @@ -7,7 +7,6 @@ contract A { } } // ---- -// Warning: (17-143): No visibility specified. Defaulting to "public". -// Warning: (80-86): Unused local variable. -// Warning: (114-120): Unused local variable. -// Warning: (17-143): Function state mutability can be restricted to pure +// Warning: (87-93): Unused local variable. +// Warning: (121-127): Unused local variable. +// Warning: (17-150): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol b/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol index da068351..8fddc988 100644 --- a/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol +++ b/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol @@ -1,7 +1,8 @@ contract C { uint s; - // this test should fail starting from 0.5.0 function f() public constant returns (uint) { return s; } } +// ---- +// ParserError: (43-51): The state mutability modifier "constant" was removed in version 0.5.0. Use "view" or "pure" instead. diff --git a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol index 8be9667a..6d88669a 100644 --- a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol +++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol @@ -1,14 +1,13 @@ contract A { fixed40x40 storeMe; - function f(ufixed x, fixed32x32 y) { + function f(ufixed x, fixed32x32 y) public { ufixed8x8 a; fixed b; } } // ---- -// Warning: (41-121): No visibility specified. Defaulting to "public". // Warning: (52-60): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (62-74): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (86-97): Unused local variable. -// Warning: (107-114): Unused local variable. -// Warning: (41-121): Function state mutability can be restricted to pure +// Warning: (93-104): Unused local variable. +// Warning: (114-121): Unused local variable. +// Warning: (41-128): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol index 727e6115..c2a1aaeb 100644 --- a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol +++ b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol @@ -1,8 +1,7 @@ contract test { - function fun(uint256 a) returns (address b) { + function fun(uint256 a) public returns (uint8 b) { if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78; } } // ---- -// Warning: (20-142): No visibility specified. Defaulting to "public". -// Warning: (20-142): Function state mutability can be restricted to pure +// Warning: (20-147): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/empty_function.sol b/test/libsolidity/syntaxTests/parsing/empty_function.sol index 218fd9a7..320a0bcc 100644 --- a/test/libsolidity/syntaxTests/parsing/empty_function.sol +++ b/test/libsolidity/syntaxTests/parsing/empty_function.sol @@ -1,10 +1,9 @@ contract test { uint256 stateVar; - function functionName(bytes20 arg1, address addr) view returns (int id) { } + function functionName(bytes20 arg1, address addr) public view returns (int id) { } } // ---- -// Warning: (36-111): No visibility specified. Defaulting to "public". // Warning: (58-70): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (72-84): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (100-106): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (36-111): Function state mutability can be restricted to pure +// Warning: (107-113): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (36-118): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol index 4c4a1217..606f59d7 100644 --- a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol +++ b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol @@ -1,10 +1,7 @@ contract c { enum validEnum { Value1, Value2, Value3, Value4 } - function c() { + constructor() public { a = validEnum.Value3; } validEnum a; } -// ---- -// Warning: (71-121): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (71-121): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/exp_expression.sol b/test/libsolidity/syntaxTests/parsing/exp_expression.sol index cdabb996..6b307ea0 100644 --- a/test/libsolidity/syntaxTests/parsing/exp_expression.sol +++ b/test/libsolidity/syntaxTests/parsing/exp_expression.sol @@ -1,9 +1,8 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { uint256 x = 3 ** a; } } // ---- -// Warning: (20-79): No visibility specified. Defaulting to "public". -// Warning: (54-63): Unused local variable. -// Warning: (20-79): Function state mutability can be restricted to pure +// Warning: (61-70): Unused local variable. +// Warning: (20-86): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/fallback_function.sol b/test/libsolidity/syntaxTests/parsing/fallback_function.sol index de32b030..054f57de 100644 --- a/test/libsolidity/syntaxTests/parsing/fallback_function.sol +++ b/test/libsolidity/syntaxTests/parsing/fallback_function.sol @@ -1,5 +1,4 @@ contract c { - function() { } + function() external { } } // ---- -// Warning: (17-31): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol index bd86f2f5..fce669dd 100644 --- a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol +++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol @@ -1,5 +1,5 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { uint256 i =0; for (i = 0; i < 10; i++) { uint256 x = i; break; continue; @@ -7,7 +7,6 @@ contract test { } } // ---- -// Warning: (20-162): No visibility specified. Defaulting to "public". // Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (115-124): Unused local variable. -// Warning: (20-162): Function state mutability can be restricted to pure +// Warning: (122-131): Unused local variable. +// Warning: (20-169): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol index 4a27e0fb..4adf0948 100644 --- a/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol +++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol @@ -1,5 +1,5 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { uint256 i =0; for (;;) { uint256 x = i; break; continue; @@ -7,7 +7,6 @@ contract test { } } // ---- -// Warning: (24-170): No visibility specified. Defaulting to "public". // Warning: (37-46): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (115-124): Unused local variable. -// Warning: (24-170): Function state mutability can be restricted to pure +// Warning: (122-131): Unused local variable. +// Warning: (24-177): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol index 3df88ef5..c6af519c 100644 --- a/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol +++ b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol @@ -1,11 +1,10 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { uint256 i = 0; for (i = 0; i < 10; i++) continue; } } // ---- -// Warning: (20-129): No visibility specified. Defaulting to "public". // Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (20-129): Function state mutability can be restricted to pure +// Warning: (20-136): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol index a7c5e8bb..c22ae42f 100644 --- a/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol +++ b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol @@ -1,12 +1,11 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { for (uint256 i = 0; i < 10; i++) { uint256 x = i; break; continue; } } } // ---- -// Warning: (20-148): No visibility specified. Defaulting to "public". // Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (101-110): Unused local variable. -// Warning: (20-148): Function state mutability can be restricted to pure +// Warning: (108-117): Unused local variable. +// Warning: (20-155): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_no_body.sol b/test/libsolidity/syntaxTests/parsing/function_no_body.sol index 0424ebd8..c4a686dc 100644 --- a/test/libsolidity/syntaxTests/parsing/function_no_body.sol +++ b/test/libsolidity/syntaxTests/parsing/function_no_body.sol @@ -1,5 +1,3 @@ contract test { - function functionName(bytes32 input) returns (bytes32 out); + function functionName(bytes32 input) public returns (bytes32 out); } -// ---- -// Warning: (17-76): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol index c7a023ac..94e1e60a 100644 --- a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol +++ b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol @@ -1,10 +1,9 @@ contract test { uint256 stateVar; // We won't see this comment - function functionName(bytes32 input) returns (bytes32 out) {} + function functionName(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (75-136): No visibility specified. Defaulting to "public". // Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (75-136): Function state mutability can be restricted to pure +// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (75-143): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol index 3b784733..11e77f25 100644 --- a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol +++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol @@ -1,10 +1,9 @@ contract test { - function f(uint x, uint y) returns (uint a) {} + function f(uint x, uint y) public returns (uint a) {} function (uint, uint) internal returns (uint) f1 = f; } // ---- -// Warning: (20-66): No visibility specified. Defaulting to "public". // Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (20-66): Function state mutability can be restricted to pure +// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (20-73): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol index fd6447c7..3defb5ea 100644 --- a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol +++ b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol @@ -1,15 +1,13 @@ contract test { - function f(uint x, uint y) returns (uint a) {} - function g() { + function f(uint x, uint y) public returns (uint a) {} + function g() public { function (uint, uint) internal returns (uint) f1 = f; } } // ---- -// Warning: (20-66): No visibility specified. Defaulting to "public". // Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (71-153): No visibility specified. Defaulting to "public". -// Warning: (94-142): Unused local variable. -// Warning: (20-66): Function state mutability can be restricted to pure -// Warning: (71-153): Function state mutability can be restricted to pure +// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (108-156): Unused local variable. +// Warning: (20-73): Function state mutability can be restricted to pure +// Warning: (78-167): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol index d3c84678..c7703b47 100644 --- a/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol +++ b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol @@ -1,6 +1,6 @@ contract test { struct S { - function (uint x, uint y) internal returns (uint a) f; + function (uint x, uint y) internal returns (uint) f; function (uint, uint) external returns (uint) g; uint d; } @@ -8,4 +8,3 @@ contract test { // ---- // Warning: (49-55): Naming function type parameters is deprecated. // Warning: (57-63): Naming function type parameters is deprecated. -// Warning: (83-89): Naming function type return parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/parsing/if_statement.sol b/test/libsolidity/syntaxTests/parsing/if_statement.sol index 0819cb9f..b3269785 100644 --- a/test/libsolidity/syntaxTests/parsing/if_statement.sol +++ b/test/libsolidity/syntaxTests/parsing/if_statement.sol @@ -1,11 +1,8 @@ contract test { - function fun(uint256 a) returns (uint) { - if (a >= 8) { return 2; } else { var b = 7; } + function fun(uint256 a) public returns (uint) { + if (a >= 8) { return 2; } else { uint b = 7; } } } // ---- -// Warning: (102-107): Use of the "var" keyword is deprecated. -// Warning: (102-111): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (20-120): No visibility specified. Defaulting to "public". -// Warning: (102-107): Unused local variable. -// Warning: (20-120): Function state mutability can be restricted to pure +// Warning: (109-115): Unused local variable. +// Warning: (20-128): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol index f42f8f16..4730f950 100644 --- a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol +++ b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol @@ -1,9 +1,8 @@ contract c { uint[] a; - function f() returns (uint, uint) { + function f() public returns (uint, uint) { a = [1,2,3]; return (a[3], [2,3,4][0]); } } // ---- -// Warning: (31-128): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/interface_basic.sol b/test/libsolidity/syntaxTests/parsing/interface_basic.sol index c25b48ba..2363eaa8 100644 --- a/test/libsolidity/syntaxTests/parsing/interface_basic.sol +++ b/test/libsolidity/syntaxTests/parsing/interface_basic.sol @@ -1,6 +1,5 @@ interface Interface { - function f(); + function f() public; } // ---- -// Warning: (23-36): Functions in interfaces should be declared external. -// Warning: (23-36): No visibility specified. Defaulting to "public". In interfaces it defaults to external. +// Warning: (23-43): Functions in interfaces should be declared external. diff --git a/test/libsolidity/syntaxTests/parsing/library_simple.sol b/test/libsolidity/syntaxTests/parsing/library_simple.sol index fcf2638e..006ff307 100644 --- a/test/libsolidity/syntaxTests/parsing/library_simple.sol +++ b/test/libsolidity/syntaxTests/parsing/library_simple.sol @@ -1,6 +1,5 @@ library Lib { - function f() { } + function f() public { } } // ---- -// Warning: (18-34): No visibility specified. Defaulting to "public". -// Warning: (18-34): Function state mutability can be restricted to pure +// Warning: (18-41): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol index 452b52c7..64116b88 100644 --- a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol +++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol @@ -1,5 +1,5 @@ contract c { - function f() + function f() public { a = 1 wei; b = 2 szabo; @@ -12,5 +12,4 @@ contract c { uint256 d; } // ---- -// Warning: (163-172): This declaration shadows an existing declaration. -// Warning: (17-128): No visibility specified. Defaulting to "public". +// Warning: (170-179): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol index d2cdc875..2f2302ed 100644 --- a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol +++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol @@ -1,10 +1,7 @@ contract c { - function c () + constructor() public { a = 1 wei * 100 wei + 7 szabo - 3; } uint256 a; } -// ---- -// Warning: (17-86): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (17-86): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol index 5d6c8dc5..38de7b1c 100644 --- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol @@ -1,12 +1,9 @@ contract Foo { - function f() { - uint[] storage x; + uint[] m_x; + function f() public view { + uint[] storage x = m_x; uint[] memory y; + x; y; } } // ---- -// Warning: (42-58): Uninitialized storage pointer. -// Warning: (19-90): No visibility specified. Defaulting to "public". -// Warning: (42-58): Unused local variable. -// Warning: (68-83): Unused local variable. -// Warning: (19-90): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/modifier.sol b/test/libsolidity/syntaxTests/parsing/modifier.sol index 3e659dcf..b995ce89 100644 --- a/test/libsolidity/syntaxTests/parsing/modifier.sol +++ b/test/libsolidity/syntaxTests/parsing/modifier.sol @@ -1,3 +1,3 @@ contract c { - modifier mod { if (msg.sender == 0) _; } + modifier mod { if (msg.sender == 0x0000000000000000000000000000000000000000) _; } } diff --git a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol index cb2f2985..cf986efe 100644 --- a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol +++ b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol @@ -1,8 +1,7 @@ contract c { modifier mod1(uint a) { if (msg.sender == address(a)) _; } modifier mod2 { if (msg.sender == address(2)) _; } - function f() mod1(7) mod2 { } + function f() public mod1(7) mod2 { } } // ---- -// Warning: (135-164): No visibility specified. Defaulting to "public". -// Warning: (135-164): Function state mutability can be restricted to view +// Warning: (135-171): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol index 818999df..1984ed36 100644 --- a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol +++ b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol @@ -1,29 +1,15 @@ contract C { - function f() { - var (a,b,c) = g(); - var (d) = 2; - var (,e) = 3; - var (f,) = 4; - var (x,,) = g(); - var (,y,) = g(); - var () = g(); - var (,,) = g(); + function f() pure public { + (uint a, uint b, uint c) = g(); + (uint d) = 2; + (, uint e) = 3; + (uint h,) = 4; + (uint x,,) = g(); + (, uint y,) = g(); + a; b; c; d; e; h; x; y; } - function g() returns (uint, uint, uint) {} + function g() pure public returns (uint, uint, uint) {} } // ---- -// Warning: (36-37): Use of the "var" keyword is deprecated. -// Warning: (38-39): Use of the "var" keyword is deprecated. -// Warning: (40-41): Use of the "var" keyword is deprecated. -// Warning: (57-58): Use of the "var" keyword is deprecated. -// Warning: (73-74): Use of the "var" keyword is deprecated. -// Warning: (88-89): Use of the "var" keyword is deprecated. -// Warning: (104-105): Use of the "var" keyword is deprecated. -// Warning: (124-125): Use of the "var" keyword is deprecated. -// Warning: (88-89): This declaration shadows an existing declaration. -// Warning: (52-63): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (67-79): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (67-79): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (83-95): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (83-95): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// TypeError: (137-149): Too many components (3) in value for variable assignment (0) needed +// Warning: (93-107): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (111-124): Different number of components on the left hand side (2) than on the right hand side (1). diff --git a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol index 95a4d1e7..85d9e6a8 100644 --- a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol +++ b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol @@ -1,28 +1,24 @@ contract test { uint256 stateVar; /// This is test function 1 - function functionName1(bytes32 input) returns (bytes32 out) {} + function functionName1(bytes32 input) public returns (bytes32 out) {} /// This is test function 2 - function functionName2(bytes32 input) returns (bytes32 out) {} + function functionName2(bytes32 input) public returns (bytes32 out) {} // nothing to see here - function functionName3(bytes32 input) returns (bytes32 out) {} + function functionName3(bytes32 input) public returns (bytes32 out) {} /// This is test function 4 - function functionName4(bytes32 input) returns (bytes32 out) {} + function functionName4(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (74-136): No visibility specified. Defaulting to "public". // Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (173-235): No visibility specified. Defaulting to "public". -// Warning: (196-209): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (220-231): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (267-329): No visibility specified. Defaulting to "public". -// Warning: (290-303): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (314-325): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (366-428): No visibility specified. Defaulting to "public". -// Warning: (389-402): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (413-424): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (74-136): Function state mutability can be restricted to pure -// Warning: (173-235): Function state mutability can be restricted to pure -// Warning: (267-329): Function state mutability can be restricted to pure -// Warning: (366-428): Function state mutability can be restricted to pure +// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (203-216): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (234-245): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (304-317): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (335-346): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (410-423): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (441-452): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (74-143): Function state mutability can be restricted to pure +// Warning: (180-249): Function state mutability can be restricted to pure +// Warning: (281-350): Function state mutability can be restricted to pure +// Warning: (387-456): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/no_function_params.sol b/test/libsolidity/syntaxTests/parsing/no_function_params.sol index 020f1233..5a024bdb 100644 --- a/test/libsolidity/syntaxTests/parsing/no_function_params.sol +++ b/test/libsolidity/syntaxTests/parsing/no_function_params.sol @@ -1,7 +1,6 @@ contract test { uint256 stateVar; - function functionName() {} + function functionName() public {} } // ---- -// Warning: (36-62): No visibility specified. Defaulting to "public". -// Warning: (36-62): Function state mutability can be restricted to pure +// Warning: (36-69): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol b/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol index 1a78d155..fe050d1b 100644 --- a/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol +++ b/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol @@ -1,9 +1,7 @@ contract test { - function fun(uint a) returns(uint r) { return a; } - function fun(uint a, uint b) returns(uint r) { return a + b; } + function fun(uint a) public returns(uint r) { return a; } + function fun(uint a, uint b) public returns(uint r) { return a + b; } } // ---- -// Warning: (17-67): No visibility specified. Defaulting to "public". -// Warning: (69-131): No visibility specified. Defaulting to "public". -// Warning: (17-67): Function state mutability can be restricted to pure -// Warning: (69-131): Function state mutability can be restricted to pure +// Warning: (17-74): Function state mutability can be restricted to pure +// Warning: (76-145): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol index 72546dc0..a50855c0 100644 --- a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol +++ b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol @@ -1,11 +1,8 @@ contract c { - function fun() returns (uint r) { - var _ = 8; + function fun() public returns (uint r) { + uint _ = 8; return _ + 1; } } // ---- -// Warning: (59-64): Use of the "var" keyword is deprecated. -// Warning: (59-68): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (17-97): No visibility specified. Defaulting to "public". -// Warning: (17-97): Function state mutability can be restricted to pure +// Warning: (17-105): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/single_function_param.sol b/test/libsolidity/syntaxTests/parsing/single_function_param.sol index 08e531f1..955f20f0 100644 --- a/test/libsolidity/syntaxTests/parsing/single_function_param.sol +++ b/test/libsolidity/syntaxTests/parsing/single_function_param.sol @@ -1,9 +1,8 @@ contract test { uint256 stateVar; - function functionName(bytes32 input) returns (bytes32 out) {} + function functionName(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (36-97): No visibility specified. Defaulting to "public". // Warning: (58-71): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (82-93): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (36-97): Function state mutability can be restricted to pure +// Warning: (89-100): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (36-104): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/tuples.sol b/test/libsolidity/syntaxTests/parsing/tuples.sol index 6f739740..8266c94f 100644 --- a/test/libsolidity/syntaxTests/parsing/tuples.sol +++ b/test/libsolidity/syntaxTests/parsing/tuples.sol @@ -1,24 +1,16 @@ contract C { - function f() { + function f() public { uint a = (1); - var (b,) = (1,); - var (c,d) = (1, 2 + a); - var (e,) = (1, 2, b); + (uint b,) = (1,); + (uint c, uint d) = (1, 2 + a); + (uint e,) = (1, 2, b); (a) = 3; } } // ---- -// Warning: (52-53): Use of the "var" keyword is deprecated. -// Warning: (71-72): Use of the "var" keyword is deprecated. -// Warning: (73-74): Use of the "var" keyword is deprecated. -// Warning: (97-98): Use of the "var" keyword is deprecated. -// Warning: (47-62): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (47-62): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (66-88): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (92-112): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (92-112): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (14-127): No visibility specified. Defaulting to "public". -// Warning: (71-72): Unused local variable. -// Warning: (73-74): Unused local variable. -// Warning: (97-98): Unused local variable. -// Warning: (14-127): Function state mutability can be restricted to pure +// Warning: (54-70): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (107-128): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (75-81): Unused local variable. +// Warning: (83-89): Unused local variable. +// Warning: (108-114): Unused local variable. +// Warning: (14-143): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol b/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol index 0b3dda56..957740d0 100644 --- a/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol +++ b/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol @@ -2,8 +2,8 @@ // we can't determine whether they match exactly, however // it will throw DeclarationError in following stage. contract test { - function fun(uint a) returns(uint r) { return a; } - function fun(uint a) returns(uint r) { return a; } + function fun(uint a) public returns(uint r) { return a; } + function fun(uint a) public returns(uint r) { return a; } } // ---- -// DeclarationError: (189-239): Function with same name and arguments defined twice. +// DeclarationError: (189-246): Function with same name and arguments defined twice. diff --git a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol index 4706a26d..db890b37 100644 --- a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol +++ b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol @@ -3,15 +3,12 @@ contract c { uint internal b; uint public c; uint d; - function f() {} + function f() public {} function f_priv() private {} - function f_public() public {} function f_internal() internal {} } // ---- // Warning: (58-71): This declaration shadows an existing declaration. -// Warning: (89-104): No visibility specified. Defaulting to "public". -// Warning: (89-104): Function state mutability can be restricted to pure -// Warning: (109-137): Function state mutability can be restricted to pure -// Warning: (142-171): Function state mutability can be restricted to pure -// Warning: (176-209): Function state mutability can be restricted to pure +// Warning: (89-111): Function state mutability can be restricted to pure +// Warning: (116-144): Function state mutability can be restricted to pure +// Warning: (149-182): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/while_loop.sol b/test/libsolidity/syntaxTests/parsing/while_loop.sol index 129b52e1..dbb00a69 100644 --- a/test/libsolidity/syntaxTests/parsing/while_loop.sol +++ b/test/libsolidity/syntaxTests/parsing/while_loop.sol @@ -1,9 +1,7 @@ contract test { - function fun(uint256 a) { - while (true) { uint256 x = 1; break; continue; } x = 9; + function fun() public pure { + uint256 x; + while (true) { x = 1; break; continue; } x = 9; } } // ---- -// Warning: (20-115): No visibility specified. Defaulting to "public". -// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (20-115): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol index d90ec2d7..36bae6a8 100644 --- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol @@ -5,4 +5,5 @@ contract test { } } // ---- -// DeclarationError: (77-83): Identifier already declared. +// Warning: (57-63): Unused local variable. +// Warning: (77-83): Unused local variable. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol deleted file mode 100644 index 06bfe7be..00000000 --- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma experimental "v0.5.0"; -contract test { - function f() pure public { - { uint x; } - { uint x; } - } -} -// ---- -// Warning: (87-93): Unused local variable. -// Warning: (107-113): Unused local variable. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol index 1a5ff2f9..0c03ec3e 100644 --- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol @@ -5,4 +5,5 @@ contract test { } } // ---- -// DeclarationError: (75-81): Identifier already declared. +// Warning: (57-63): Unused local variable. +// Warning: (75-81): Unused local variable. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol deleted file mode 100644 index 20ea0349..00000000 --- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma experimental "v0.5.0"; -contract test { - function f() pure public { - { uint x; } - uint x; - } -} -// ---- -// Warning: (87-93): Unused local variable. -// Warning: (105-111): Unused local variable. diff --git a/test/libsolidity/syntaxTests/scoping/scoping.sol b/test/libsolidity/syntaxTests/scoping/scoping.sol index 34b055d9..dae5a42d 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { function f() public { { @@ -8,4 +7,4 @@ contract test { } } // ---- -// DeclarationError: (123-124): Undeclared identifier. +// DeclarationError: (93-94): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol index 7334bc49..8522a0e3 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { function f() pure public { x = 3; @@ -6,4 +5,4 @@ contract test { } } // ---- -// DeclarationError: (85-86): Undeclared identifier. Did you mean "x"? +// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol b/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol index d893a889..8522a0e3 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol @@ -4,3 +4,5 @@ contract test { uint x; } } +// ---- +// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for.sol b/test/libsolidity/syntaxTests/scoping/scoping_for.sol index 6e5b7095..a882d1ca 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_for.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_for.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { function f() pure public { for (uint x = 0; x < 10; x ++){ diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for2.sol b/test/libsolidity/syntaxTests/scoping/scoping_for2.sol index eb74b8ab..f8c5c19b 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_for2.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_for2.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { function f() pure public { for (uint x = 0; x < 10; x ++) diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol index 1814cb47..81e34562 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { function f() pure public { for (uint x = 0; x < 10; x ++){ @@ -8,4 +7,4 @@ contract test { } } // ---- -// DeclarationError: (154-155): Undeclared identifier. +// DeclarationError: (124-125): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol index 3e80b385..28b88525 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { function f() pure public { for (;; y++){ @@ -7,4 +6,4 @@ contract test { } } // ---- -// DeclarationError: (93-94): Undeclared identifier. +// DeclarationError: (63-64): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_old.sol b/test/libsolidity/syntaxTests/scoping/scoping_old.sol index 83f6b60b..70e5ee0c 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_old.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_old.sol @@ -4,3 +4,5 @@ contract test { uint256 x = 2; } } +// ---- +// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol b/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol index 9e2c0171..a5087c57 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol @@ -3,3 +3,5 @@ contract test { uint a = a; } } +// ---- +// DeclarationError: (64-65): Undeclared identifier. "a" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol b/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol deleted file mode 100644 index ab3dcefb..00000000 --- a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol +++ /dev/null @@ -1,8 +0,0 @@ -pragma experimental "v0.5.0"; -contract test { - function f() pure public { - uint a = a; - } -} -// ---- -// DeclarationError: (94-95): Undeclared identifier. Did you mean "a"? diff --git a/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol b/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol index a6ee4bf1..c17d0849 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol @@ -7,9 +7,6 @@ contract C { function g(bytes32) pure internal {} } // ---- -// Warning: (54-72): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (54-72): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. -// Warning: (85-100): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (85-100): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. -// Warning: (113-131): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (113-131): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. +// TypeError: (64-71): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (92-99): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (123-130): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol index b94a4391..a30e428a 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol @@ -1,6 +1,6 @@ contract C { function f() public pure { - bytes32 h = keccak256(abi.encodePacked(keccak256, f, this.f.gas, block.blockhash)); + bytes32 h = keccak256(abi.encodePacked(keccak256, f, this.f.gas, blockhash)); h; } } @@ -8,4 +8,4 @@ contract C { // TypeError: (91-100): This type cannot be encoded. // TypeError: (102-103): This type cannot be encoded. // TypeError: (105-115): This type cannot be encoded. -// TypeError: (117-132): This type cannot be encoded. +// TypeError: (117-126): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol index f1b5606e..c97f588e 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol @@ -1,13 +1,13 @@ contract C { function f() public pure { - bool a = address(this).call(address(this).delegatecall, super); - bool b = address(this).delegatecall(log0, tx, mulmod); + bool a = address(this).call(abi.encode(address(this).delegatecall, super)); + bool b = address(this).delegatecall(abi.encode(log0, tx, mulmod)); a; b; } } // ---- -// TypeError: (80-106): This type cannot be encoded. -// TypeError: (108-113): This type cannot be encoded. -// TypeError: (160-164): This type cannot be encoded. -// TypeError: (166-168): This type cannot be encoded. -// TypeError: (170-176): This type cannot be encoded. +// TypeError: (91-117): This type cannot be encoded. +// TypeError: (119-124): This type cannot be encoded. +// TypeError: (183-187): This type cannot be encoded. +// TypeError: (189-191): This type cannot be encoded. +// TypeError: (193-199): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol index 05f5db0b..a1d3f5af 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol @@ -4,11 +4,10 @@ contract C { struct T { uint y; } T t; function f() public view { - bytes32 a = sha256(s, t); + bytes32 a = sha256(abi.encodePacked(s, t)); a; } } // ---- -// Warning: (132-144): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (139-140): This type cannot be encoded. -// TypeError: (142-143): This type cannot be encoded. +// TypeError: (156-157): This type cannot be encoded. +// TypeError: (159-160): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol index 977a7d73..38702825 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol @@ -6,12 +6,11 @@ contract C { struct T { uint y; } T t; function f() public view { - bytes32 a = sha256(s, t); + bytes32 a = sha256(abi.encodePacked(s, t)); a; } } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// Warning: (167-179): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (174-175): This type cannot be encoded. -// TypeError: (177-178): This type cannot be encoded. +// TypeError: (191-192): This type cannot be encoded. +// TypeError: (194-195): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol index d10c1718..b50d4449 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol @@ -1,17 +1,17 @@ contract C { struct S { uint x; } S s; - struct T { } + struct T { uint y; } T t; enum A { X, Y } function f() public pure { - bool a = address(this).delegatecall(S, A, A.X, T, uint, uint[]); + bytes memory a = abi.encodePacked(S, A, A.X, T, uint, uint[]); + a; } } // ---- -// Warning: (51-63): Defining empty structs is deprecated. -// TypeError: (168-169): This type cannot be encoded. -// TypeError: (171-172): This type cannot be encoded. -// TypeError: (179-180): This type cannot be encoded. -// TypeError: (182-186): This type cannot be encoded. -// TypeError: (188-194): This type cannot be encoded. +// TypeError: (174-175): This type cannot be encoded. +// TypeError: (177-178): This type cannot be encoded. +// TypeError: (185-186): This type cannot be encoded. +// TypeError: (188-192): This type cannot be encoded. +// TypeError: (194-200): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol index a190adc3..be8482ff 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals.sol @@ -1,33 +1,8 @@ contract C { - function f() pure public returns (bytes32) { - return keccak256(1); - } - function g() pure public returns (bytes32) { - return sha3(1); - } - function h() pure public returns (bytes32) { - return sha256(1); - } - function j() pure public returns (bytes32) { - return ripemd160(1); - } function k() pure public returns (bytes) { return abi.encodePacked(1); } } // ---- -// Warning: (87-88): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (77-89): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (77-89): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// Warning: (161-168): "sha3" has been deprecated in favour of "keccak256" -// Warning: (166-167): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (161-168): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (161-168): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// Warning: (247-248): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (240-249): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (240-249): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// Warning: (331-332): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (321-333): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (321-333): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// Warning: (420-421): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. +// Warning: (92-93): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol index b7557d2a..4e6210c6 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol @@ -1,34 +1,9 @@ pragma experimental "v0.5.0"; contract C { - function f() pure public returns (bytes32) { - return keccak256(1); - } - function g() pure public returns (bytes32) { - return sha3(1); - } - function h() pure public returns (bytes32) { - return sha256(1); - } - function j() pure public returns (bytes32) { - return ripemd160(1); - } function k() pure public returns (bytes) { return abi.encodePacked(1); } } // ---- -// TypeError: (117-118): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// TypeError: (107-119): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (107-119): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// TypeError: (191-198): "sha3" has been deprecated in favour of "keccak256" -// TypeError: (196-197): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// TypeError: (191-198): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (191-198): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// TypeError: (277-278): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// TypeError: (270-279): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (270-279): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// TypeError: (361-362): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// TypeError: (351-363): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (351-363): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// TypeError: (450-451): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. +// TypeError: (122-123): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol index 2b9b688a..7bbc36d0 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol @@ -1,16 +1,4 @@ contract C { - function f() pure public returns (bytes32) { - return keccak256(uint8(1)); - } - function g() pure public returns (bytes32) { - return sha3(uint8(1)); - } - function h() pure public returns (bytes32) { - return sha256(uint8(1)); - } - function j() pure public returns (bytes32) { - return ripemd160(uint8(1)); - } function k() pure public returns (bytes) { return abi.encodePacked(uint8(1)); } @@ -19,12 +7,3 @@ contract C { } } // ---- -// Warning: (77-96): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (77-96): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory. -// Warning: (168-182): "sha3" has been deprecated in favour of "keccak256" -// Warning: (168-182): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (168-182): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory. -// Warning: (254-270): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (254-270): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory. -// Warning: (342-361): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (342-361): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory. diff --git a/test/libsolidity/syntaxTests/tupleAssignments/err_fill_assignment.sol b/test/libsolidity/syntaxTests/tupleAssignments/err_fill_assignment.sol new file mode 100644 index 00000000..32b381bb --- /dev/null +++ b/test/libsolidity/syntaxTests/tupleAssignments/err_fill_assignment.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure returns (uint, uint, bytes32) { + uint a; + bytes32 b; + (a,) = f(); + (,b) = f(); + } +} +// ---- +// TypeError: (103-106): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(uint256,). +// TypeError: (117-120): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(,bytes32). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol b/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol index b2979804..902d8b98 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol @@ -6,5 +6,5 @@ contract C { } } // ---- +// TypeError: (89-101): Type tuple(int_const 1,int_const 2,struct C.S storage ref,struct C.S storage ref) is not implicitly convertible to expected type tuple(,struct C.S storage ref,struct C.S storage ref). // Warning: (79-101): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first. -// Warning: (79-101): Different number of components on the left hand side (3) than on the right hand side (4). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol b/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol index aa35d7d4..51556aab 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol @@ -6,5 +6,5 @@ contract C { } } // ---- +// TypeError: (90-102): Type tuple(struct C.S storage ref,struct C.S storage ref,int_const 1,int_const 2) is not implicitly convertible to expected type tuple(struct C.S storage ref,struct C.S storage ref,). // Warning: (79-102): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first. -// Warning: (79-102): Different number of components on the left hand side (3) than on the right hand side (4). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol index 5b7f870b..ae722391 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol @@ -8,5 +8,5 @@ contract C { } } // ---- -// TypeError: (126-136): Different number of components on the left hand side (2) than on the right hand side (3). -// TypeError: (140-150): Different number of components on the left hand side (2) than on the right hand side (3). +// TypeError: (133-136): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(uint256,). +// TypeError: (147-150): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(,bytes32). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/nowarn_explicit_singleton_token_expression.sol b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_explicit_singleton_token_expression.sol deleted file mode 100644 index 3262781b..00000000 --- a/test/libsolidity/syntaxTests/tupleAssignments/nowarn_explicit_singleton_token_expression.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract C { - function f() public pure { - uint a; - (a,) = (uint(1),); - } -} -// ---- -// Warning: (53-70): Different number of components on the left hand side (2) than on the right hand side (1). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_assignment.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_assignment.sol deleted file mode 100644 index a079a509..00000000 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_assignment.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract C { - function f() public pure returns (uint, uint, bytes32) { - uint a; - bytes32 b; - (a,) = f(); - (,b) = f(); - } -} -// ---- -// Warning: (96-106): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (110-120): Different number of components on the left hand side (2) than on the right hand side (3). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol index 1d243c7c..23484567 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol @@ -1,11 +1,8 @@ contract C { function f() public pure returns (uint, uint, uint, uint) { - // Can later be replaced by (uint a, uint b,) = f(); - var (a,b,) = f(); + (uint a, uint b,) = f(); a; b; } } // ---- -// Warning: (136-137): Use of the "var" keyword is deprecated. -// Warning: (138-139): Use of the "var" keyword is deprecated. -// Warning: (131-147): Different number of components on the left hand side (3) than on the right hand side (4). +// Warning: (76-99): Different number of components on the left hand side (3) than on the right hand side (4). diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol index 3e40b155..24327db0 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol @@ -2,9 +2,8 @@ pragma solidity ^0.4.3; contract C { event SomeEvent(); function a() public { - (SomeEvent(), 7); + (emit SomeEvent(), 7); } } // ---- -// Warning: (95-106): Invoking events without "emit" prefix is deprecated. -// Warning: (95-106): Tuple component cannot be empty. +// ParserError: (95-99): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol deleted file mode 100644 index aec5ff2a..00000000 --- a/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - event SomeEvent(); - function a() public { - (SomeEvent(), 7); - } -} -// ---- -// TypeError: (101-112): Event invocations have to be prefixed by "emit". -// TypeError: (101-112): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol new file mode 100644 index 00000000..0a11dc3a --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol @@ -0,0 +1,23 @@ +contract C { + struct S { uint x; } + S s; + function e() pure public { + assembly { mstore(keccak256(0, 20), mul(s_slot, 2)) } + } + function f() pure public { + uint x; + assembly { x := 7 } + } + function g() view public { + assembly { for {} 1 { pop(sload(0)) } { } pop(gas) } + } + function h() view public { + assembly { function g() { pop(blockhash(20)) } } + } + function j() public { + assembly { pop(call(0, 1, 2, 3, 4, 5, 6)) } + } + function k() public { + assembly { pop(call(gas, 1, 2, 3, 4, 5, 6)) } + } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol new file mode 100644 index 00000000..418be561 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol @@ -0,0 +1,7 @@ +contract C { + function k() public { + assembly { jump(2) } + } +} +// ---- +// Warning: (58-65): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol new file mode 100644 index 00000000..c1729db7 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol @@ -0,0 +1,8 @@ +contract C { + function k() public view { + assembly { jump(2) } + } +} +// ---- +// Warning: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. +// TypeError: (63-70): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol new file mode 100644 index 00000000..51e36a58 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol @@ -0,0 +1,18 @@ +contract C { + function f() public { + address(this).transfer(1); + require(address(this).send(2)); + selfdestruct(address(this)); + require(address(this).delegatecall("")); + require(address(this).call("")); + } + function g() pure public { + bytes32 x = keccak256("abc"); + bytes32 y = sha256("abc"); + address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4)); + require(true); + assert(true); + x; y; z; + } + function() payable external {} +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol new file mode 100644 index 00000000..0b834022 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol @@ -0,0 +1,21 @@ +contract C { + function f() view public { + bytes32 x = keccak256("abc"); + bytes32 y = sha256("abc"); + address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4)); + require(true); + assert(true); + x; y; z; + } + function g() public { + bytes32 x = keccak256("abc"); + bytes32 y = sha256("abc"); + address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4)); + require(true); + assert(true); + x; y; z; + } +} +// ---- +// Warning: (17-261): Function state mutability can be restricted to pure +// Warning: (266-505): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol new file mode 100644 index 00000000..9b00fd6d --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol @@ -0,0 +1,23 @@ +contract C { + function f() view public { + address(this).transfer(1); + } + function g() view public { + require(address(this).send(2)); + } + function h() view public { + selfdestruct(address(this)); + } + function i() view public { + require(address(this).delegatecall("")); + } + function j() view public { + require(address(this).call("")); + } +} +// ---- +// TypeError: (52-77): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError: (132-153): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError: (201-228): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError: (283-313): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError: (369-391): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol new file mode 100644 index 00000000..e21037bd --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol @@ -0,0 +1,10 @@ +contract C { + uint x; + function f() pure public { g(); } + function g() view public { x; } + function h() view public { i(); } + function i() public { x = 2; } +} +// ---- +// TypeError: (56-59): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". +// TypeError: (130-133): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_success.sol b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_success.sol new file mode 100644 index 00000000..5aa21ce1 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_success.sol @@ -0,0 +1,6 @@ +contract C { + function g() pure public { g(); } + function f() view public returns (uint) { f(); g(); } + function h() public { h(); g(); f(); } + function i() payable public { i(); h(); g(); f(); } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/constant.sol b/test/libsolidity/syntaxTests/viewPureChecker/constant.sol new file mode 100644 index 00000000..36d93497 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/constant.sol @@ -0,0 +1,6 @@ +contract C { + uint constant x = 2; + function k() pure public returns (uint) { + return x; + } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/constant_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/constant_restrict_warning.sol new file mode 100644 index 00000000..a4b4a353 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/constant_restrict_warning.sol @@ -0,0 +1,12 @@ +contract C { + uint constant x = 2; + function f() view public returns (uint) { + return x; + } + function g() public returns (uint) { + return x; + } +} +// ---- +// Warning: (42-107): Function state mutability can be restricted to pure +// Warning: (112-172): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/viewPureChecker/creation_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/creation_no_restrict_warning.sol new file mode 100644 index 00000000..d80edd1b --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/creation_no_restrict_warning.sol @@ -0,0 +1,4 @@ +contract D {} +contract C { + function f() public { new D(); } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/creation_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/creation_view_fail.sol new file mode 100644 index 00000000..08e45ea1 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/creation_view_fail.sol @@ -0,0 +1,6 @@ +contract D {} +contract C { + function f() public view { new D(); } +} +// ---- +// TypeError: (58-65): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/function_types.sol b/test/libsolidity/syntaxTests/viewPureChecker/function_types.sol new file mode 100644 index 00000000..92943889 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/function_types.sol @@ -0,0 +1,22 @@ +contract C { + function f() pure public { + function () external nonpayFun; + function () external view viewFun; + function () external pure pureFun; + + nonpayFun; + viewFun; + pureFun; + pureFun(); + } + function g() view public { + function () external view viewFun; + + viewFun(); + } + function h() public { + function () external nonpayFun; + + nonpayFun(); + } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/function_types_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/function_types_fail.sol new file mode 100644 index 00000000..d00f65c9 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/function_types_fail.sol @@ -0,0 +1,18 @@ +contract C { + function f() pure public { + function () external nonpayFun; + nonpayFun(); + } + function g() pure public { + function () external view viewFun; + viewFun(); + } + function h() view public { + function () external nonpayFun; + nonpayFun(); + } +} +// ---- +// TypeError: (92-103): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError: (193-202): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". +// TypeError: (289-300): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/interface.sol b/test/libsolidity/syntaxTests/viewPureChecker/interface.sol new file mode 100644 index 00000000..0874e78a --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/interface.sol @@ -0,0 +1,6 @@ +interface D { + function f() view external; +} +contract C is D { + function f() view external {} +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables.sol b/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables.sol new file mode 100644 index 00000000..7d01118a --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables.sol @@ -0,0 +1,19 @@ +contract C { + struct S { uint a; } + S s; + function f() view public { + S storage x = s; + x; + } + function g() view public { + S storage x = s; + x = s; + } + function i() public { + s.a = 2; + } + function h() public { + S storage x = s; + x.a = 2; + } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables_fail.sol new file mode 100644 index 00000000..0ff1ac24 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables_fail.sol @@ -0,0 +1,15 @@ +contract C { + struct S { uint a; } + S s; + function f() pure public { + S storage x = s; + x; + } + function g() view public { + S storage x = s; + x.a = 1; + } +} +// ---- +// TypeError: (100-101): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". +// TypeError: (184-187): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/mappings.sol b/test/libsolidity/syntaxTests/viewPureChecker/mappings.sol new file mode 100644 index 00000000..eb0ccbfb --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/mappings.sol @@ -0,0 +1,12 @@ +contract C { + mapping(uint => uint) a; + function f() view public { + a; + } + function g() view public { + a[2]; + } + function h() public { + a[2] = 3; + } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/modifiers.sol b/test/libsolidity/syntaxTests/viewPureChecker/modifiers.sol new file mode 100644 index 00000000..f8f6b2cb --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/modifiers.sol @@ -0,0 +1,17 @@ +contract D { + uint x; + modifier purem(uint) { _; } + modifier viewm(uint) { uint a = x; _; a; } + modifier nonpayablem(uint) { x = 2; _; } +} +contract C is D { + function f() purem(0) pure public {} + function g() viewm(0) view public {} + function h() nonpayablem(0) public {} + function i() purem(x) view public {} + function j() viewm(x) view public {} + function k() nonpayablem(x) public {} + function l() purem(x = 2) public {} + function m() viewm(x = 2) public {} + function n() nonpayablem(x = 2) public {} +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/modifiers_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/modifiers_fail.sol new file mode 100644 index 00000000..513850f7 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/modifiers_fail.sol @@ -0,0 +1,12 @@ +contract D { + uint x; + modifier viewm(uint) { uint a = x; _; a; } + modifier nonpayablem(uint) { x = 2; _; } +} +contract C is D { + function f() viewm(0) pure public {} + function g() nonpayablem(0) view public {} +} +// ---- +// TypeError: (154-162): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". +// TypeError: (195-209): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/overriding_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/overriding_fail.sol new file mode 100644 index 00000000..61702495 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/overriding_fail.sol @@ -0,0 +1,16 @@ +contract D { + uint x; + function f() public view { x; } + function g() public pure {} +} +contract C1 is D { + function f() public {} + function g() public view {} +} +contract C2 is D { + function g() public {} +} +// ---- +// TypeError: (118-140): Overriding function changes state mutability from "view" to "nonpayable". +// TypeError: (145-172): Overriding function changes state mutability from "pure" to "view". +// TypeError: (198-220): Overriding function changes state mutability from "pure" to "nonpayable". diff --git a/test/libsolidity/syntaxTests/viewPureChecker/overriding_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/overriding_no_restrict_warning.sol new file mode 100644 index 00000000..c82c7908 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/overriding_no_restrict_warning.sol @@ -0,0 +1,7 @@ +contract D { + uint x; + function f() public { x = 2; } +} +contract C is D { + function f() public {} +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/read_storage_pure_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/read_storage_pure_fail.sol new file mode 100644 index 00000000..785656b9 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/read_storage_pure_fail.sol @@ -0,0 +1,8 @@ +contract C { + uint x; + function f() public pure returns (uint) { + return x; + } +} +// ---- +// TypeError: (86-87): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". diff --git a/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_fail.sol new file mode 100644 index 00000000..e04d0825 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_fail.sol @@ -0,0 +1,13 @@ +contract C { + struct S { uint x; } + S s; + function f() pure internal returns (S storage) { + return s; + } + function g() pure public { + f().x; + } +} +// ---- +// TypeError: (115-116): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". +// TypeError: (163-168): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". diff --git a/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_no_restrict_warning.sol new file mode 100644 index 00000000..9b4eb466 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_no_restrict_warning.sol @@ -0,0 +1,14 @@ +contract C { + struct S { uint x; } + S s; + function f() view internal returns (S storage) { + return s; + } + function g() public { + f().x = 2; + } + function h() view public { + f(); + f().x; + } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/selector.sol b/test/libsolidity/syntaxTests/viewPureChecker/selector.sol new file mode 100644 index 00000000..c4e30075 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/selector.sol @@ -0,0 +1,12 @@ +contract C { + uint public x; + function f() payable public { + } + function g() pure public returns (bytes4) { + return this.f.selector ^ this.x.selector; + } + function h() view public returns (bytes4) { + x; + return this.f.selector ^ this.x.selector; + } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/selector_complex.sol b/test/libsolidity/syntaxTests/viewPureChecker/selector_complex.sol new file mode 100644 index 00000000..311dec4a --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/selector_complex.sol @@ -0,0 +1,11 @@ +contract C { + function f(C c) pure public returns (C) { + return c; + } + function g() pure public returns (bytes4) { + // By passing `this`, we read from the state, even if f itself is pure. + return f(this).f.selector; + } +} +// ---- +// TypeError: (228-232): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". diff --git a/test/libsolidity/syntaxTests/viewPureChecker/selector_complex2.sol b/test/libsolidity/syntaxTests/viewPureChecker/selector_complex2.sol new file mode 100644 index 00000000..d1543fed --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/selector_complex2.sol @@ -0,0 +1,9 @@ +contract C { + function f() payable public returns (C) { + return this; + } + function g() pure public returns (bytes4) { + C x = C(0x123); + return x.f.selector; + } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol b/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol new file mode 100644 index 00000000..0e397efc --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol @@ -0,0 +1,7 @@ +contract C { + uint x; + function g() pure public {} + function f() view public returns (uint) { return now; } + function h() public { x = 2; } + function i() payable public { x = 2; } +} diff --git a/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol b/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol new file mode 100644 index 00000000..87719eb3 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol @@ -0,0 +1,5 @@ +contract C { + function g() view public { } +} +// ---- +// Warning: (17-45): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/viewPureChecker/suggest_view.sol b/test/libsolidity/syntaxTests/viewPureChecker/suggest_view.sol new file mode 100644 index 00000000..c045dfc4 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/suggest_view.sol @@ -0,0 +1,6 @@ +contract C { + uint x; + function g() public returns (uint) { return x; } +} +// ---- +// Warning: (29-77): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol new file mode 100644 index 00000000..3fed4d29 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol @@ -0,0 +1,6 @@ +contract C { + uint x; + function f() view public { x = 2; } +} +// ---- +// TypeError: (56-57): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/visibility/function_no_visibility.sol b/test/libsolidity/syntaxTests/visibility/function_no_visibility.sol new file mode 100644 index 00000000..ecc36f04 --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/function_no_visibility.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure { } +} +// ---- +// Warning: (17-38): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol b/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol new file mode 100644 index 00000000..ec7c0937 --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; +contract C { + function f() pure { } +} +// ---- +// SyntaxError: (47-68): No visibility specified. |