diff options
author | chriseth <chris@ethereum.org> | 2018-11-14 02:33:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 02:33:35 +0800 |
commit | 1d4f565a64988a3400847d2655ca24f73f234bc6 (patch) | |
tree | caaa6c26e307513505349b50ca4f2a8a9506752b /test/libsolidity/syntaxTests | |
parent | 59dbf8f1085b8b92e8b7eb0ce380cbeb642e97eb (diff) | |
parent | 91b6b8a88e76016e0324036cb7a7f9300a1e2439 (diff) | |
download | dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.gz dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.bz2 dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.lz dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.xz dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.zst dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.zip |
Merge pull request #5416 from ethereum/develop
Merge develop into release for 0.5.0
Diffstat (limited to 'test/libsolidity/syntaxTests')
1172 files changed, 9933 insertions, 1474 deletions
diff --git a/test/libsolidity/syntaxTests/array/array_pop.sol b/test/libsolidity/syntaxTests/array/array_pop.sol new file mode 100644 index 00000000..3804f911 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/array_pop.sol @@ -0,0 +1,7 @@ +contract C { + uint[] data; + function test() public { + data.pop(); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/array/array_pop_arg.sol b/test/libsolidity/syntaxTests/array/array_pop_arg.sol new file mode 100644 index 00000000..bb7803e2 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/array_pop_arg.sol @@ -0,0 +1,8 @@ +contract C { + uint[] data; + function test() public { + data.pop(5); + } +} +// ---- +// TypeError: (65-76): Wrong argument count for function call: 1 arguments given but expected 0. diff --git a/test/libsolidity/syntaxTests/array/bytes_pop.sol b/test/libsolidity/syntaxTests/array/bytes_pop.sol new file mode 100644 index 00000000..cd5aa0eb --- /dev/null +++ b/test/libsolidity/syntaxTests/array/bytes_pop.sol @@ -0,0 +1,7 @@ +contract C { + bytes data; + function test() public { + data.pop(); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/array/dynamic_memory_array_pop.sol b/test/libsolidity/syntaxTests/array/dynamic_memory_array_pop.sol new file mode 100644 index 00000000..5a79afc9 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/dynamic_memory_array_pop.sol @@ -0,0 +1,8 @@ +contract C { + function test() public { + uint[] memory data; + data.pop(); + } +} +// ---- +// TypeError: (74-82): Member "pop" is not available in uint256[] memory outside of storage. 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 new file mode 100644 index 00000000..59328140 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol @@ -0,0 +1,8 @@ +contract C { + function f(uint constant LEN) public { + uint[LEN] a; + } +} +// ---- +// DeclarationError: (28-45): The "constant" keyword can only be used for state variables. +// TypeError: (69-72): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/bytes32_too_large.sol b/test/libsolidity/syntaxTests/array/length/bytes32_too_large.sol new file mode 100644 index 00000000..1742c80d --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/bytes32_too_large.sol @@ -0,0 +1,5 @@ +contract C { + bytes32[8**90] ids; +} +// ---- +// TypeError: (25-30): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/bytes32_too_large_multidim.sol b/test/libsolidity/syntaxTests/array/length/bytes32_too_large_multidim.sol new file mode 100644 index 00000000..1344574c --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/bytes32_too_large_multidim.sol @@ -0,0 +1,5 @@ +contract C { + bytes32[8**90][500] ids; +} +// ---- +// TypeError: (25-30): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_function.sol index 92536dd5..92536dd5 100644 --- a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol +++ b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_function.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol index 89e174f2..89e174f2 100644 --- a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol +++ b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol b/test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol index 6810a9d6..6810a9d6 100644 --- a/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol +++ b/test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol diff --git a/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol b/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol new file mode 100644 index 00000000..2ad97d27 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol @@ -0,0 +1,6 @@ +contract C { + function f() public {} + uint[f] ids; +} +// ---- +// TypeError: (49-50): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol b/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol index a6863955..bb8cc599 100644 --- a/test/libsolidity/syntaxTests/arrayLength/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/arrayLength/complex_cyclic_constant.sol b/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol index 254f9f02..ee107078 100644 --- a/test/libsolidity/syntaxTests/arrayLength/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/arrayLength/const_cannot_be_fractional.sol b/test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol index 397bbbcd..397bbbcd 100644 --- a/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol +++ b/test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/constant_var.sol b/test/libsolidity/syntaxTests/array/length/constant_var.sol index 41750250..41750250 100644 --- a/test/libsolidity/syntaxTests/arrayLength/constant_var.sol +++ b/test/libsolidity/syntaxTests/array/length/constant_var.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol b/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol index 91ba9045..3adc0e9b 100644 --- a/test/libsolidity/syntaxTests/arrayLength/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/length/fixed_size_multidim_zero_length.sol b/test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol new file mode 100644 index 00000000..fd8f3078 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol @@ -0,0 +1,15 @@ +contract C { + function a() public pure returns(int[0][500] memory) {} + function b() public pure returns(uint[0][500] memory) {} + function c() public pure returns(byte[0][500] memory) {} + function d() public pure returns(bytes32[0][500] memory) {} + function e() public pure returns(bytes[0][500] memory) {} + function e() public pure returns(string[0][500] memory) {} +} +// ---- +// TypeError: (52-53): Array with zero length specified. +// TypeError: (111-112): Array with zero length specified. +// TypeError: (170-171): Array with zero length specified. +// TypeError: (232-233): Array with zero length specified. +// TypeError: (292-293): Array with zero length specified. +// TypeError: (353-354): Array with zero length specified. diff --git a/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol b/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol new file mode 100644 index 00000000..b38939e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol @@ -0,0 +1,15 @@ +contract C { + int[0] a; + uint[0] b; + byte[0] c; + bytes32[0] d; + bytes[0] e; + string[0] f; +} +// ---- +// TypeError: (19-20): Array with zero length specified. +// TypeError: (32-33): Array with zero length specified. +// TypeError: (45-46): Array with zero length specified. +// TypeError: (61-62): Array with zero length specified. +// TypeError: (75-76): Array with zero length specified. +// TypeError: (90-91): Array with zero length specified. diff --git a/test/libsolidity/syntaxTests/arrayLength/inline_array.sol b/test/libsolidity/syntaxTests/array/length/inline_array.sol index a30745d3..a30745d3 100644 --- a/test/libsolidity/syntaxTests/arrayLength/inline_array.sol +++ b/test/libsolidity/syntaxTests/array/length/inline_array.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_1.sol index c92861eb..c92861eb 100644 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_1.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_2.sol index 92e3c3cf..92e3c3cf 100644 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_2.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_3.sol index 26add45c..26add45c 100644 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_3.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_4.sol index a0d58f4a..a0d58f4a 100644 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_4.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_5.sol index 38a80867..38a80867 100644 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_5.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol b/test/libsolidity/syntaxTests/array/length/non_integer_constant_var.sol index 7a853a34..7a853a34 100644 --- a/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol +++ b/test/libsolidity/syntaxTests/array/length/non_integer_constant_var.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol b/test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol index b44ccfe9..b44ccfe9 100644 --- a/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol +++ b/test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol diff --git a/test/libsolidity/syntaxTests/array/length/parameter_too_large.sol b/test/libsolidity/syntaxTests/array/length/parameter_too_large.sol new file mode 100644 index 00000000..02e0a7cc --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/parameter_too_large.sol @@ -0,0 +1,5 @@ +contract C { + function f(bytes32[1263941234127518272] memory) public pure {} +} +// ---- +// TypeError: (26-61): Array is too large to be encoded. diff --git a/test/libsolidity/syntaxTests/array/length/parameter_too_large_multidim.sol b/test/libsolidity/syntaxTests/array/length/parameter_too_large_multidim.sol new file mode 100644 index 00000000..5f96ecd5 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/parameter_too_large_multidim.sol @@ -0,0 +1,11 @@ +contract C { + function f(bytes32[1263941234127518272][500] memory) public pure {} + function f(uint[2**30][] memory) public pure {} + function f(uint[2**30][2**30][] memory) public pure {} + function f(uint[2**16][2**16][] memory) public pure {} +} +// ---- +// TypeError: (26-66): Array is too large to be encoded. +// TypeError: (96-116): Array is too large to be encoded. +// TypeError: (146-173): Array is too large to be encoded. +// TypeError: (203-230): Array is too large to be encoded. diff --git a/test/libsolidity/syntaxTests/array/length/parameter_too_large_multidim_ABIv2.sol b/test/libsolidity/syntaxTests/array/length/parameter_too_large_multidim_ABIv2.sol new file mode 100644 index 00000000..de1fde3f --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/parameter_too_large_multidim_ABIv2.sol @@ -0,0 +1,10 @@ +pragma experimental ABIEncoderV2; + +contract C { + function f(bytes32[1263941234127518272][500] memory) public pure {} + function f(uint[2**30][2**30][][] memory) public pure {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (61-101): Array is too large to be encoded. +// TypeError: (131-160): Array is too large to be encoded. diff --git a/test/libsolidity/syntaxTests/arrayLength/parentheses.sol b/test/libsolidity/syntaxTests/array/length/parentheses.sol index 40f55ad6..8dbcc0a4 100644 --- a/test/libsolidity/syntaxTests/arrayLength/parentheses.sol +++ b/test/libsolidity/syntaxTests/array/length/parentheses.sol @@ -21,5 +21,5 @@ contract C { uint[((2) + 1) + 1] a12; uint[(2 + 1) + ((1))] a13; uint[(((2) + 1)) + (((1)))] a14; - uint[((((2) + 1)) + (((1))))%1] a15; + uint[((((3) + 1)) + (((1))))%2] a15; } diff --git a/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol b/test/libsolidity/syntaxTests/array/length/pure_functions.sol index b620db76..b620db76 100644 --- a/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol +++ b/test/libsolidity/syntaxTests/array/length/pure_functions.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/too_large.sol b/test/libsolidity/syntaxTests/array/length/too_large.sol index c90a7494..c90a7494 100644 --- a/test/libsolidity/syntaxTests/arrayLength/too_large.sol +++ b/test/libsolidity/syntaxTests/array/length/too_large.sol diff --git a/test/libsolidity/syntaxTests/arrayLength/tuples.sol b/test/libsolidity/syntaxTests/array/length/tuples.sol index bc10b3b5..bc10b3b5 100644 --- a/test/libsolidity/syntaxTests/arrayLength/tuples.sol +++ b/test/libsolidity/syntaxTests/array/length/tuples.sol diff --git a/test/libsolidity/syntaxTests/array/length/uint_too_large_multidim.sol b/test/libsolidity/syntaxTests/array/length/uint_too_large_multidim.sol new file mode 100644 index 00000000..901bc28a --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/uint_too_large_multidim.sol @@ -0,0 +1,5 @@ +contract C { + uint[8**90][500] ids; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/no_array_pop.sol b/test/libsolidity/syntaxTests/array/no_array_pop.sol new file mode 100644 index 00000000..79a68ef1 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/no_array_pop.sol @@ -0,0 +1,8 @@ +contract C { + uint data; + function test() public { + data.pop(); + } +} +// ---- +// TypeError: (63-71): Member "pop" not found or not visible after argument-dependent lookup in uint256. diff --git a/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol b/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol new file mode 100644 index 00000000..8414f43d --- /dev/null +++ b/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol @@ -0,0 +1,8 @@ +contract C { + uint[3] data; + function test() public { + data.pop(); + } +} +// ---- +// TypeError: (66-74): Member "pop" not found or not visible after argument-dependent lookup in uint256[3] storage ref. diff --git a/test/libsolidity/syntaxTests/array/string_pop.sol b/test/libsolidity/syntaxTests/array/string_pop.sol new file mode 100644 index 00000000..700fda16 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/string_pop.sol @@ -0,0 +1,8 @@ +contract C { + string data; + function test() public { + data.pop(); + } +} +// ---- +// TypeError: (65-73): Member "pop" not found or not visible after argument-dependent lookup in string storage ref. 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..f3be9071 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol @@ -0,0 +1,9 @@ +contract C { + function f() public { + uint[] storage x; + uint[10] storage y; + } +} +// ---- +// DeclarationError: (38-54): Uninitialized storage pointer. +// DeclarationError: (58-76): Uninitialized storage pointer. diff --git a/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol b/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol deleted file mode 100644 index 11d40f26..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract C { - function f(uint constant LEN) { - uint[LEN] a; - } -} -// ---- -// TypeError: (62-65): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol deleted file mode 100644 index ac3abc4c..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - function f() {} - uint[f] ids; -} -// ---- -// TypeError: (42-43): Invalid array length, expected integer literal or constant expression. 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/assign_constant_function_value_050.sol b/test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol deleted file mode 100644 index 2c92899d..00000000 --- a/test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol +++ /dev/null @@ -1,8 +0,0 @@ -pragma experimental "v0.5.0"; - -contract C { - function () pure returns (uint) x; - uint constant y = x(); -} -// ---- -// TypeError: (105-108): 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/constructible_internal_constructor_new.sol b/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor.sol index 8dee4c71..8dee4c71 100644 --- a/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor_new.sol +++ b/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor.sol diff --git a/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor_old.sol b/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor_old.sol deleted file mode 100644 index 144743e3..00000000 --- a/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor_old.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract C { - function C() internal {} -} -contract D is C { - function D() public {} -} -// ---- -// Warning: (14-38): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (60-82): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_new.sol b/test/libsolidity/syntaxTests/constructor/constructor.sol index aa3422cc..aa3422cc 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_new.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor.sol 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..586329b1 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol @@ -0,0 +1,3 @@ +contract A { constructor() {} } +// ---- +// SyntaxError: (13-29): No visibility specified. Did you intend to add "public"? diff --git a/test/libsolidity/syntaxTests/constructor/constructor_old.sol b/test/libsolidity/syntaxTests/constructor/constructor_old.sol index 9ec6257d..9ead6858 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_old.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_old.sol @@ -1,3 +1,4 @@ contract A { function A() public {} } // ---- -// Warning: (13-35): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. +// SyntaxError: (13-35): Functions are not allowed to have the same name as the contract. If you intend this to be a constructor, use "constructor(...) { ... }" to define it. +// Warning: (13-35): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_old_050.sol b/test/libsolidity/syntaxTests/constructor/constructor_old_050.sol deleted file mode 100644 index 19e46e79..00000000 --- a/test/libsolidity/syntaxTests/constructor/constructor_old_050.sol +++ /dev/null @@ -1,4 +0,0 @@ -pragma experimental "v0.5.0"; -contract A { function A() public {} } -// ---- -// SyntaxError: (43-65): Functions are not allowed to have the same name as the contract. If you intend this to be a constructor, use "constructor(...) { ... }" to define it. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability.sol b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability.sol new file mode 100644 index 00000000..39bf6384 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability.sol @@ -0,0 +1,9 @@ +contract test1 { + constructor() public view {} +} +contract test2 { + constructor() public 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_new.sol b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol deleted file mode 100644 index 15ed0e1e..00000000 --- a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol +++ /dev/null @@ -1,13 +0,0 @@ -contract test1 { - constructor() constant {} -} -contract test2 { - constructor() view {} -} -contract test3 { - constructor() 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". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol deleted file mode 100644 index 6dbcbc97..00000000 --- a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol +++ /dev/null @@ -1,16 +0,0 @@ -contract test1 { - function test1() constant {} -} -contract test2 { - function test2() view {} -} -contract test3 { - function test3() 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". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_visibility_new.sol b/test/libsolidity/syntaxTests/constructor/constructor_visibility.sol index 502dc029..f9c4b9b9 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_visibility_new.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_visibility.sol @@ -1,5 +1,5 @@ // The constructor of a base class should not be visible in the derived class -contract A { constructor(string) public { } } +contract A { constructor(string memory) public { } } contract B is A { function f() pure public { A x = A(0); // convert from address @@ -9,4 +9,4 @@ contract B is A { } } // ---- -// TypeError: (243-247): Explicit type conversion not allowed from "string memory" to "contract A". +// TypeError: (250-254): Explicit type conversion not allowed from "string memory" to "contract A". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_visibility_old.sol b/test/libsolidity/syntaxTests/constructor/constructor_visibility_old.sol deleted file mode 100644 index 847ea27b..00000000 --- a/test/libsolidity/syntaxTests/constructor/constructor_visibility_old.sol +++ /dev/null @@ -1,13 +0,0 @@ -// The constructor of a base class should not be visible in the derived class -contract A { function A(string s) public { } } -contract B is A { - function f() pure public { - A x = A(0); // convert from address - string memory y = "ab"; - A(y); // call as a function is invalid - x; - } -} -// ---- -// Warning: (91-122): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// TypeError: (244-248): Explicit type conversion not allowed from "string memory" to "contract A". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation.sol b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation.sol new file mode 100644 index 00000000..6bbb83ce --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation.sol @@ -0,0 +1,5 @@ +contract C { + constructor() public; +} +// ---- +// TypeError: (14-35): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_new.sol b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_new.sol deleted file mode 100644 index 5e619143..00000000 --- a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_new.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - constructor(); -} -// ---- -// TypeError: (14-28): 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 deleted file mode 100644 index 72458703..00000000 --- a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation_old.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - function C(); -} -// ---- -// 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. diff --git a/test/libsolidity/syntaxTests/constructor/external_constructor_new.sol b/test/libsolidity/syntaxTests/constructor/external_constructor.sol index 30cf0668..30cf0668 100644 --- a/test/libsolidity/syntaxTests/constructor/external_constructor_new.sol +++ b/test/libsolidity/syntaxTests/constructor/external_constructor.sol diff --git a/test/libsolidity/syntaxTests/constructor/external_constructor_old.sol b/test/libsolidity/syntaxTests/constructor/external_constructor_old.sol deleted file mode 100644 index 27869361..00000000 --- a/test/libsolidity/syntaxTests/constructor/external_constructor_old.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract test { - function test() external {} -} -// ---- -// Warning: (17-44): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// TypeError: (17-44): Constructor must be public or internal. diff --git a/test/libsolidity/syntaxTests/constructor/function_named_constructor.sol b/test/libsolidity/syntaxTests/constructor/function_named_constructor.sol index 29784033..68273c0a 100644 --- a/test/libsolidity/syntaxTests/constructor/function_named_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/function_named_constructor.sol @@ -2,4 +2,4 @@ contract C { function constructor() public; } // ---- -// Warning: (17-47): This function is named "constructor" but is not the constructor of the contract. If you intend this to be a constructor, use "constructor(...) { ... }" without the "function" keyword to define it. +// ParserError: (26-37): This function is named "constructor" but is not the constructor of the contract. If you intend this to be a constructor, use "constructor(...) { ... }" without the "function" keyword to define it. diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_new.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor.sol index 2511c751..2511c751 100644 --- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_new.sol +++ b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor.sol diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted_new.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol index 2a199b3a..17cb701d 100644 --- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted_new.sol +++ b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol @@ -3,11 +3,11 @@ contract B { A a; constructor() public { - a = new A(this); + a = new A(address(this)); } } contract A { - constructor(address a) internal {} + constructor(address) internal {} } // ---- // TypeError: (141-146): Contract with internal constructor cannot be created directly. diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted_old.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted_old.sol deleted file mode 100644 index 0a27e9f8..00000000 --- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted_old.sol +++ /dev/null @@ -1,15 +0,0 @@ -// Previously, the type information for A was not yet available at the point of -// "new A". -contract B { - A a; - function B() public { - a = new A(this); - } -} -contract A { - function A(address a) internal {} -} -// ---- -// Warning: (112-155): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (172-205): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// TypeError: (140-145): Contract with internal constructor cannot be created directly. diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_old.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_old.sol deleted file mode 100644 index 2897e6f3..00000000 --- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_old.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract C { - function C() internal {} -} -contract D { - function f() public { C x = new C(); x; } -} -// ---- -// Warning: (14-38): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// TypeError: (83-88): Contract with internal constructor cannot be created directly. diff --git a/test/libsolidity/syntaxTests/constructor/interface_constructor.sol b/test/libsolidity/syntaxTests/constructor/interface_constructor.sol new file mode 100644 index 00000000..87585a62 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/interface_constructor.sol @@ -0,0 +1,7 @@ +interface I { + constructor() public; +} +// ---- +// TypeError: (15-36): Functions in interfaces must 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_new.sol b/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol deleted file mode 100644 index fa5d54c4..00000000 --- a/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol +++ /dev/null @@ -1,7 +0,0 @@ -interface I { - constructor(); -} -// ---- -// 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. diff --git a/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol b/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol deleted file mode 100644 index ddf54977..00000000 --- a/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol +++ /dev/null @@ -1,8 +0,0 @@ -interface I { - function I(); -} -// ---- -// 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. diff --git a/test/libsolidity/syntaxTests/constructor/library_constructor.sol b/test/libsolidity/syntaxTests/constructor/library_constructor.sol new file mode 100644 index 00000000..38934f8d --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/library_constructor.sol @@ -0,0 +1,6 @@ +library Lib { + constructor() public; +} +// ---- +// 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_new.sol b/test/libsolidity/syntaxTests/constructor/library_constructor_new.sol deleted file mode 100644 index 8db7e62a..00000000 --- a/test/libsolidity/syntaxTests/constructor/library_constructor_new.sol +++ /dev/null @@ -1,6 +0,0 @@ -library Lib { - constructor(); -} -// ---- -// TypeError: (15-29): Constructor cannot be defined in libraries. -// TypeError: (15-29): 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 deleted file mode 100644 index d4499049..00000000 --- a/test/libsolidity/syntaxTests/constructor/library_constructor_old.sol +++ /dev/null @@ -1,7 +0,0 @@ -library Lib { - function Lib(); -} -// ---- -// 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. diff --git a/test/libsolidity/syntaxTests/constructor/overriding_constructor.sol b/test/libsolidity/syntaxTests/constructor/overriding_constructor.sol index 3290a33b..30cf3bce 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 B is A { function A() public pure returns (uint8) {} } +contract A { function f() public {} } +contract B is A { + function A() public pure returns (uint8) {} + function g() public { + A.f(); + } +} // ---- -// 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: (58-101): This declaration shadows an existing declaration. +// TypeError: (130-133): Member "f" not found or not visible after argument-dependent lookup in function () pure returns (uint8). diff --git a/test/libsolidity/syntaxTests/constructor/returns_in_constructor_new.sol b/test/libsolidity/syntaxTests/constructor/returns_in_constructor.sol index e6a03014..e6a03014 100644 --- a/test/libsolidity/syntaxTests/constructor/returns_in_constructor_new.sol +++ b/test/libsolidity/syntaxTests/constructor/returns_in_constructor.sol diff --git a/test/libsolidity/syntaxTests/constructor/returns_in_constructor_old.sol b/test/libsolidity/syntaxTests/constructor/returns_in_constructor_old.sol deleted file mode 100644 index 00b3974c..00000000 --- a/test/libsolidity/syntaxTests/constructor/returns_in_constructor_old.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract test { - function test() public returns (uint a) { } -} -// ---- -// Warning: (17-60): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// TypeError: (48-56): Non-empty "returns" directive for constructor. diff --git a/test/libsolidity/syntaxTests/constructor/two_constructors_new.sol b/test/libsolidity/syntaxTests/constructor/two_constructors.sol index 42c0de28..42c0de28 100644 --- a/test/libsolidity/syntaxTests/constructor/two_constructors_new.sol +++ b/test/libsolidity/syntaxTests/constructor/two_constructors.sol diff --git a/test/libsolidity/syntaxTests/constructor/two_constructors_mixed.sol b/test/libsolidity/syntaxTests/constructor/two_constructors_mixed.sol deleted file mode 100644 index c757354e..00000000 --- a/test/libsolidity/syntaxTests/constructor/two_constructors_mixed.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract test { - function test(uint) public { } - constructor() public {} -} -// ---- -// Warning: (17-47): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// DeclarationError: (49-72): More than one constructor defined. diff --git a/test/libsolidity/syntaxTests/constructor/two_constructors_old.sol b/test/libsolidity/syntaxTests/constructor/two_constructors_old.sol deleted file mode 100644 index db632ced..00000000 --- a/test/libsolidity/syntaxTests/constructor/two_constructors_old.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract test { - function test(uint a) public { } - function test() public {} -} -// ---- -// Warning: (17-49): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (51-76): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// DeclarationError: (51-76): More than one constructor defined. diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol new file mode 100644 index 00000000..35420b6d --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol @@ -0,0 +1,5 @@ +contract C { + function f() internal pure returns (mapping(uint=>uint) storage r) { } +} +// ---- +// TypeError: (53-82): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol new file mode 100644 index 00000000..4146192f --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol @@ -0,0 +1,5 @@ +contract C { + mapping(uint=>uint) m; + function f() internal view returns (mapping(uint=>uint) storage r) { r = m; } +} +// ---- diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol new file mode 100644 index 00000000..52a8b3d7 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol @@ -0,0 +1,5 @@ +contract C { + function f() internal pure returns (mapping(uint=>uint) storage) {} +} +// ---- +// TypeError: (53-80): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol new file mode 100644 index 00000000..9c5e3149 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol @@ -0,0 +1,5 @@ +contract C { + mapping(uint=>uint) m; + function f() internal view returns (mapping(uint=>uint) storage) { return m; } +} +// ---- diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol new file mode 100644 index 00000000..cad9b8e8 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol @@ -0,0 +1,10 @@ +contract C { + struct S { bool f; } + S s; + function f() internal pure returns (S storage) { + assembly { + } + } +} +// ---- +// TypeError: (87-96): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol index 65902cc8..0d3db856 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol @@ -8,7 +8,7 @@ contract C { } function g(bool flag) internal returns (S storage c) { // control flow in assembly will not be analyzed for now, - // so this will not issue a warning + // so this will not issue an error assembly { if flag { sstore(c_slot, sload(s_slot)) @@ -17,7 +17,7 @@ contract C { } function h() internal returns (S storage c) { // any reference from assembly will be sufficient for now, - // so this will not issue a warning + // so this will not issue an error assembly { sstore(s_slot, sload(c_slot)) } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol deleted file mode 100644 index 09c13847..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol +++ /dev/null @@ -1,10 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal pure returns (S storage) { - assembly { - } - } -} -// ---- -// Warning: (87-88): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/default_location.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/default_location.sol index 9a42192d..ec83c596 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/default_location.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/default_location.sol @@ -1,18 +1,18 @@ contract C { struct S { bool f; } S s; - function f() internal view returns (S c) { + function f() internal view returns (S memory c) { c = s; } - function g() internal view returns (S) { + function g() internal view returns (S memory) { return s; } - function h() internal pure returns (S) { + function h() internal pure returns (S memory) { } - function i(bool flag) internal view returns (S c) { + function i(bool flag) internal view returns (S memory c) { if (flag) c = s; } - function j(bool flag) internal view returns (S) { + function j(bool flag) internal view returns (S memory) { if (flag) return s; } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol new file mode 100644 index 00000000..eb574c96 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol @@ -0,0 +1,52 @@ +contract C { + struct S { bool f; } + S s; + function f() internal view returns (S storage c) { + do { + break; + c = s; + } while(false); + } + function g() internal view returns (S storage c) { + do { + if (s.f) { + continue; + c = s; + } + else { + } + } while(false); + } + function h() internal view returns (S storage c) { + do { + if (s.f) { + break; + } + else { + c = s; + } + } while(false); + } + function i() internal view returns (S storage c) { + do { + if (s.f) { + continue; + } + else { + c = s; + } + } while(false); + } + function j() internal view returns (S storage c) { + do { + continue; + c = s; + } while(false); + } +} +// ---- +// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (223-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (440-451): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (654-665): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (871-882): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol index 6520672c..55c5edd3 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol @@ -23,13 +23,8 @@ contract C { } function k() internal view returns (S storage c) { do { - if (s.f) { - continue; - break; - } - else { - c = s; - } + c = s; + continue; } while(false); } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol deleted file mode 100644 index f1a92e9c..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol +++ /dev/null @@ -1,35 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c) { - do { - break; - c = s; - } while(false); - } - function g() internal view returns (S storage c) { - do { - if (s.f) { - continue; - c = s; - } - else { - } - } while(false); - } - function h() internal view returns (S storage c) { - do { - if (s.f) { - break; - continue; - } - else { - c = s; - } - } while(false); - } -} -// ---- -// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (223-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (440-451): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol deleted file mode 100644 index 3a0a30ea..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c, S storage d) { c = s; d = s; return; } -} -// ---- diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol deleted file mode 100644 index 0a5b2fbf..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol +++ /dev/null @@ -1,15 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal pure returns (S storage) { return; } - function g() internal view returns (S storage c, S storage) { c = s; return; } - function h() internal view returns (S storage, S storage d) { d = s; return; } - function i() internal pure returns (S storage, S storage) { return; } - function j() internal view returns (S storage, S storage) { return (s,s); } -} -// ---- -// Warning: (87-88): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (163-164): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (233-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (316-317): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (327-328): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol new file mode 100644 index 00000000..9aa580a4 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol @@ -0,0 +1,16 @@ +contract C { + struct S { bool f; } + S s; + function f() internal view returns (S storage c) { + for(;; c = s) { + } + } + function g() internal view returns (S storage c) { + for(;;) { + c = s; + } + } +} +// ---- +// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (182-193): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol deleted file mode 100644 index ba9a2440..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol +++ /dev/null @@ -1,16 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c) { - for(;; c = s) { - } - } - function g() internal view returns (S storage c) { - for(;;) { - c = s; - } - } -} -// ---- -// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (182-193): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol new file mode 100644 index 00000000..f3e55318 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol @@ -0,0 +1,18 @@ +contract C { + struct S { bool f; } + S s; + function f(bool flag) internal view returns (S storage c) { + if (flag) c = s; + } + function g(bool flag) internal returns (S storage c) { + if (flag) c = s; + else + { + if (!flag) c = s; + else s.f = true; + } + } +} +// ---- +// TypeError: (96-107): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (186-197): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol deleted file mode 100644 index c257c252..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol +++ /dev/null @@ -1,18 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f(bool flag) internal view returns (S storage c) { - if (flag) c = s; - } - function g(bool flag) internal returns (S storage c) { - if (flag) c = s; - else - { - if (!flag) c = s; - else s.f = true; - } - } -} -// ---- -// Warning: (96-107): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (186-197): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol new file mode 100644 index 00000000..42342979 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol @@ -0,0 +1,22 @@ +contract C { + modifier revertIfNoReturn() { + _; + revert(); + } + modifier ifFlag(bool flag) { + if (flag) + _; + } + struct S { uint a; } + S s; + function f(bool flag) ifFlag(flag) internal view returns(S storage) { + return s; + } + + function g(bool flag) ifFlag(flag) revertIfNoReturn() internal view returns(S storage) { + return s; + } +} +// ---- +// TypeError: (249-258): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (367-376): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol deleted file mode 100644 index 50c6dd99..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol +++ /dev/null @@ -1,22 +0,0 @@ -contract C { - modifier revertIfNoReturn() { - _; - revert(); - } - modifier ifFlag(bool flag) { - if (flag) - _; - } - struct S { uint a; } - S s; - function f(bool flag) ifFlag(flag) internal view returns(S storage) { - return s; - } - - function g(bool flag) ifFlag(flag) revertIfNoReturn() internal view returns(S storage) { - return s; - } -} -// ---- -// Warning: (249-250): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (367-368): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol new file mode 100644 index 00000000..d0ad8245 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol @@ -0,0 +1,18 @@ +contract C { + struct S { bool f; } + S s; + function f() internal view returns (S storage c) { + false && (c = s).f; + } + function g() internal view returns (S storage c) { + true || (c = s).f; + } + function h() internal view returns (S storage c) { + // expect error, although this is always fine + true && (false || (c = s).f); + } +} +// ---- +// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (176-187): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (264-275): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol deleted file mode 100644 index 9f660f11..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol +++ /dev/null @@ -1,18 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c) { - false && (c = s).f; - } - function g() internal view returns (S storage c) { - true || (c = s).f; - } - function h() internal view returns (S storage c) { - // expect warning, although this is always fine - true && (false || (c = s).f); - } -} -// ---- -// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (176-187): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (264-275): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol new file mode 100644 index 00000000..6d10287b --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol @@ -0,0 +1,13 @@ +contract C { + struct S { bool f; } + S s; + function f(bool flag) internal view returns (S storage c) { + flag ? (c = s).f : false; + } + function g(bool flag) internal view returns (S storage c) { + flag ? false : (c = s).f; + } +} +// ---- +// TypeError: (96-107): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (200-211): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol deleted file mode 100644 index 57561fbb..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol +++ /dev/null @@ -1,13 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f(bool flag) internal view returns (S storage c) { - flag ? (c = s).f : false; - } - function g(bool flag) internal view returns (S storage c) { - flag ? false : (c = s).f; - } -} -// ---- -// Warning: (96-107): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (200-211): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol deleted file mode 100644 index 4cecc27c..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal pure returns (S storage) { - throw; - } -} -// ---- -// Warning: (108-113): "throw" is deprecated in favour of "revert()", "require()" and "assert()". diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol index 0b171560..7567f694 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol @@ -8,5 +8,8 @@ contract C { uint a; (c, a) = f(); } + function h() internal view returns (S storage, S storage) { + return (s,s); + } } // ---- diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_internal.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_internal.sol new file mode 100644 index 00000000..8bce0dd2 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_internal.sol @@ -0,0 +1,4 @@ +contract C { + function f() internal returns(uint[] storage); + function g() internal returns(uint[] storage s); +} diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_library.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_library.sol new file mode 100644 index 00000000..818b6a20 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_library.sol @@ -0,0 +1,4 @@ +library L { + function f() public returns(uint[] storage); + function g() public returns(uint[] storage s); +} diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol new file mode 100644 index 00000000..e7b4fae7 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol @@ -0,0 +1,11 @@ +contract C { + struct S { bool f; } + S s; + function f() internal view returns (S storage c) { + while(false) { + c = s; + } + } +} +// ---- +// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol deleted file mode 100644 index 26db892f..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c) { - while(false) { - c = s; - } - } -} -// ---- -// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_bytes_array.sol b/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_bytes_array.sol new file mode 100644 index 00000000..78c40e53 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_bytes_array.sol @@ -0,0 +1,9 @@ +contract C { + bytes a; + bytes b; + function f() public view { + bytes storage c = a; + bytes memory d = b; + d = bytes(c); + } +} diff --git a/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_string.sol b/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_string.sol new file mode 100644 index 00000000..f7e96f35 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_string.sol @@ -0,0 +1,9 @@ +contract C { + string a; + string b; + function f() public view { + string storage c = a; + string memory d = b; + d = string(c); + } +} diff --git a/test/libsolidity/syntaxTests/conversion/conversion_to_bytes.sol b/test/libsolidity/syntaxTests/conversion/conversion_to_bytes.sol new file mode 100644 index 00000000..3a6deff1 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/conversion_to_bytes.sol @@ -0,0 +1,5 @@ +contract test { + function f() public pure returns (bytes memory) { + return bytes("abc"); + } +} diff --git a/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_storage_array_ref.sol b/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_storage_array_ref.sol new file mode 100644 index 00000000..458adda6 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_storage_array_ref.sol @@ -0,0 +1,10 @@ +contract C { + int[10] x; + function f() public view { + int[](x); + int(x); + } +} +// ---- +// TypeError: (55-63): Explicit type conversion not allowed from "int256[10] storage ref" to "int256[] storage pointer". +// TypeError: (67-73): Explicit type conversion not allowed from "int256[10] storage ref" to "int256". diff --git a/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_payable.sol b/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_payable.sol new file mode 100644 index 00000000..75f7a953 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_payable.sol @@ -0,0 +1,10 @@ +contract C { + function h() external { + } + function f() view external returns (bytes4) { + function () payable external g = this.h; + return g.selector; + } +} +// ---- +// TypeError: (105-144): Type function () external is not implicitly convertible to expected type function () payable external. diff --git a/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_pure.sol b/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_pure.sol new file mode 100644 index 00000000..8d1b08aa --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_pure.sol @@ -0,0 +1,10 @@ +contract C { + function h() external { + } + function f() view external returns (bytes4) { + function () pure external g = this.h; + return g.selector; + } +} +// ---- +// TypeError: (105-141): Type function () external is not implicitly convertible to expected type function () pure external. diff --git a/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_view.sol b/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_view.sol new file mode 100644 index 00000000..535d6c77 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_nonpayable_view.sol @@ -0,0 +1,10 @@ +contract C { + function h() external { + } + function f() view external returns (bytes4) { + function () view external g = this.h; + return g.selector; + } +} +// ---- +// TypeError: (105-141): Type function () external is not implicitly convertible to expected type function () view external. diff --git a/test/libsolidity/syntaxTests/conversion/function_type_payable_nonpayable.sol b/test/libsolidity/syntaxTests/conversion/function_type_payable_nonpayable.sol new file mode 100644 index 00000000..299d7e30 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_payable_nonpayable.sol @@ -0,0 +1,8 @@ +contract C { + function h() payable external { + } + function f() view external returns (bytes4) { + function () external g = this.h; + return g.selector; + } +} diff --git a/test/libsolidity/syntaxTests/conversion/function_type_payable_pure.sol b/test/libsolidity/syntaxTests/conversion/function_type_payable_pure.sol new file mode 100644 index 00000000..78bada51 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_payable_pure.sol @@ -0,0 +1,10 @@ +contract C { + function h() payable external { + } + function f() view external returns (bytes4) { + function () pure external g = this.h; + return g.selector; + } +} +// ---- +// TypeError: (113-149): Type function () payable external is not implicitly convertible to expected type function () pure external. diff --git a/test/libsolidity/syntaxTests/conversion/function_type_payable_view.sol b/test/libsolidity/syntaxTests/conversion/function_type_payable_view.sol new file mode 100644 index 00000000..f12cb301 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_payable_view.sol @@ -0,0 +1,10 @@ +contract C { + function h() payable external { + } + function f() view external returns (bytes4) { + function () view external g = this.h; + return g.selector; + } +} +// ---- +// TypeError: (113-149): Type function () payable external is not implicitly convertible to expected type function () view external. diff --git a/test/libsolidity/syntaxTests/conversion/function_type_pure_nonpayable.sol b/test/libsolidity/syntaxTests/conversion/function_type_pure_nonpayable.sol new file mode 100644 index 00000000..7742e0c1 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_pure_nonpayable.sol @@ -0,0 +1,8 @@ +contract C { + function h() pure external { + } + function f() view external returns (bytes4) { + function () external g = this.h; + return g.selector; + } +} diff --git a/test/libsolidity/syntaxTests/conversion/function_type_pure_payable.sol b/test/libsolidity/syntaxTests/conversion/function_type_pure_payable.sol new file mode 100644 index 00000000..cd4e9b4e --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_pure_payable.sol @@ -0,0 +1,10 @@ +contract C { + function h() pure external { + } + function f() view external returns (bytes4) { + function () payable external g = this.h; + return g.selector; + } +} +// ---- +// TypeError: (110-149): Type function () pure external is not implicitly convertible to expected type function () payable external. diff --git a/test/libsolidity/syntaxTests/conversion/function_type_pure_view.sol b/test/libsolidity/syntaxTests/conversion/function_type_pure_view.sol new file mode 100644 index 00000000..578ecdbd --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_pure_view.sol @@ -0,0 +1,8 @@ +contract C { + function h() pure external { + } + function f() view external returns (bytes4) { + function () view external g = this.h; + return g.selector; + } +} diff --git a/test/libsolidity/syntaxTests/conversion/function_type_same.sol b/test/libsolidity/syntaxTests/conversion/function_type_same.sol new file mode 100644 index 00000000..c5ebe1ca --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_same.sol @@ -0,0 +1,14 @@ +contract C { + int dummy; + function h_nonpayable() external { dummy = 1; } + function h_payable() payable external {} + function h_view() view external { dummy; } + function h_pure() pure external {} + function f() view external { + function () external g_nonpayable = this.h_nonpayable; g_nonpayable; + function () payable external g_payable = this.h_payable; g_payable; + function () view external g_view = this.h_view; g_view; + function () pure external g_pure = this.h_pure; g_pure; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/conversion/function_type_view_nonpayable.sol b/test/libsolidity/syntaxTests/conversion/function_type_view_nonpayable.sol new file mode 100644 index 00000000..f52aece0 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_view_nonpayable.sol @@ -0,0 +1,10 @@ +contract C { + int dummy; + function h() view external { + dummy; + } + function f() view external returns (bytes4) { + function () external g = this.h; + return g.selector; + } +} diff --git a/test/libsolidity/syntaxTests/conversion/function_type_view_payable.sol b/test/libsolidity/syntaxTests/conversion/function_type_view_payable.sol new file mode 100644 index 00000000..3bf4bac2 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_view_payable.sol @@ -0,0 +1,10 @@ +contract C { + function h() view external { + } + function f() view external returns (bytes4) { + function () payable external g = this.h; + return g.selector; + } +} +// ---- +// TypeError: (110-149): Type function () view external is not implicitly convertible to expected type function () payable external. diff --git a/test/libsolidity/syntaxTests/conversion/function_type_view_pure.sol b/test/libsolidity/syntaxTests/conversion/function_type_view_pure.sol new file mode 100644 index 00000000..c567a2c8 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/function_type_view_pure.sol @@ -0,0 +1,10 @@ +contract C { + function h() view external { + } + function f() view external returns (bytes4) { + function () pure external g = this.h; + return g.selector; + } +} +// ---- +// TypeError: (110-146): Type function () view external is not implicitly convertible to expected type function () pure external. diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_storage_array_ref.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_storage_array_ref.sol new file mode 100644 index 00000000..31e298d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_storage_array_ref.sol @@ -0,0 +1,7 @@ +contract C { + int[10] x; + int[] y; + function f() public { + y = x; + } +} diff --git a/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer1.sol b/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer1.sol new file mode 100644 index 00000000..3aa59612 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer1.sol @@ -0,0 +1,10 @@ +contract C { + uint[] a; + uint[] b; + function f() public view { + uint[] storage c = a; + uint[] storage d = b; + d = uint[](c); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer2.sol b/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer2.sol new file mode 100644 index 00000000..060c9707 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer2.sol @@ -0,0 +1,10 @@ +contract C { + uint[] a; + uint[] b; + function f() public view { + uint[] storage c = a; + uint[] memory d = b; + d = uint[](c); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type.sol b/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type.sol new file mode 100644 index 00000000..b23fbb89 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type.sol @@ -0,0 +1,4 @@ +library L { + struct Nested { uint y; } + function c(function(Nested memory) external returns (uint)[] storage) external pure {} +} diff --git a/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type_fail.sol b/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type_fail.sol new file mode 100644 index 00000000..b80849ce --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type_fail.sol @@ -0,0 +1,9 @@ +library L { + struct Nested { uint y; } + function b(function(Nested calldata) external returns (uint)[] storage) external pure {} + function d(function(Nested storage) external returns (uint)[] storage) external pure {} +} + +// ---- +// TypeError: (66-81): Data location must be "memory" for parameter in function, but "calldata" was given. +// TypeError: (159-173): Data location must be "memory" for parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/external_function_return_parameters_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/external_function_return_parameters_no_data_location.sol new file mode 100644 index 00000000..cbcf2a6e --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/external_function_return_parameters_no_data_location.sol @@ -0,0 +1,5 @@ +contract C { + function i() external pure returns(uint[]) {} +} +// ---- +// TypeError: (52-58): Data location must be "memory" for return parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol new file mode 100644 index 00000000..781c645a --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol @@ -0,0 +1,4 @@ +contract test { + function f(bytes calldata) external; +} +// ---- diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol new file mode 100644 index 00000000..d30bde3f --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol @@ -0,0 +1,5 @@ +contract test { + function f(bytes memory) external; +} +// ---- +// TypeError: (31-43): Data location must be "calldata" for parameter in external function, but "memory" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol new file mode 100644 index 00000000..7dc5ba6d --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol @@ -0,0 +1,5 @@ +contract test { + function f(bytes storage) external; +} +// ---- +// TypeError: (31-44): Data location must be "calldata" for parameter in external function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol new file mode 100644 index 00000000..bc14aa1f --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol @@ -0,0 +1,5 @@ +contract test { + function f(bytes4 memory) public; +} +// ---- +// TypeError: (31-44): Data location can only be specified for array, struct or mapping types, but "memory" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/function_parameters_with_data_location_fine.sol b/test/libsolidity/syntaxTests/dataLocations/function_parameters_with_data_location_fine.sol new file mode 100644 index 00000000..2bc7b393 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/function_parameters_with_data_location_fine.sol @@ -0,0 +1,8 @@ +contract C { + function f(uint[] memory, uint[] storage) private pure {} + function g(uint[] memory, uint[] storage) internal pure {} + function h(uint[] memory) public pure {} + function i(uint[] calldata) external pure {} + // No data location for events. + event e(uint[]); +} diff --git a/test/libsolidity/syntaxTests/dataLocations/function_return_parameters_with_data_location_fine.sol b/test/libsolidity/syntaxTests/dataLocations/function_return_parameters_with_data_location_fine.sol new file mode 100644 index 00000000..ea019198 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/function_return_parameters_with_data_location_fine.sol @@ -0,0 +1,6 @@ +contract C { + function f() private pure returns(uint[] memory, uint[] storage b) { b = b; } + function g() internal pure returns(uint[] memory, uint[] storage b) { b = b; } + function h() public pure returns(uint[] memory) {} + function i() external pure returns(uint[] memory) {} +} diff --git a/test/libsolidity/syntaxTests/dataLocations/function_type_array_as_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/function_type_array_as_reference_type.sol new file mode 100644 index 00000000..b3856f58 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/function_type_array_as_reference_type.sol @@ -0,0 +1,8 @@ +contract C { + struct Nested { uint y; } + // ensure that we consider array of function pointers as reference type + function b(function(Nested memory) external returns (uint)[] storage) internal pure {} + function c(function(Nested memory) external returns (uint)[] memory) public pure {} + function d(function(Nested memory) external returns (uint)[] calldata) external pure {} +} +// ---- diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol new file mode 100644 index 00000000..da3abff4 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol @@ -0,0 +1,5 @@ +contract test { + function f(bytes calldata) internal; +} +// ---- +// TypeError: (31-45): Data location must be "storage" or "memory" for parameter in function, but "calldata" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol new file mode 100644 index 00000000..1e5971c4 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol @@ -0,0 +1,4 @@ +contract test { + function f(bytes memory) internal; +} +// ---- diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol new file mode 100644 index 00000000..56f0fe99 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol @@ -0,0 +1,4 @@ +contract test { + function f(bytes storage) internal; +} +// ---- diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/internal_function_parameters_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/internal_function_parameters_no_data_location.sol new file mode 100644 index 00000000..f1c4a550 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/internal_function_parameters_no_data_location.sol @@ -0,0 +1,5 @@ +contract C { + function g(uint[]) internal pure {} +} +// ---- +// TypeError: (28-34): Data location must be "storage" or "memory" for parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/internal_function_return_parameters_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/internal_function_return_parameters_no_data_location.sol new file mode 100644 index 00000000..a32995e7 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/internal_function_return_parameters_no_data_location.sol @@ -0,0 +1,5 @@ +contract C { + function g() internal pure returns(uint[]) {} +} +// ---- +// TypeError: (52-58): Data location must be "storage" or "memory" for return parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraries/library_external_function_params_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/libraries/library_external_function_params_no_data_location.sol new file mode 100644 index 00000000..c20088b7 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraries/library_external_function_params_no_data_location.sol @@ -0,0 +1,12 @@ +library L { + struct S { uint x; } + function g(uint[2]) external pure {} + function h(uint[]) external pure {} + function i(S) external pure {} + function j(mapping(uint => uint)) external pure {} +} +// ---- +// TypeError: (52-59): Data location must be "storage" or "calldata" for parameter in external function, but none was given. +// TypeError: (93-99): Data location must be "storage" or "calldata" for parameter in external function, but none was given. +// TypeError: (133-134): Data location must be "storage" or "calldata" for parameter in external function, but none was given. +// TypeError: (168-189): Data location must be "storage" or "calldata" for parameter in external function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraries/library_external_function_return_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/libraries/library_external_function_return_no_data_location.sol new file mode 100644 index 00000000..fa3a7821 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraries/library_external_function_return_no_data_location.sol @@ -0,0 +1,12 @@ +library L { + struct S { uint x; } + function g() external pure returns (uint[2]) {} + function h() external pure returns (uint[]) {} + function i() external pure returns (S) {} + function j() external pure returns (mapping(uint => uint)) {} +} +// ---- +// TypeError: (77-84): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (129-135): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (180-181): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (226-247): Data location must be "storage" or "memory" for return parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_fine.sol b/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_fine.sol new file mode 100644 index 00000000..7a276f95 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_fine.sol @@ -0,0 +1,10 @@ +library L { + struct S { uint x; } + function f(uint[] memory, uint[] storage, S storage) private pure + returns (mapping(uint => uint) storage a, S memory b, uint[] storage c) { return (a, b, c); } + function g(uint[] memory, uint[] storage) internal pure + returns (mapping(uint => uint) storage a, S memory b, uint[] storage c) { return (a, b, c); } + function h(uint[] memory, uint[] storage) public pure returns (S storage x) { return x; } + function i(uint[] calldata, uint[] storage) external pure returns (S storage x) {return x; } +} +// ---- diff --git a/test/libsolidity/syntaxTests/dataLocations/libraries/library_internal_function_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/libraries/library_internal_function_no_data_location.sol new file mode 100644 index 00000000..68c177a8 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraries/library_internal_function_no_data_location.sol @@ -0,0 +1,20 @@ +library L { + struct S { uint x; } + function g() internal pure returns (uint[2]) {} + function h() internal pure returns (uint[]) {} + function i() internal pure returns (S) {} + function j() internal pure returns (mapping(uint => uint)) {} + function gp(uint[2]) internal pure {} + function hp(uint[]) internal pure {} + function ip(S) internal pure {} + function jp(mapping(uint => uint)) internal pure {} +} +// ---- +// TypeError: (77-84): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (129-135): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (180-181): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (226-247): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (268-275): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (310-316): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (351-352): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (387-408): Data location must be "storage" or "memory" for parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraries/library_private_function_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/libraries/library_private_function_no_data_location.sol new file mode 100644 index 00000000..35256eae --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraries/library_private_function_no_data_location.sol @@ -0,0 +1,20 @@ +library L { + struct S { uint x; } + function g() private pure returns (uint[2]) {} + function h() private pure returns (uint[]) {} + function i() private pure returns (S) {} + function j() private pure returns (mapping(uint => uint)) {} + function gp(uint[2]) private pure {} + function hp(uint[]) private pure {} + function ip(S) private pure {} + function jp(mapping(uint => uint)) private pure {} +} +// ---- +// TypeError: (76-83): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (127-133): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (177-178): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (222-243): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (264-271): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (305-311): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (345-346): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (380-401): Data location must be "storage" or "memory" for parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraries/library_public_function_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/libraries/library_public_function_no_data_location.sol new file mode 100644 index 00000000..f8f8dcb2 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraries/library_public_function_no_data_location.sol @@ -0,0 +1,19 @@ +library L { + struct S { uint x; } + function g() private pure returns (uint[2]) {} + function h() private pure returns (uint[]) {} + function i() private pure returns (S) {} + function j() private pure returns (mapping(uint => uint)) {} + function gp(uint[2]) private pure {} + function hp(uint[]) private pure {} + function ip(S) private pure {} + function jp(mapping(uint => uint)) private pure {}} +// ---- +// TypeError: (76-83): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (127-133): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (177-178): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (222-243): Data location must be "storage" or "memory" for return parameter in function, but none was given. +// TypeError: (264-271): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (305-311): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (345-346): Data location must be "storage" or "memory" for parameter in function, but none was given. +// TypeError: (380-401): Data location must be "storage" or "memory" for parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_calldata.sol new file mode 100644 index 00000000..d3ac2acc --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_calldata.sol @@ -0,0 +1,3 @@ +library test { + function f(bytes calldata) external; +} diff --git a/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_memory.sol b/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_memory.sol new file mode 100644 index 00000000..2de0082a --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_memory.sol @@ -0,0 +1,5 @@ +library test { + function f(bytes memory) external; +} +// ---- +// TypeError: (30-42): Data location must be "storage" or "calldata" for parameter in external function, but "memory" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_storage.sol b/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_storage.sol new file mode 100644 index 00000000..2ee68ef9 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_storage.sol @@ -0,0 +1,3 @@ +library test { + function f(bytes storage) external; +} diff --git a/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_calldata.sol new file mode 100644 index 00000000..c4b81f98 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_calldata.sol @@ -0,0 +1,5 @@ +library test { + function f(bytes calldata) internal pure {} +} +// ---- +// TypeError: (30-44): Data location must be "storage" or "memory" for parameter in function, but "calldata" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_memory.sol b/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_memory.sol new file mode 100644 index 00000000..78a30f5b --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_memory.sol @@ -0,0 +1,3 @@ +library test { + function f(bytes memory) internal pure {} +} diff --git a/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_storage.sol b/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_storage.sol new file mode 100644 index 00000000..b51f148b --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_storage.sol @@ -0,0 +1,3 @@ +library test { + function f(bytes storage) internal pure {} +} diff --git a/test/libsolidity/syntaxTests/dataLocations/memory_storage_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/memory_storage_data_location.sol new file mode 100644 index 00000000..a441b540 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/memory_storage_data_location.sol @@ -0,0 +1,12 @@ +contract C { + int[] x; + function f() public { + int[] storage a = x; + int[] memory b; + a = b; + a = int[](b); + } +} +// ---- +// TypeError: (93-94): Type int256[] memory is not implicitly convertible to expected type int256[] storage pointer. +// TypeError: (102-110): Type int256[] memory is not implicitly convertible to expected type int256[] storage pointer. diff --git a/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_parameters_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_parameters_no_data_location.sol new file mode 100644 index 00000000..fdd5cbaf --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_parameters_no_data_location.sol @@ -0,0 +1,5 @@ +contract C { + function f(uint[]) private pure {} +} +// ---- +// TypeError: (28-34): Data location must be "storage" or "memory" for parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_return_parameters_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_return_parameters_no_data_location.sol new file mode 100644 index 00000000..65ec1bce --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_return_parameters_no_data_location.sol @@ -0,0 +1,5 @@ +contract C { + function f() private pure returns(uint[]) {} +} +// ---- +// TypeError: (51-57): Data location must be "storage" or "memory" for return parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol new file mode 100644 index 00000000..3aba870f --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol @@ -0,0 +1,5 @@ +contract test { + function f(bytes calldata) public; +} +// ---- +// TypeError: (31-45): Data location must be "memory" for parameter in function, but "calldata" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol new file mode 100644 index 00000000..4eebf016 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol @@ -0,0 +1,4 @@ +contract test { + function f(bytes memory) public; +} +// ---- diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol new file mode 100644 index 00000000..1c033a69 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol @@ -0,0 +1,5 @@ +contract test { + function f(bytes storage) public; +} +// ---- +// TypeError: (31-44): Data location must be "memory" for parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_parameters_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_parameters_no_data_location.sol new file mode 100644 index 00000000..f76bd631 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_parameters_no_data_location.sol @@ -0,0 +1,5 @@ +contract C { + function h(uint[]) public pure {} +} +// ---- +// TypeError: (28-34): Data location must be "memory" for parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_return_parameters_no_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_return_parameters_no_data_location.sol new file mode 100644 index 00000000..6b087c34 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_return_parameters_no_data_location.sol @@ -0,0 +1,5 @@ +contract C { + function h() public pure returns(uint[]) {} +} +// ---- +// TypeError: (50-56): Data location must be "memory" for return parameter in function, but none was given. 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 new file mode 100644 index 00000000..5f6daf68 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol @@ -0,0 +1,13 @@ +contract test { + function f() public { + uint storage a1; + bytes16 storage b1; + uint memory a2; + bytes16 memory b2; + } +} +// ---- +// TypeError: (48-63): Data location can only be specified for array, struct or mapping types, but "storage" was given. +// TypeError: (71-89): Data location can only be specified for array, struct or mapping types, but "storage" was given. +// TypeError: (97-111): Data location can only be specified for array, struct or mapping types, but "memory" was given. +// TypeError: (119-136): Data location can only be specified for array, struct or mapping types, but "memory" was given. diff --git a/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol new file mode 100644 index 00000000..0fbad155 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol @@ -0,0 +1,13 @@ +contract test { + uint[] a; + uint[] b; + function f() public { + uint[] storage s1 = a; + uint[] memory s2 = new uint[](42); + uint[] storage s3 = b; + s1.push(42); + s2[3] = 12; + s3.push(42); + } +} +// ---- 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/emit_non_event.sol b/test/libsolidity/syntaxTests/emit/emit_non_event.sol index 1df6990d..d5045ddf 100644 --- a/test/libsolidity/syntaxTests/emit/emit_non_event.sol +++ b/test/libsolidity/syntaxTests/emit/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/events/event_array_indexed_v2.sol b/test/libsolidity/syntaxTests/events/event_array_indexed_v2.sol index aaf6028a..3f729a6a 100644 --- a/test/libsolidity/syntaxTests/events/event_array_indexed_v2.sol +++ b/test/libsolidity/syntaxTests/events/event_array_indexed_v2.sol @@ -4,4 +4,4 @@ contract c { } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// TypeError: (59-65): Indexed reference types cannot yet be used with ABIEncoderV2. +// TypeError: (59-73): Indexed reference types cannot yet be used with ABIEncoderV2. diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_indexed_v2.sol b/test/libsolidity/syntaxTests/events/event_nested_array_indexed_v2.sol index ffae5b9c..f05b884e 100644 --- a/test/libsolidity/syntaxTests/events/event_nested_array_indexed_v2.sol +++ b/test/libsolidity/syntaxTests/events/event_nested_array_indexed_v2.sol @@ -4,4 +4,4 @@ contract c { } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// TypeError: (59-67): Indexed reference types cannot yet be used with ABIEncoderV2. +// TypeError: (59-75): Indexed reference types cannot yet be used with ABIEncoderV2. diff --git a/test/libsolidity/syntaxTests/events/event_struct_indexed.sol b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol index 69ee5017..7332cb3b 100644 --- a/test/libsolidity/syntaxTests/events/event_struct_indexed.sol +++ b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol @@ -3,4 +3,4 @@ contract c { event E(S indexed); } // ---- -// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// 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/events/event_struct_indexed_v2.sol b/test/libsolidity/syntaxTests/events/event_struct_indexed_v2.sol index a8e0837f..a1d8cf04 100644 --- a/test/libsolidity/syntaxTests/events/event_struct_indexed_v2.sol +++ b/test/libsolidity/syntaxTests/events/event_struct_indexed_v2.sol @@ -5,4 +5,4 @@ contract c { } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// TypeError: (85-86): Indexed reference types cannot yet be used with ABIEncoderV2. +// TypeError: (85-94): Indexed reference types cannot yet be used with ABIEncoderV2. diff --git a/test/libsolidity/syntaxTests/fallback/default_visibility.sol b/test/libsolidity/syntaxTests/fallback/default_visibility.sol new file mode 100644 index 00000000..6fbb15a5 --- /dev/null +++ b/test/libsolidity/syntaxTests/fallback/default_visibility.sol @@ -0,0 +1,7 @@ +contract C { + // Check that visibility is also enforced for the fallback function. + function() {} +} +// ---- +// SyntaxError: (90-103): No visibility specified. Did you intend to add "external"? +// TypeError: (90-103): Fallback function must be defined as "external". 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/functionCalls/named_arguments_for_functions_that_take_arbitrary_parameters.sol b/test/libsolidity/syntaxTests/functionCalls/named_arguments_for_functions_that_take_arbitrary_parameters.sol new file mode 100644 index 00000000..089e1dbf --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/named_arguments_for_functions_that_take_arbitrary_parameters.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + abi.encodeWithSelector({selector:"abc"}); + } +} +// ---- +// TypeError: (52-92): Named arguments cannot be used for functions that take arbitrary parameters. 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/external_function_to_function_type_calldata_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol index eb4f0693..f22afe5e 100644 --- a/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol @@ -3,7 +3,7 @@ // when converting to a function type. contract C { function f(function(bytes memory) pure external /*g*/) pure public { } - function callback(bytes) pure external {} + function callback(bytes calldata) pure external {} function g() view public { f(this.callback); } diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol new file mode 100644 index 00000000..adffb14b --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view returns (address payable) { + return address(this.f); + } +} +// ---- +// TypeError: (85-100): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol index 95ebc179..51f0b10d 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. +// SyntaxError: (83-106): Functions without implementation cannot have modifiers. +// DeclarationError: (104-105): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol index b89a3bb4..42697b73 100644 --- a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// ParserError: (118-119): Expected ';' but got identifier +// ParserError: (104-115): Expected primary expression. 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..92ec4eb7 --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol @@ -0,0 +1,17 @@ +contract C { + function f() public { + (bool success,) = address(this).call(); + require(success); + (success,) = address(this).call(bytes4(0x12345678)); + require(success); + (success,) = address(this).call(uint(1)); + require(success); + (success,) = address(this).call(uint(1), uint(2)); + require(success); + } +} +// ---- +// TypeError: (65-85): 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: (153-171): 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: (240-247): 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: (297-333): 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..655d5f4c --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol @@ -0,0 +1,14 @@ +contract C { + function f() public { + (bool success,) = address(this).callcode(); + require(success); + (success,) = address(this).callcode(uint(1)); + require(success); + (success,) = address(this).callcode(uint(1), uint(2)); + require(success); + } +} +// ---- +// TypeError: (65-89): 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: (161-168): 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: (218-258): 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..fa524b99 --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol @@ -0,0 +1,14 @@ +contract C { + function f() public { + (bool success,) = address(this).delegatecall(); + require(success); + (success,) = address(this).delegatecall(uint(1)); + require(success); + (success,) = address(this).delegatecall(uint(1), uint(2)); + require(success); + } +} +// ---- +// TypeError: (65-93): 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: (169-176): 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: (226-270): 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/indexing/array_multidim_rational.sol b/test/libsolidity/syntaxTests/indexing/array_multidim_rational.sol new file mode 100644 index 00000000..df9f8223 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/array_multidim_rational.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + bytes[32] memory a; + a[8**90][8**90][8**90*0.1]; + } +} +// ---- +// TypeError: (67-72): Type int_const 1897...(74 digits omitted)...1424 is not implicitly convertible to expected type uint256. +// TypeError: (74-79): Type int_const 1897...(74 digits omitted)...1424 is not implicitly convertible to expected type uint256. +// TypeError: (81-90): Type rational_const 9485...(73 digits omitted)...5712 / 5 is not implicitly convertible to expected type uint256. +// TypeError: (65-91): Index expression cannot be represented as an unsigned integer. diff --git a/test/libsolidity/syntaxTests/indexing/array_multim_overflow_index.sol b/test/libsolidity/syntaxTests/indexing/array_multim_overflow_index.sol new file mode 100644 index 00000000..9c98ad45 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/array_multim_overflow_index.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + bytes[32] memory a; + a[8**90][8**90][1 - 8**90]; + } +} +// ---- +// TypeError: (67-72): Type int_const 1897...(74 digits omitted)...1424 is not implicitly convertible to expected type uint256. +// TypeError: (74-79): Type int_const 1897...(74 digits omitted)...1424 is not implicitly convertible to expected type uint256. +// TypeError: (81-90): Type int_const -189...(75 digits omitted)...1423 is not implicitly convertible to expected type uint256. +// TypeError: (65-91): Index expression cannot be represented as an unsigned integer. diff --git a/test/libsolidity/syntaxTests/indexing/array_negative_index.sol b/test/libsolidity/syntaxTests/indexing/array_negative_index.sol new file mode 100644 index 00000000..019d023b --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/array_negative_index.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + bytes[32] memory a; + a[-1]; + } +} +// ---- +// TypeError: (67-69): Type int_const -1 is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/indexing/array_noninteger_index.sol b/test/libsolidity/syntaxTests/indexing/array_noninteger_index.sol new file mode 100644 index 00000000..7c0ac9fe --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/array_noninteger_index.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + bytes[32] memory a; + a[888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888]; + } +} +// ---- +// TypeError: (67-178): Type int_const 8888...(103 digits omitted)...8888 is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/indexing/array_out_of_bounds_index.sol b/test/libsolidity/syntaxTests/indexing/array_out_of_bounds_index.sol new file mode 100644 index 00000000..b0079857 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/array_out_of_bounds_index.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + bytes[32] memory a; + a[64]; + } +} +// ---- +// TypeError: (65-70): Out of bounds array access. diff --git a/test/libsolidity/syntaxTests/indexing/array_without_index.sol b/test/libsolidity/syntaxTests/indexing/array_without_index.sol new file mode 100644 index 00000000..6b1c2778 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/array_without_index.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + bytes memory a; + a[]; + } +} +// ---- +// TypeError: (61-64): Index expression cannot be omitted. diff --git a/test/libsolidity/syntaxTests/indexing/fixedbytes_negative_index.sol b/test/libsolidity/syntaxTests/indexing/fixedbytes_negative_index.sol new file mode 100644 index 00000000..12399317 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/fixedbytes_negative_index.sol @@ -0,0 +1,9 @@ +contract C { + function f() public { + bytes32 b; + b[-1]; + } +} +// ---- +// TypeError: (58-60): Type int_const -1 is not implicitly convertible to expected type uint256. +// TypeError: (56-61): Index expression cannot be represented as an unsigned integer. diff --git a/test/libsolidity/syntaxTests/indexing/fixedbytes_noninteger_index.sol b/test/libsolidity/syntaxTests/indexing/fixedbytes_noninteger_index.sol new file mode 100644 index 00000000..adf7db61 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/fixedbytes_noninteger_index.sol @@ -0,0 +1,9 @@ +contract C { + function f() public { + bytes32 b; + b[888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888]; + } +} +// ---- +// TypeError: (58-169): Type int_const 8888...(103 digits omitted)...8888 is not implicitly convertible to expected type uint256. +// TypeError: (56-170): Index expression cannot be represented as an unsigned integer. diff --git a/test/libsolidity/syntaxTests/indexing/fixedbytes_out_of_bounds_index.sol b/test/libsolidity/syntaxTests/indexing/fixedbytes_out_of_bounds_index.sol new file mode 100644 index 00000000..8264a8b2 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/fixedbytes_out_of_bounds_index.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + bytes32 b; + b[64]; + } +} +// ---- +// TypeError: (56-61): Out of bounds array access. diff --git a/test/libsolidity/syntaxTests/indexing/fixedbytes_without_index.sol b/test/libsolidity/syntaxTests/indexing/fixedbytes_without_index.sol new file mode 100644 index 00000000..979ac8a7 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/fixedbytes_without_index.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + bytes32 b; + b[]; + } +} +// ---- +// TypeError: (56-59): Index expression cannot be omitted. diff --git a/test/libsolidity/syntaxTests/indexing/function_type.sol b/test/libsolidity/syntaxTests/indexing/function_type.sol new file mode 100644 index 00000000..6c6c06a9 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/function_type.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + f[0]; + } +} +// ---- +// TypeError: (41-42): Indexed expression has to be a type, mapping or array (is function ()) diff --git a/test/libsolidity/syntaxTests/indexing/function_type_without_index.sol b/test/libsolidity/syntaxTests/indexing/function_type_without_index.sol new file mode 100644 index 00000000..bf511bc9 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/function_type_without_index.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + f[]; + } +} +// ---- +// TypeError: (41-42): Indexed expression has to be a type, mapping or array (is function ()) diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol index 0b18b995..692b1827 100644 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol @@ -4,4 +4,4 @@ contract Base { contract Derived is Base(2) { } contract Derived2 is Base(), Derived() { } // ---- -// Warning: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1. +// TypeError: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1. Remove parentheses if you do not want to provide arguments here. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol deleted file mode 100644 index db04ab8c..00000000 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol +++ /dev/null @@ -1,9 +0,0 @@ -pragma experimental "v0.5.0"; - -contract Base { - constructor(uint) public {} -} -contract Derived is Base(2) { } -contract Derived2 is Base(), Derived() { } -// ---- -// TypeError: (132-138): Wrong argument count for constructor call: 0 arguments given but expected 1. 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/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol index 6cf68d2a..8f5ceef8 100644 --- a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol @@ -1,4 +1,4 @@ contract A { constructor() public { } } contract B is A { constructor() A public { } } // ---- -// Warning: (72-73): Modifier-style base constructor call without arguments. +// DeclarationError: (72-73): Modifier-style base constructor call without arguments. 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/ancestor_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol deleted file mode 100644 index 8d5df5bf..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol +++ /dev/null @@ -1,7 +0,0 @@ -pragma experimental "v0.5.0"; - -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() public { } } -contract C is B { constructor() A(3) public { } } -// ---- -// DeclarationError: (156-160): 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_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol deleted file mode 100644 index f9325f99..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; - -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() A(3) public { } } -// ---- -// DeclarationError: (110-114): 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/modifiers_in_constructor_context.sol b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol new file mode 100644 index 00000000..d8ce0e48 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol @@ -0,0 +1,9 @@ +// This generated an invalid warning on m1 in some compiler versions. +contract A { + constructor() m1 public { } + modifier m1 { _; } +} +contract B is A { + modifier m2 { _; } + constructor() A() m1 m2 public { } +} 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/function_state_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol new file mode 100644 index 00000000..023a161a --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol @@ -0,0 +1,2 @@ +interface ERC20 { function x() external returns (uint); } +contract C is ERC20 { uint public x; } 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/inheritance/override/state_variable_function.sol b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol new file mode 100644 index 00000000..0f05cc8e --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol @@ -0,0 +1,8 @@ +contract A { + uint public x; +} +contract C is A { + function x() public returns (uint); +} +// ---- +// DeclarationError: (50-85): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol index c55c41f2..1ce48200 100644 --- a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol +++ b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol @@ -6,5 +6,5 @@ contract Derived2 is Base { constructor() Base(2) public { } } // ---- -// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2. +// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2. Remove parentheses if you do not want to provide arguments here. // TypeError: (130-137): Wrong argument count for modifier invocation: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol new file mode 100644 index 00000000..a87a3e66 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + let x := C + } + } +} +// ---- +// TypeError: (72-73): Expected a library. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol new file mode 100644 index 00000000..ecda3e99 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + assembly { + let x := f + } + } +} diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol new file mode 100644 index 00000000..3c551c18 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol @@ -0,0 +1,10 @@ +library L { +} + +contract C { + function f() public pure { + assembly { + let x := L + } + } +} diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol new file mode 100644 index 00000000..bd5562d5 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + let x := super + } + } +} +// ---- +// DeclarationError: (72-77): Identifier not found. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol new file mode 100644 index 00000000..db28e507 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol @@ -0,0 +1,13 @@ +contract C { + function f() public { + assembly { + super := 1 + f := 1 + C := 1 + } + } +} +// ---- +// TypeError: (58-63): Only local variables can be assigned to in inline assembly. +// TypeError: (75-76): Only local variables can be assigned to in inline assembly. +// TypeError: (88-89): Only local variables can be assigned to in inline assembly. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol new file mode 100644 index 00000000..ac1f541e --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol @@ -0,0 +1,16 @@ +contract C { + function f() public pure { + assembly { + function f(a) {} + + f() + f(1) + f(1, 2) + } + } +} +// ---- +// TypeError: (87-88): Expected 1 arguments but got 0. +// SyntaxError: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them. +// TypeError: (108-109): Expected 1 arguments but got 2. +// SyntaxError: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_not_found.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_not_found.sol new file mode 100644 index 00000000..57534bd6 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_not_found.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + k() + } + } +} +// ---- +// DeclarationError: (63-64): Function not found. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol new file mode 100644 index 00000000..150fb938 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + assembly { + l: + + l() + } + } +} +// ---- +// SyntaxError: (63-64): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead. +// SyntaxError: (63-64): 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: (73-74): Attempt to call label instead of function. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_variable.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_variable.sol new file mode 100644 index 00000000..c0071855 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_variable.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + assembly { + let x := 1 + + x() + } + } +} +// ---- +// TypeError: (81-82): Attempt to call variable instead of function. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_without_call.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_without_call.sol new file mode 100644 index 00000000..8557e2fa --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_without_call.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + assembly { + function k() {} + + k + } + } +} +// ---- +// TypeError: (86-87): Function k used without being called. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_fun_arg.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_fun_arg.sol new file mode 100644 index 00000000..e05277de --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_fun_arg.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + assembly { + function f(a, b) {} + f() + f(1,) + f(,1) + } + } +} +// ---- +// ParserError: (113-114): Literal, identifier or instruction expected. +// ParserError: (113-114): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_function_name.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_function_name.sol new file mode 100644 index 00000000..17995b09 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_function_name.sol @@ -0,0 +1,10 @@ +contract C { + function f() public pure { + assembly { + function (a, b) {} + } + } +} +// ---- +// ParserError: (72-73): Expected identifier but got '(' +// ParserError: (79-80): Expected ';' but got '{' diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol new file mode 100644 index 00000000..715913de --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol @@ -0,0 +1,10 @@ +contract C { + function f() public pure { + assembly { + let x := 0100 + } + } +} +// ---- +// ParserError: (72-73): Literal, identifier or instruction expected. +// ParserError: (72-73): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/missing_variable_in_assign.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/missing_variable_in_assign.sol new file mode 100644 index 00000000..c8984333 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/missing_variable_in_assign.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + assembly { + let x := mload(0) + := 1 + } + } +} +// ---- +// ParserError: (87-88): Literal, identifier or instruction expected. +// ParserError: (87-88): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol new file mode 100644 index 00000000..d1bcc946 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol @@ -0,0 +1,11 @@ +contract C { + function f() pure public {} + function f(address) pure public {} + function g() pure public { + assembly { + let x := f + } + } +} +// ---- +// DeclarationError: (155-156): Multiple matching identifiers. Resolving overloaded identifiers is not supported. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol new file mode 100644 index 00000000..07113093 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -0,0 +1,11 @@ +contract C { + uint[] x; + function() external { + uint[] storage y = x; + assembly { + pop(y) + } + } +} +// ---- +// TypeError: (118-119): You have to use the _slot or _offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol new file mode 100644 index 00000000..dc742142 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol @@ -0,0 +1,13 @@ +contract C { + uint[] x; + function() external { + uint[] storage y = x; + assembly { + y_slot := 1 + y_offset := 2 + } + } +} +// ---- +// TypeError: (114-120): Storage variables cannot be assigned to. +// TypeError: (138-146): Storage variables cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol new file mode 100644 index 00000000..ec23a263 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + _offset + } + } +} +// ---- +// DeclarationError: (75-82): In variable names _slot and _offset can only be used as a suffix. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol new file mode 100644 index 00000000..d493a68a --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + _slot + } + } +} +// ---- +// DeclarationError: (75-80): In variable names _slot and _offset can only be used as a suffix. 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..b01a7705 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -0,0 +1,11 @@ +contract C { + uint[] x; + function() external { + uint[] storage y = x; + assembly { + pop(y_slot) + pop(y_offset) + } + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol new file mode 100644 index 00000000..9165654f --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol @@ -0,0 +1,9 @@ +contract C { + function f() pure public { + assembly { + let x := f_slot + } + } +} +// ---- +// TypeError: (84-90): The suffixes _offset and _slot can only be used on storage variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol new file mode 100644 index 00000000..704b712d --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol @@ -0,0 +1,13 @@ +contract C { + uint[] x; + function() external { + uint[] memory y = x; + assembly { + pop(y_slot) + pop(y_offset) + } + } +} +// ---- +// TypeError: (117-123): The suffixes _offset and _slot can only be used on storage variables. +// TypeError: (141-149): The suffixes _offset and _slot can only be used on storage variables. 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..d8f2eadd 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/memberLookup/msg_value_modifier_payable.sol b/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_payable.sol new file mode 100644 index 00000000..6e93626f --- /dev/null +++ b/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_payable.sol @@ -0,0 +1,4 @@ +contract C { + modifier costs(uint _amount) { require(msg.value >= _amount); _; } + function f() costs(1 ether) public payable {} +} diff --git a/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_pure.sol b/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_pure.sol new file mode 100644 index 00000000..398c127d --- /dev/null +++ b/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_pure.sol @@ -0,0 +1,6 @@ +contract C { + modifier costs(uint _amount) { require(msg.value >= _amount); _; } + function f() costs(1 ether) public pure {} +} +// ---- +// TypeError: (101-115): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". diff --git a/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_view.sol b/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_view.sol new file mode 100644 index 00000000..8430c5c3 --- /dev/null +++ b/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_view.sol @@ -0,0 +1,6 @@ +contract C { + modifier costs(uint _amount) { require(msg.value >= _amount); _; } + function f() costs(1 ether) public view {} +} +// ---- +// TypeError: (101-115): This modifier uses "msg.value" and thus the function has to be payable or internal. diff --git a/test/libsolidity/syntaxTests/missing_state_variable.sol b/test/libsolidity/syntaxTests/missing_state_variable.sol index 02082a45..8b97220c 100644 --- a/test/libsolidity/syntaxTests/missing_state_variable.sol +++ b/test/libsolidity/syntaxTests/missing_state_variable.sol @@ -4,4 +4,4 @@ contract Scope { } } // ---- -// TypeError: (101-115): Member "stateVar" not found or not visible after argument-dependent lookup in type(contract Scope) +// TypeError: (101-115): Member "stateVar" not found or not visible after argument-dependent lookup in type(contract Scope). 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/modifiers/modifiers_on_abstract_functions_050.sol b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol deleted file mode 100644 index af1babbc..00000000 --- a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma experimental "v0.5.0"; -contract C -{ - modifier only_owner() { _; } - function foo() only_owner public; - function bar() public only_owner; -} -// ---- -// SyntaxError: (80-113): Functions without implementation cannot have modifiers. -// SyntaxError: (118-151): Functions without implementation cannot have modifiers. diff --git a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_no_parser_error.sol b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_no_parser_error.sol index e18c5cf9..2e86fcc1 100644 --- a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_no_parser_error.sol +++ b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_no_parser_error.sol @@ -9,5 +9,5 @@ contract C function bar() public only_owner; } // ---- -// Warning: (203-236): Modifiers of functions without implementation are ignored. -// Warning: (241-274): Modifiers of functions without implementation are ignored. +// SyntaxError: (203-236): Functions without implementation cannot have modifiers. +// SyntaxError: (241-274): Functions without implementation cannot have modifiers. 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/differentNumberOfComponents.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/differentNumberOfComponents.sol new file mode 100644 index 00000000..3b05a54c --- /dev/null +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/differentNumberOfComponents.sol @@ -0,0 +1,25 @@ +contract C { + function f() public { + uint a = (1,2); + uint b = (1,2,3); + uint c = (1,2,3,4); + } + function g() public { + (uint a1, uint b1, uint c1, uint d1) = 1; + (uint a2, uint b2, uint c2) = 1; + (uint a3, uint b3) = 1; + } + function h() public { + (uint a1, uint b1, uint c1, uint d1) = (1,2,3); + (uint a2, uint b2, uint c2) = (1,2,3,4); + } +} +// ---- +// TypeError: (47-61): Different number of components on the left hand side (1) than on the right hand side (2). +// TypeError: (71-87): Different number of components on the left hand side (1) than on the right hand side (3). +// TypeError: (97-115): Different number of components on the left hand side (1) than on the right hand side (4). +// TypeError: (157-197): Different number of components on the left hand side (4) than on the right hand side (1). +// TypeError: (207-238): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (248-270): Different number of components on the left hand side (2) than on the right hand side (1). +// TypeError: (312-358): Different number of components on the left hand side (4) than on the right hand side (3). +// TypeError: (368-407): Different number of components on the left hand side (3) than on the right hand side (4). diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/differentNumberOfComponentsFromReturn.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/differentNumberOfComponentsFromReturn.sol new file mode 100644 index 00000000..7b556350 --- /dev/null +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/differentNumberOfComponentsFromReturn.sol @@ -0,0 +1,29 @@ +contract C { + function f() public { + uint a = two(); + uint b = three(); + uint c = four(); + } + function g() public { + (uint a1, uint b1, uint c1, uint d1) = one(); + (uint a2, uint b2, uint c2) = one(); + (uint a3, uint b3) = one(); + } + function h() public { + (uint a1, uint b1, uint c1, uint d1) = three(); + (uint a2, uint b2, uint c2) = four(); + } + function one() public pure returns (uint); + function two() public pure returns (uint, uint); + function three() public pure returns (uint, uint, uint); + function four() public pure returns (uint, uint, uint, uint); +} +// ---- +// TypeError: (47-61): Different number of components on the left hand side (1) than on the right hand side (2). +// TypeError: (71-87): Different number of components on the left hand side (1) than on the right hand side (3). +// TypeError: (97-112): Different number of components on the left hand side (1) than on the right hand side (4). +// TypeError: (154-198): Different number of components on the left hand side (4) than on the right hand side (1). +// TypeError: (208-243): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (253-279): Different number of components on the left hand side (2) than on the right hand side (1). +// TypeError: (321-367): Different number of components on the left hand side (4) than on the right hand side (3). +// TypeError: (377-413): Different number of components on the left hand side (3) than on the right hand side (4). diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/disallowWildcards.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/disallowWildcards.sol new file mode 100644 index 00000000..b500823d --- /dev/null +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/disallowWildcards.sol @@ -0,0 +1,24 @@ +contract C { + function fn() public pure { + (uint a,) = (1,2,3); + (,uint b) = (1,2,3); + (,uint c,) = (1,2,3,4,5); + (uint d, uint e,) = (1,2,3,4); + (,uint f, uint g) = (1,2,3,4); + (,uint h, uint i,) = (1,2,3); + (uint j,) = 1; + (,uint k) = 1; + (,uint l,) = 1; + a;b;c;d;e;f;g;h;i;j;k;l; + } +} +// ---- +// TypeError: (53-72): Different number of components on the left hand side (2) than on the right hand side (3). +// TypeError: (82-101): Different number of components on the left hand side (2) than on the right hand side (3). +// TypeError: (111-135): Different number of components on the left hand side (3) than on the right hand side (5). +// TypeError: (145-174): Different number of components on the left hand side (3) than on the right hand side (4). +// TypeError: (184-213): Different number of components on the left hand side (3) than on the right hand side (4). +// TypeError: (223-251): Different number of components on the left hand side (4) than on the right hand side (3). +// TypeError: (261-274): Different number of components on the left hand side (2) than on the right hand side (1). +// TypeError: (284-297): Different number of components on the left hand side (2) than on the right hand side (1). +// TypeError: (307-321): Different number of components on the left hand side (3) than on the right hand side (1). diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/disallowWildcardsFromReturn.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/disallowWildcardsFromReturn.sol new file mode 100644 index 00000000..3224a182 --- /dev/null +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/disallowWildcardsFromReturn.sol @@ -0,0 +1,31 @@ +contract C { + function fn() public pure { + (uint a,) = three(); + (,uint b) = three(); + (,uint c,) = five(); + (uint d, uint e,) = four(); + (,uint f, uint g) = four(); + (,uint h, uint i,) = three(); + (uint j,) = one(); + (,uint k) = one(); + (,uint l,) = one(); + (,uint m, uint n,) = five(); + a;b;c;d;e;f;g;h;i;j;k;l;m;n; + } + function one() public pure returns (uint); + function two() public pure returns (uint, uint); + function three() public pure returns (uint, uint, uint); + function four() public pure returns (uint, uint, uint, uint); + function five() public pure returns (uint, uint, uint, uint, uint); +} +// ---- +// TypeError: (53-72): Different number of components on the left hand side (2) than on the right hand side (3). +// TypeError: (82-101): Different number of components on the left hand side (2) than on the right hand side (3). +// TypeError: (111-130): Different number of components on the left hand side (3) than on the right hand side (5). +// TypeError: (140-166): Different number of components on the left hand side (3) than on the right hand side (4). +// TypeError: (176-202): Different number of components on the left hand side (3) than on the right hand side (4). +// TypeError: (212-240): Different number of components on the left hand side (4) than on the right hand side (3). +// TypeError: (250-267): Different number of components on the left hand side (2) than on the right hand side (1). +// TypeError: (277-294): Different number of components on the left hand side (2) than on the right hand side (1). +// TypeError: (304-322): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (332-359): Different number of components on the left hand side (4) than on the right hand side (5). diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol index 182ba072..7db98577 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol @@ -3,4 +3,4 @@ contract C { (uint a) = f(); a; } -} +} diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationComplex.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationComplex.sol index a3ce6a74..ba6e9916 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationComplex.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationComplex.sol @@ -2,10 +2,10 @@ contract D { struct S { uint a; uint b; } } contract C { - function f() internal returns (uint, uint, uint, D.S[20] storage, uint) { - (,,,D.S[10*2] storage x,) = f(); + function f() internal pure { + (,,,D.S[10*2] storage x,) = g(); x; } -} + function g() internal pure returns (uint, uint, uint, D.S[20] storage x, uint) { x = x; } +} // ---- -// Warning: (110-117): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationEmpty.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationEmpty.sol new file mode 100644 index 00000000..9618958e --- /dev/null +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationEmpty.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + (uint a, uint b) = f(); + (uint c) = f(); + uint d = f(); + } +} +// ---- +// TypeError: (52-74): Different number of components on the left hand side (2) than on the right hand side (0). +// TypeError: (84-98): Different number of components on the left hand side (1) than on the right hand side (0). +// TypeError: (108-120): Different number of components on the left hand side (1) than on the right hand side (0). 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/multiVariableDeclarationInvalidType.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol index 2b765837..85094d00 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol @@ -3,7 +3,7 @@ contract C { (uint a, string memory b,,) = f(); a; b; } -} +} // ---- // TypeError: (85-118): Type string memory is not implicitly convertible to expected type uint256. // TypeError: (85-118): Type uint256 is not implicitly convertible to expected type string memory. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol index 3ba85f69..1f9e52d1 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 { { @@ -7,6 +5,6 @@ contract C { } a; } -} +} // ---- -// 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..45b8858b 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol @@ -1,13 +1,11 @@ -pragma experimental "v0.5.0"; - contract C { function f() internal { { (uint a, uint b, uint c) = (a, b, 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/multiVariableDeclaration/multiVariableDeclarationSimple.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationSimple.sol index 8e06322c..a2fcce18 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationSimple.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationSimple.sol @@ -1,12 +1,12 @@ contract C { - function f() internal returns (uint, uint, uint, uint) { + function f() internal pure returns (uint, uint, uint, uint) { (uint a, uint b,,) = f(); a; b; } - function g() internal returns (bytes memory, string storage) { - (bytes memory a, string storage b) = g(); + function g() internal pure { + (bytes memory a, string storage b) = h(); a; b; } -} + function h() internal pure returns (bytes memory, string storage s) { s = s; } +} // ---- -// Warning: (163-169): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol index 8ae0eaac..00458908 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol @@ -4,6 +4,6 @@ contract C { function f() internal pure returns (uint, uint, uint, S storage, uint, uint) { (,,,s.x[2](),,) = f(); } -} +} // ---- // TypeError: (160-168): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/oneElementTuple.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/oneElementTuple.sol new file mode 100644 index 00000000..562c7c0b --- /dev/null +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/oneElementTuple.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + (uint a,) = (1,); + a; + } +} +// ---- +// TypeError: (59-63): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/sameNumberOfComponents.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/sameNumberOfComponents.sol new file mode 100644 index 00000000..59eb34af --- /dev/null +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/sameNumberOfComponents.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + (uint a1, uint b1, uint c1, uint d1) = (1,2,3,4); + (uint a2, uint b2, uint c2) = (1,2,3); + (uint a3, uint b3) = (1,2); + a1; b1; c1; d1; a2; b2; c2; a3; b3; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/multiline_comments.sol b/test/libsolidity/syntaxTests/multiline_comments.sol new file mode 100644 index 00000000..480fde6c --- /dev/null +++ b/test/libsolidity/syntaxTests/multiline_comments.sol @@ -0,0 +1,13 @@ +/* + * This is a multi-line comment + * it should create no problems + * +*/ + +contract test { + /* + * this is another multi-line comment + * + */ +} +// ---- 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/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..b15666c0 --- /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) storage y = x; + return x == y; + } +} +// ---- +// TypeError: (147-153): 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..3389ffe4 --- /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 memory) public pure {} + function f(S2 memory) public pure {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (143-179): 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..6ff8fd6e --- /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 memory) public pure {} + function f(S2 memory) public pure {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
\ No newline at end of file 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..73b608ae --- /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 memory) public {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (103-111): 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..607a4a68 --- /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 memory) public {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (105-113): 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..da73d8dd --- /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 memory) public {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (132-140): 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..ae9416e5 --- /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[][] memory) {} +} +// ---- +// 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..b9a64c2a --- /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[][] memory) {} +} +// ---- +// TypeError: (51-68): 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..ccee6093 --- /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] memory) {} +} +// ---- +// TypeError: (51-67): 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..8ca3a53d --- /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 memory) {} +} +// ---- +// 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..48e80fcf --- /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 memory x) {} +} +// ---- +// TypeError: (80-90): 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..544df1a5 --- /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..dd73ac47 --- /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..f2de6e72 --- /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..60d7b758 --- /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..8c9d0c0f --- /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..88402fa3 --- /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 "a". 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..ba05fcb3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol @@ -0,0 +1,7 @@ +contract test { + function f(uint[] memory constant a) public { } +} +// ---- +// DeclarationError: (31-55): The "constant" keyword can only be used for state variables. +// TypeError: (31-55): Constants of non-value type not yet implemented. +// TypeError: (31-55): 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..e58ed160 --- /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..2f94ef92 --- /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..cf680462 --- /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..bc1c4267 --- /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 calldata) external returns (uint256 r) {r = 1;} +} +contract Bike is Vehicle { + function f(bytes calldata) external returns (uint256 r) {r = 42;} +} +// ---- +// Warning: (23-87): 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/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/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..0f67460f --- /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 memory". 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..845b9156 --- /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..22d515ea --- /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): Data location must be "calldata" for parameter in external function, but "memory" was given. 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..3825809c --- /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): Data location must be "calldata" for parameter in external function, but "storage" was given. 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..cf303772 --- /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[] memory x) public { + uint[] storage dataRef = data; + dataRef = x; + } +} +// ---- +// TypeError: (128-129): 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..0547ace1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol @@ -0,0 +1,8 @@ +contract C { + function f() public { + mapping(uint => uint) storage x; + x; + } +} +// ---- +// TypeError: (47-78): 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..801eb275 --- /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[] memory 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..984b81b1 --- /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[] memory x) public { + f(x); + } +} +// ---- +// TypeError: (113-114): 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..c5175a41 --- /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[] memory x) public { + } +} +// ---- +// Warning: (91-106): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (80-122): 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..ed6a9b37 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/224_string_bytes_conversion.sol @@ -0,0 +1,11 @@ +contract Test { + string s; + bytes b; + function h(string calldata _s) pure external { bytes(_s).length; } + function i(string memory _s) pure internal { bytes(_s).length; } + function j() view internal { bytes(s).length; } + function k(bytes calldata _b) pure external { string(_b); } + function l(bytes memory _b) pure internal { string(_b); } + function m() view internal { string(b); } +} +// ---- 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..be57144e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/232_literal_string_to_storage_pointer.sol @@ -0,0 +1,5 @@ +contract C { + function f() public { string storage x = "abc"; } +} +// ---- +// TypeError: (39-63): 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/244_tuples.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol new file mode 100644 index 00000000..d18c115d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol @@ -0,0 +1,10 @@ +contract C { + function f() public pure { + uint a = (1); + (uint b,) = (uint8(1),2); + (uint c, uint d) = (uint32(1), 2 + a); + (uint e, ,) = (uint64(1), 2, b); + a;b;c;d;e; + } +} +// ---- 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/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..0ab3c198 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/250_member_access_parser_ambiguity.sol @@ -0,0 +1,16 @@ +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 storage 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; + z; + } +} +// ---- 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..c60ee651 --- /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..b11cefba --- /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..20d8afa5 --- /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 memory) {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// Warning: (75-116): 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..b2b55350 --- /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..e45e09de --- /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) storage x = new mapping(uint => uint)[](4); + } +} +// ---- +// TypeError: (94-117): 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..4fc9d46e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol @@ -0,0 +1,4 @@ +contract M { + function f(uint[] memory) public; + function f(int[] memory) 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..025244d3 --- /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 memory) { + string memory x = "Hello"; + string memory y = "World"; + string[2] memory z = [x, y]; + return (z[0]); + } +} +// ---- +// Warning: (17-198): 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..4e92f6e1 --- /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 memory) { + string[2] memory z = ["Hello", "World"]; + return (z[0]); + } +} +// ---- +// Warning: (17-140): 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..6d36942d --- /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 memory) { + return (["foo", "man", "choo"][1]); + } +} +// ---- +// Warning: (17-112): 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..03d7266a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + uint[3] memory x = [45, 'foo', true]; + } +} +// ---- +// TypeError: (66-83): 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..e9ab08ba --- /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) storage 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_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol new file mode 100644 index 00000000..0d0a0797 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + uintM something = 3; + } +} +// ---- +// DeclarationError: (50-55): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol new file mode 100644 index 00000000..b9590a8c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + intM should = 4; + } +} +// ---- +// DeclarationError: (50-54): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol new file mode 100644 index 00000000..85d4c25b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + bytesM fail = "now"; + } +} +// ---- +// DeclarationError: (50-56): 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..dcf11a6e --- /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..f635a214 --- /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; + } +} +// ---- +// SyntaxError: (70-75): Use of unary + is disallowed. 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/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..3d9bc3fc --- /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..e9599f4b --- /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 + } + } +} +// ---- +// SyntaxError: (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..342afc46 --- /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 + } + } +} +// ---- +// SyntaxError: (73-76): The use of non-functional instructions is disallowed. 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..ca1e15a9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol @@ -0,0 +1,8 @@ +contract c { + uint8 x; + function f() public { + assembly { pop(x) } + } +} +// ---- +// TypeError: (75-76): 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..0032f99e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol @@ -0,0 +1,13 @@ +contract test { + modifier m { + uint a = 1; + assembly { + a := 2 + } + _; + } + function f() public m { + } +} +// ---- +// Warning: (122-151): 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..3dfb458a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol @@ -0,0 +1,10 @@ +contract test { + uint x = 1; + function f() public { + assembly { + x := 2 + } + } +} +// ---- +// TypeError: (89-90): 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..b9b92d47 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol @@ -0,0 +1,13 @@ +contract test { + uint x = 1; + modifier m { + assembly { + x := 2 + } + _; + } + function f() public m { + } +} +// ---- +// TypeError: (80-81): 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..c8928804 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol @@ -0,0 +1,10 @@ +contract test { + uint constant x = 1; + function f() public { + assembly { + x := 2 + } + } +} +// ---- +// TypeError: (98-99): 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..03ff9166 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol @@ -0,0 +1,10 @@ +contract test { + uint constant x = 1; + function f() public { + assembly { + let y := x + } + } +} +// ---- +// TypeError: (107-108): 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..877f5783 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol @@ -0,0 +1,10 @@ +contract test { + function f() public { + uint a; + assembly { + function g() -> x { x := a } + } + } +} +// ---- +// DeclarationError: (114-115): 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..65d614a3 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol @@ -0,0 +1,11 @@ +contract test { + uint[] r; + function f() public { + uint[] storage a = r; + assembly { + function g() -> x { x := a_offset } + } + } +} +// ---- +// DeclarationError: (142-150): 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..abe9067a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol @@ -0,0 +1,8 @@ +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..952b9af6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol @@ -0,0 +1,9 @@ +contract C { + function f(bytes calldata bytesAsCalldata) external { + assembly { + let x := bytesAsCalldata + } + } +} +// ---- +// TypeError: (111-126): 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/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..62fe7171 --- /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 + } + } +} +// ---- +// SyntaxError: (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/389_inline_assembly_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol new file mode 100644 index 00000000..7315d5d1 --- /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 + } + } +} +// ---- +// SyntaxError: (75-82): The use of non-functional instructions is disallowed. Please use functional notation instead. +// SyntaxError: (95-98): The use of non-functional instructions is disallowed. Please use functional notation 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..0d7bacb4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol @@ -0,0 +1,10 @@ +contract C { + function f() pure public { + assembly { + label: + } + } +} +// ---- +// SyntaxError: (75-80): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead. +// SyntaxError: (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/393_inline_assembly_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol new file mode 100644 index 00000000..6cb35d6d --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol @@ -0,0 +1,9 @@ +contract C { + function f() pure public { + assembly { + jump(2) + } + } +} +// ---- +// SyntaxError: (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. 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..8538a2a0 --- /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) + } + } +} +// ---- +// SyntaxError: (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..c56ad25f --- /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; + } +} +// ---- +// TypeError: (52-61): "msg.value" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error. 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..2575954e --- /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 memory) { + } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// Warning: (112-164): 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..52d1bd13 --- /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 memory) { + 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..d052dab5 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol @@ -0,0 +1,12 @@ +// This tests a crash that occurred because we did not stop for fatal errors. +contract C { + struct S { + ftring a; + } + S public s; + function s() public s { + } +} +// ---- +// DeclarationError: (150-179): Identifier already declared. +// DeclarationError: (114-120): 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..ad57224c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol @@ -0,0 +1,12 @@ +contract C { + function f() public { + address payable addr; + uint balance = addr.balance; + (bool callSuc,) = addr.call(""); + (bool delegatecallSuc,) = addr.delegatecall(""); + bool sendRet = addr.send(1); + addr.transfer(1); + balance; callSuc; delegatecallSuc; 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..fee2525e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol @@ -0,0 +1,6 @@ +interface I { + function f() external pure { + } +} +// ---- +// TypeError: (18-52): Functions in interfaces cannot have an implementation. 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..385ed18e --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol @@ -0,0 +1,6 @@ +interface I { + struct A { + int dummy; + } +} +// ---- 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..9722e936 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol @@ -0,0 +1,4 @@ +interface I { + function f(uint a) external returns (bool); +} +// ---- 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..1533e7ff --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol @@ -0,0 +1,4 @@ +interface I { + enum A { B, C } +} +// ---- 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..24f36c5b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + throw; + } +} +// ---- +// SyntaxError: (52-57): "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/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/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..c343995f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_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 { + function() payable external {} +} + +contract B { + A a; + + function() external { + address(a).transfer(100); + } +} +// ---- 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_fail.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_fail.sol new file mode 100644 index 00000000..de42ebd7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_fail.sol @@ -0,0 +1,13 @@ +contract C { + struct S { uint a; } + S m_x; + uint[] m_y; + function f() view public { + S x = m_x; + uint[] y = m_y; + x; y; + } +} +// ---- +// TypeError: (104-107): Data location must be "storage" or "memory" for variable, but none was given. +// TypeError: (123-131): Data location must be "storage" or "memory" for variable, but none was given. 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..fe846aa0 --- /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 specified for array, struct or mapping types, but "storage" was given. 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..e74db375 --- /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 specified for array, struct or mapping types, but "storage" was given. 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..78c38aaf --- /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] calldata a) pure external { + } +} +// ---- +// TypeError: (28-56): 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..7578246e --- /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] memory a) pure internal { + } +} +// ---- +// TypeError: (28-54): 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..2831b6fb --- /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] memory a) pure public { + } +} +// ---- +// TypeError: (28-54): 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..ee56204a --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/481_explicit_literal_to_unspecified_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/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..c44fab55 --- /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"); + } +} +// ---- +// Warning: (52-65): Statement has no effect. 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..41ef95c5 --- /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..d02b098d --- /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..d39fcc28 --- /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..e4113906 --- /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..20031ea9 --- /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..3d37e988 --- /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..82b6c89d --- /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..7e9612d0 --- /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 memory _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..ad08eca6 --- /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. Remove parentheses if you do not want to provide arguments here. 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/527_fallback_marked_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol new file mode 100644 index 00000000..b8e1c654 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol @@ -0,0 +1,5 @@ +contract C { + function () internal { } +} +// ---- +// TypeError: (17-41): 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..6038a99f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol @@ -0,0 +1,5 @@ +contract C { + function () private { } +} +// ---- +// TypeError: (17-40): 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..d9c1580f --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol @@ -0,0 +1,5 @@ +contract C { + function () public { } +} +// ---- +// TypeError: (17-39): 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..01b7b294 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol @@ -0,0 +1,20 @@ +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 + } + function() payable external { + } +} +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..39edaa2d --- /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; + } +} +// ---- +// TypeError: (52-64): Member "balance" not found or not visible after argument-dependent lookup in contract C. Use "address(this).balance" to access this address member. 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..a44cc6d2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/542_warn_about_address_members_on_contract_transfer.sol @@ -0,0 +1,7 @@ +contract C { + function f() view public { + this.transfer; + } +} +// ---- +// TypeError: (52-65): Member "transfer" not found or not visible after argument-dependent lookup in contract C. Use "address(this).transfer" to access this address member. 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..e9e26a00 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/543_warn_about_address_members_on_contract_send.sol @@ -0,0 +1,7 @@ +contract C { + function f() view public { + this.send; + } +} +// ---- +// TypeError: (52-61): Member "send" not found or not visible after argument-dependent lookup in contract C. Use "address(this).send" to access this address member. 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..16da7578 --- /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; + } +} +// ---- +// TypeError: (52-61): Member "call" not found or not visible after argument-dependent lookup in contract C. Use "address(this).call" to access this address member. 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..9292f9c0 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/545_warn_about_address_members_on_contract_callcode.sol @@ -0,0 +1,7 @@ +contract C { + function f() view public { + this.callcode; + } +} +// ---- +// TypeError: (52-65): Member "callcode" not found or not visible after argument-dependent lookup in contract C. Use "address(this).callcode" to access this address member. 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..20354991 --- /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; + } +} +// ---- +// TypeError: (52-69): Member "delegatecall" not found or not visible after argument-dependent lookup in contract C. Use "address(this).delegatecall" to access this address member. 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..8a4734e6 --- /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; + } +} +// ---- +// TypeError: (65-74): Member "balance" not found or not visible after argument-dependent lookup in contract C. Use "address(c).balance" to access this address member. 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..e617f540 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/548_warn_about_address_members_on_non_this_contract_transfer.sol @@ -0,0 +1,8 @@ +contract C { + function f() view public { + C c; + c.transfer; + } +} +// ---- +// TypeError: (65-75): Member "transfer" not found or not visible after argument-dependent lookup in contract C. Use "address(c).transfer" to access this address member. 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..54965d4b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/549_warn_about_address_members_on_non_this_contract_send.sol @@ -0,0 +1,8 @@ +contract C { + function f() view public { + C c; + c.send; + } +} +// ---- +// TypeError: (65-71): Member "send" not found or not visible after argument-dependent lookup in contract C. Use "address(c).send" to access this address member. 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..940f383c --- /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; + } +} +// ---- +// TypeError: (65-71): Member "call" not found or not visible after argument-dependent lookup in contract C. Use "address(c).call" to access this address member. 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..9d4725bd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/551_warn_about_address_members_on_non_this_contract_callcode.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + C c; + c.callcode; + } +} +// ---- +// TypeError: (65-75): Member "callcode" not found or not visible after argument-dependent lookup in contract C. Use "address(c).callcode" to access this address member. 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..9941ce1f --- /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; + } +} +// ---- +// TypeError: (65-79): Member "delegatecall" not found or not visible after argument-dependent lookup in contract C. Use "address(c).delegatecall" to access this address member. 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..4c1870f1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/559_no_warning_for_using_members_that_look_like_address_members.sol @@ -0,0 +1,6 @@ +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/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/nameAndTypeResolution/570_function_type_undeclared_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol new file mode 100644 index 00000000..962f4fe4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(Nested)) external pure {} +} +// ---- +// DeclarationError: (37-43): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol new file mode 100644 index 00000000..735af9e9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(Nested) external) external pure {} +} +// ---- +// DeclarationError: (37-43): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol new file mode 100644 index 00000000..ffb467cd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(function(function(Nested)))) external pure {} +} +// ---- +// DeclarationError: (55-61): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/573_similar_name_longer_than_80_not_suggested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/573_similar_name_longer_than_80_not_suggested.sol new file mode 100644 index 00000000..c6719d8c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/573_similar_name_longer_than_80_not_suggested.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + int YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY; + } +} +// ---- +// DeclarationError: (146-236): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/574_similar_name_shorter_than_80_suggested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/574_similar_name_shorter_than_80_suggested.sol new file mode 100644 index 00000000..61fb2d82 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/574_similar_name_shorter_than_80_suggested.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + int YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY; + } +} +// ---- +// DeclarationError: (137-216): Undeclared identifier. Did you mean "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"?
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/575_member_member_getter_call_without_parentheses.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/575_member_member_getter_call_without_parentheses.sol new file mode 100644 index 00000000..61f43103 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/575_member_member_getter_call_without_parentheses.sol @@ -0,0 +1,19 @@ +contract A{ + function f() public pure{ + + } +} +contract B{ + A public a; +} +contract C{ + B public b; +} +contract D{ + C c; + function f() public view{ + c.b.a.f(); + } +} +// ---- +// TypeError: (170-175): Member "a" not found or not visible after argument-dependent lookup in function () view external returns (contract B). Did you intend to call the function? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/576_member_getter_call_without_parentheses.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/576_member_getter_call_without_parentheses.sol new file mode 100644 index 00000000..bdc5fdc7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/576_member_getter_call_without_parentheses.sol @@ -0,0 +1,17 @@ +contract A{ + function f() public pure{ + + } +} +contract B{ + A public a; +} +contract C{ + B b; + function f() public view{ + b.a.f(); + } +} + +// ---- +// TypeError: (140-145): Member "f" not found or not visible after argument-dependent lookup in function () view external returns (contract A). Did you intend to call the function? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/577_member_getter_call_without_parentheses_missing_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/577_member_getter_call_without_parentheses_missing_function.sol new file mode 100644 index 00000000..d204d926 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/577_member_getter_call_without_parentheses_missing_function.sol @@ -0,0 +1,15 @@ +contract A{ + +} +contract B{ + A public a; +} +contract C{ + B b; + function f() public view{ + b.a.f(); + } +} + +// ---- +// TypeError: (104-109): Member "f" not found or not visible after argument-dependent lookup in function () view external returns (contract A). Did you intend to call the function? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/578_private_member_getter_call_without_parentheses.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/578_private_member_getter_call_without_parentheses.sol new file mode 100644 index 00000000..e71da372 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/578_private_member_getter_call_without_parentheses.sol @@ -0,0 +1,17 @@ +contract A{ + function f() public pure{ + + } +} +contract B{ + A private a; +} +contract C{ + B b; + function f() public view{ + b.a.f(); + } +} + +// ---- +// TypeError: (141-144): Member "a" not found or not visible after argument-dependent lookup in contract B. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/579_member_getter_call_without_parentheses_private_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/579_member_getter_call_without_parentheses_private_function.sol new file mode 100644 index 00000000..18932238 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/579_member_getter_call_without_parentheses_private_function.sol @@ -0,0 +1,17 @@ +contract A{ + function f() private pure{ + + } +} +contract B{ + A public a; +} +contract C{ + B b; + function f() public view{ + b.a.f(); + } +} + +// ---- +// TypeError: (141-146): Member "f" not found or not visible after argument-dependent lookup in function () view external returns (contract A). Did you intend to call the function? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/580_improve_name_suggestion_one_and_two_letters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/580_improve_name_suggestion_one_and_two_letters.sol new file mode 100644 index 00000000..8d2d071b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/580_improve_name_suggestion_one_and_two_letters.sol @@ -0,0 +1,14 @@ +contract c { + function f () public + { + a = ac; + a = cd; + a = b; + } + uint256 a; + uint256 ab; +} +// ---- +// DeclarationError: (56-58): Undeclared identifier. Did you mean "ab"? +// DeclarationError: (72-74): Undeclared identifier. +// DeclarationError: (88-89): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/581_improve_name_suggestion_three_letters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/581_improve_name_suggestion_three_letters.sol new file mode 100644 index 00000000..69f5a7e2 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/581_improve_name_suggestion_three_letters.sol @@ -0,0 +1,12 @@ +contract c { + function f () public + { + a = abd; + a = ade; + } + uint256 a; + uint256 abc; +} +// ---- +// DeclarationError: (56-59): Undeclared identifier. Did you mean "abc" or "abi"? +// DeclarationError: (73-76): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/582_improve_name_suggestion_four_letters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/582_improve_name_suggestion_four_letters.sol new file mode 100644 index 00000000..547ea308 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/582_improve_name_suggestion_four_letters.sol @@ -0,0 +1,17 @@ +contract c { + function f () public + { + a = land; + a = lost; + a = lang; + } + uint256 long; + uint256 abc; +} +// ---- +// DeclarationError: (52-53): Undeclared identifier. +// DeclarationError: (56-60): Undeclared identifier. Did you mean "long"? +// DeclarationError: (70-71): Undeclared identifier. +// DeclarationError: (74-78): Undeclared identifier. Did you mean "long", "log0", "log1", "log2", "log3" or "log4"? +// DeclarationError: (88-89): Undeclared identifier. +// DeclarationError: (92-96): Undeclared identifier. Did you mean "long"? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/583_abi_encode_packed_with_rational_number_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/583_abi_encode_packed_with_rational_number_constant.sol new file mode 100644 index 00000000..6be591f6 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/583_abi_encode_packed_with_rational_number_constant.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public { abi.encodePacked(0/1); } +} +// ---- +// TypeError: (61-64): Cannot perform packed encoding for a literal. Please convert it to an explicit type first.
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/584_abi_decode_with_tuple_of_other_than_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/584_abi_decode_with_tuple_of_other_than_types.sol new file mode 100644 index 00000000..c95eeb35 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/584_abi_decode_with_tuple_of_other_than_types.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public { abi.decode("", (0)); } +} +// ---- +// TypeError: (60-61): Argument has to be a type name. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/constant_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/constant_mapping.sol new file mode 100644 index 00000000..61c0cc17 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/constant_mapping.sol @@ -0,0 +1,8 @@ +contract C { + // This should probably have a better error message at some point. + // Constant mappings should not be possible in general. + mapping(uint => uint) constant x; +} +// ---- +// TypeError: (148-180): Constants of non-value type not yet implemented. +// TypeError: (148-180): Uninitialized "constant" variable. diff --git a/test/libsolidity/syntaxTests/parsing/address_constant_payable.sol b/test/libsolidity/syntaxTests/parsing/address_constant_payable.sol new file mode 100644 index 00000000..d98f4ae3 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_constant_payable.sol @@ -0,0 +1,5 @@ +contract C { + address constant payable b = address(0); +} +// ---- +// ParserError: (34-41): Expected identifier but got 'payable' diff --git a/test/libsolidity/syntaxTests/parsing/address_function_arguments_and_returns.sol b/test/libsolidity/syntaxTests/parsing/address_function_arguments_and_returns.sol new file mode 100644 index 00000000..c377600a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_function_arguments_and_returns.sol @@ -0,0 +1,4 @@ +contract C { + function f(address) public pure returns (address) {} + function g(address payable) public pure returns (address payable) {} +} diff --git a/test/libsolidity/syntaxTests/parsing/address_in_struct.sol b/test/libsolidity/syntaxTests/parsing/address_in_struct.sol new file mode 100644 index 00000000..68049b50 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_in_struct.sol @@ -0,0 +1,6 @@ +contract C { + struct S { + address payable a; + address b; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol b/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol new file mode 100644 index 00000000..606f5cd0 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol @@ -0,0 +1,26 @@ +contract C { + address view m_a; + address pure m_b; + address view[] m_c; + mapping(uint => address view) m_d; + function f() public pure { + address view a; + address pure b; + a; b; + } + function g(address view) public pure {} + function h(address pure) public pure {} + function i() public pure returns (address view) {} + function j() public pure returns (address pure) {} +} +// ---- +// TypeError: (14-26): Address types can only be payable or non-payable. +// TypeError: (33-45): Address types can only be payable or non-payable. +// TypeError: (52-64): Address types can only be payable or non-payable. +// TypeError: (89-101): Address types can only be payable or non-payable. +// TypeError: (195-207): Address types can only be payable or non-payable. +// TypeError: (236-248): Address types can only be payable or non-payable. +// TypeError: (300-312): Address types can only be payable or non-payable. +// TypeError: (352-364): Address types can only be payable or non-payable. +// TypeError: (138-150): Address types can only be payable or non-payable. +// TypeError: (156-168): Address types can only be payable or non-payable. diff --git a/test/libsolidity/syntaxTests/parsing/address_nonpayable.sol b/test/libsolidity/syntaxTests/parsing/address_nonpayable.sol new file mode 100644 index 00000000..fea67138 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_nonpayable.sol @@ -0,0 +1,7 @@ +contract C { + address a; + function f(address b) public pure returns (address c) { + address d = b; + return d; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/address_payable.sol b/test/libsolidity/syntaxTests/parsing/address_payable.sol new file mode 100644 index 00000000..c29ae1b7 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable.sol @@ -0,0 +1,7 @@ +contract C { + address payable a; + function f(address payable b) public pure returns (address payable c) { + address payable d = b; + return d; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_constant.sol b/test/libsolidity/syntaxTests/parsing/address_payable_constant.sol new file mode 100644 index 00000000..154bfb54 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable_constant.sol @@ -0,0 +1,3 @@ +contract C { + address payable constant a = address(0); +} diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_conversion.sol b/test/libsolidity/syntaxTests/parsing/address_payable_conversion.sol new file mode 100644 index 00000000..bf073a52 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable_conversion.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + address payable a = address payable(this); + } +} +// ---- +// ParserError: (80-87): Expected ';' but got 'payable' diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_function_type.sol b/test/libsolidity/syntaxTests/parsing/address_payable_function_type.sol new file mode 100644 index 00000000..234b528a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable_function_type.sol @@ -0,0 +1,6 @@ +contract C { + function (address payable) view internal returns (address payable) f; + function g(function (address payable) payable external returns (address payable)) public payable returns (function (address payable) payable external returns (address payable)) { + function (address payable) payable external returns (address payable) h; h; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_library.sol b/test/libsolidity/syntaxTests/parsing/address_payable_library.sol new file mode 100644 index 00000000..33787d33 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable_library.sol @@ -0,0 +1,5 @@ +library L { +} +contract C { + using L for address payable; +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_local.sol b/test/libsolidity/syntaxTests/parsing/address_payable_local.sol new file mode 100644 index 00000000..544f7c21 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable_local.sol @@ -0,0 +1,11 @@ +contract C { + mapping(uint => address payable) m; + mapping(uint => address payable[]) n; + function f() public view { + address payable a; + address payable[] memory b; + mapping(uint => address payable) storage c = m; + mapping(uint => address payable[]) storage d = n; + a; b; c; d; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_state_variable.sol b/test/libsolidity/syntaxTests/parsing/address_payable_state_variable.sol new file mode 100644 index 00000000..12c2468d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable_state_variable.sol @@ -0,0 +1,8 @@ +contract C { + address payable a; + address payable public b; + address payable[] c; + address payable[] public d; + mapping(uint => address payable) e; + mapping(uint => address payable[]) f; +} diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_struct.sol b/test/libsolidity/syntaxTests/parsing/address_payable_struct.sol new file mode 100644 index 00000000..6c281bc7 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable_struct.sol @@ -0,0 +1,8 @@ +contract C { + struct S { + address payable a; + address payable[] b; + mapping(uint => address payable) c; + mapping(uint => address payable[]) d; + } +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_type_expression.sol b/test/libsolidity/syntaxTests/parsing/address_payable_type_expression.sol new file mode 100644 index 00000000..394b39c0 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_payable_type_expression.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + address payable; + } +} +// ---- +// ParserError: (67-68): Expected identifier but got ';' diff --git a/test/libsolidity/syntaxTests/parsing/address_public_payable_error.sol b/test/libsolidity/syntaxTests/parsing/address_public_payable_error.sol new file mode 100644 index 00000000..0acf5e4b --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/address_public_payable_error.sol @@ -0,0 +1,5 @@ +contract C { + address public payable a; +} +// ---- +// ParserError: (32-39): Expected identifier but got 'payable' diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol new file mode 100644 index 00000000..edbc9665 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol @@ -0,0 +1,3 @@ +contract c { + event e(uint[10] a, bytes7[8] indexed b, c[3] x); +} diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol new file mode 100644 index 00000000..4c1f96e6 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol @@ -0,0 +1,6 @@ +contract c { + function f() public { c[10] storage a = 7; uint8[10 * 2] storage x; } +} +// ---- +// TypeError: (39-58): Type int_const 7 is not implicitly convertible to expected type contract c[10] storage pointer. +// DeclarationError: (60-83): Uninitialized storage pointer. diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol new file mode 100644 index 00000000..9adf6f12 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol @@ -0,0 +1,6 @@ +contract c { + uint[10] a; + uint[] a2; + struct x { uint[2**20] b; y[1] c; } + struct y { uint d; mapping(uint=>x)[] e; } +} diff --git a/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol b/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol new file mode 100644 index 00000000..28a07e63 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure { + assembly "evmasm" {} + } +} diff --git a/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol b/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol new file mode 100644 index 00000000..c2d39279 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + assembly "failasm" {} + } +} +// ---- +// ParserError: (55-64): Only "evmasm" supported. diff --git a/test/libsolidity/syntaxTests/parsing/calling_function.sol b/test/libsolidity/syntaxTests/parsing/calling_function.sol new file mode 100644 index 00000000..9e88c451 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/calling_function.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + function() returns(function() returns(function() returns(function() returns(uint)))) x; + uint y; + y = x()()()(); + } +} diff --git a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol new file mode 100644 index 00000000..0e348f5b --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol @@ -0,0 +1,8 @@ +contract A { + function f() public { + uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6; + } +} +// ---- +// 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 new file mode 100644 index 00000000..40aaa917 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol @@ -0,0 +1,10 @@ +contract A { + function f() public { + uint x = true ? 1 : 0; + uint y = false ? 0 : 1; + } +} +// ---- +// 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 new file mode 100644 index 00000000..7489aaf9 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol @@ -0,0 +1,8 @@ +contract A { + function f() public pure { + uint y = 1; + uint x = 3 < 0 ? y = 3 : 6; + true ? x = 3 : 4; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol new file mode 100644 index 00000000..705fbadf --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol @@ -0,0 +1,10 @@ +contract A { + function f() public { + uint x = 3 > 0 ? 3 : 0; + uint y = (3 > 0) ? 3 : 0; + } +} +// ---- +// 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 new file mode 100644 index 00000000..bbabf957 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol @@ -0,0 +1,12 @@ +contract A { + function f() public { + uint x = 3; + uint y = 1; + uint z = (x > y) ? x : y; + uint w = x > y ? x : y; + } +} +// ---- +// 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/constructor_allowed_this.sol b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol index 9f714aea..b66253e4 100644 --- a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol +++ b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol @@ -3,9 +3,9 @@ contract A { } } contract B { - constructor(address) public { + constructor(C) public { } - function b(address) public returns (A) { + function b(C) public returns (A) { return new A(); } } diff --git a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol new file mode 100644 index 00000000..6d88669a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol @@ -0,0 +1,13 @@ +contract A { + fixed40x40 storeMe; + function f(ufixed x, fixed32x32 y) public { + ufixed8x8 a; + fixed b; + } +} +// ---- +// 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: (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/declaring_fixed_literal_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol new file mode 100644 index 00000000..b0d938a0 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol @@ -0,0 +1,5 @@ +contract A { + fixed40x40 pi = 3.14; +} +// ---- +// TypeError: (33-37): Type rational_const 157 / 50 is not implicitly convertible to expected type fixed40x40. Try converting to type ufixed16x2 or use an explicit conversion. diff --git a/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol b/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol new file mode 100644 index 00000000..41b2762b --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol @@ -0,0 +1,29 @@ +contract C { + bool payable a; + string payable b; + int payable c; + int256 payable d; + uint payable e; + uint256 payable f; + byte payable g; + bytes payable h; + bytes32 payable i; + fixed payable j; + fixed80x80 payable k; + ufixed payable l; + ufixed80x80 payable m; +} +// ---- +// ParserError: (22-29): State mutability can only be specified for address types. +// ParserError: (44-51): State mutability can only be specified for address types. +// ParserError: (63-70): State mutability can only be specified for address types. +// ParserError: (85-92): State mutability can only be specified for address types. +// ParserError: (105-112): State mutability can only be specified for address types. +// ParserError: (128-135): State mutability can only be specified for address types. +// ParserError: (148-155): State mutability can only be specified for address types. +// ParserError: (169-176): State mutability can only be specified for address types. +// ParserError: (192-199): State mutability can only be specified for address types. +// ParserError: (213-220): State mutability can only be specified for address types. +// ParserError: (239-246): State mutability can only be specified for address types. +// ParserError: (261-268): State mutability can only be specified for address types. +// ParserError: (288-295): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol new file mode 100644 index 00000000..9cb0fb4f --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol @@ -0,0 +1,29 @@ +contract C { + function a(bool payable) public pure {} + function b(string payable) public pure {} + function c(int payable) public pure {} + function d(int256 payable) public pure {} + function e(uint payable) public pure {} + function f(uint256 payable) public pure {} + function g(byte payable) public pure {} + function h(bytes payable) public pure {} + function i(bytes32 payable) public pure {} + function j(fixed payable) public pure {} + function k(fixed80x80 payable) public pure {} + function l(ufixed payable) public pure {} + function m(ufixed80x80 payable) public pure {} +} +// ---- +// ParserError: (33-40): State mutability can only be specified for address types. +// ParserError: (79-86): State mutability can only be specified for address types. +// ParserError: (122-129): State mutability can only be specified for address types. +// ParserError: (168-175): State mutability can only be specified for address types. +// ParserError: (212-219): State mutability can only be specified for address types. +// ParserError: (259-266): State mutability can only be specified for address types. +// ParserError: (303-310): State mutability can only be specified for address types. +// ParserError: (348-355): State mutability can only be specified for address types. +// ParserError: (395-402): State mutability can only be specified for address types. +// ParserError: (440-447): State mutability can only be specified for address types. +// ParserError: (490-497): State mutability can only be specified for address types. +// ParserError: (536-543): State mutability can only be specified for address types. +// ParserError: (587-594): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol new file mode 100644 index 00000000..3d47f1c7 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol @@ -0,0 +1,31 @@ +contract C { + function f() public pure { + bool payable a; + string payable b; + int payable c; + int256 payable d; + uint payable e; + uint256 payable f; + byte payable g; + bytes payable h; + bytes32 payable i; + fixed payable j; + fixed80x80 payable k; + ufixed payable l; + ufixed80x80 payable m; + } +} +// ---- +// ParserError: (57-64): State mutability can only be specified for address types. +// ParserError: (83-90): State mutability can only be specified for address types. +// ParserError: (106-113): State mutability can only be specified for address types. +// ParserError: (132-139): State mutability can only be specified for address types. +// ParserError: (156-163): State mutability can only be specified for address types. +// ParserError: (183-190): State mutability can only be specified for address types. +// ParserError: (207-214): State mutability can only be specified for address types. +// ParserError: (232-239): State mutability can only be specified for address types. +// ParserError: (259-266): State mutability can only be specified for address types. +// ParserError: (284-291): State mutability can only be specified for address types. +// ParserError: (314-321): State mutability can only be specified for address types. +// ParserError: (340-347): State mutability can only be specified for address types. +// ParserError: (371-378): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol new file mode 100644 index 00000000..fc7a3c25 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol @@ -0,0 +1,29 @@ +contract C { + function a() public pure returns (bool payable) {} + function b() public pure returns (string payable) {} + function c() public pure returns (int payable) {} + function d() public pure returns (int256 payable) {} + function e() public pure returns (uint payable) {} + function f() public pure returns (uint256 payable) {} + function g() public pure returns (byte payable) {} + function h() public pure returns (bytes payable) {} + function i() public pure returns (bytes32 payable) {} + function j() public pure returns (fixed payable) {} + function k() public pure returns (fixed80x80 payable) {} + function l() public pure returns (ufixed payable) {} + function m() public pure returns (ufixed80x80 payable) {} +} +// ---- +// ParserError: (56-63): State mutability can only be specified for address types. +// ParserError: (113-120): State mutability can only be specified for address types. +// ParserError: (167-174): State mutability can only be specified for address types. +// ParserError: (224-231): State mutability can only be specified for address types. +// ParserError: (279-286): State mutability can only be specified for address types. +// ParserError: (337-344): State mutability can only be specified for address types. +// ParserError: (392-399): State mutability can only be specified for address types. +// ParserError: (448-455): State mutability can only be specified for address types. +// ParserError: (506-513): State mutability can only be specified for address types. +// ParserError: (562-569): State mutability can only be specified for address types. +// ParserError: (623-630): State mutability can only be specified for address types. +// ParserError: (680-687): State mutability can only be specified for address types. +// ParserError: (742-749): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol new file mode 100644 index 00000000..c2a1aaeb --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol @@ -0,0 +1,7 @@ +contract test { + function fun(uint256 a) public returns (uint8 b) { + if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78; + } +} +// ---- +// 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_from_interface.sol b/test/libsolidity/syntaxTests/parsing/enum_from_interface.sol new file mode 100644 index 00000000..0fe0fbae --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_from_interface.sol @@ -0,0 +1,9 @@ +interface I { + enum Direction { Left, Right } +} + +contract D { + function f() public pure returns (I.Direction) { + return I.Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol b/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol new file mode 100644 index 00000000..8d9003eb --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol @@ -0,0 +1,12 @@ +interface I { + enum Direction { Left, Right } +} + +library L { + function f() public pure returns (I.Direction) { + return I.Direction.Left; + } + function g() internal pure returns (I.Direction) { + return I.Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_from_library.sol b/test/libsolidity/syntaxTests/parsing/enum_from_library.sol new file mode 100644 index 00000000..ab762a82 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_from_library.sol @@ -0,0 +1,9 @@ +library L { + enum Direction { Left, Right } +} + +contract D { + function f() public pure returns (L.Direction) { + return L.Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol b/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol new file mode 100644 index 00000000..e5b98352 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol @@ -0,0 +1,9 @@ +contract C { + enum Direction { Left, Right } +} + +contract D is C { + function f() public pure returns (Direction) { + return Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol b/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol new file mode 100644 index 00000000..75858744 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol @@ -0,0 +1,9 @@ +interface I { + enum Direction { Left, Right } +} + +contract D is I { + function f() public pure returns (Direction) { + return Direction.Left; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol new file mode 100644 index 00000000..606f59d7 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol @@ -0,0 +1,7 @@ +contract c { + enum validEnum { Value1, Value2, Value3, Value4 } + constructor() public { + a = validEnum.Value3; + } + validEnum a; +} diff --git a/test/libsolidity/syntaxTests/parsing/event.sol b/test/libsolidity/syntaxTests/parsing/event.sol new file mode 100644 index 00000000..2aaa873f --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/event.sol @@ -0,0 +1,3 @@ +contract c { + event e(); +} diff --git a/test/libsolidity/syntaxTests/parsing/event_arguments.sol b/test/libsolidity/syntaxTests/parsing/event_arguments.sol new file mode 100644 index 00000000..3228853a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/event_arguments.sol @@ -0,0 +1,3 @@ +contract c { + event e(uint a, bytes32 s); +} diff --git a/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol b/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol new file mode 100644 index 00000000..d603fc08 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol @@ -0,0 +1,3 @@ +contract c { + event e(uint a, bytes32 indexed s, bool indexed b); +} diff --git a/test/libsolidity/syntaxTests/parsing/exp_expression.sol b/test/libsolidity/syntaxTests/parsing/exp_expression.sol new file mode 100644 index 00000000..6b307ea0 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/exp_expression.sol @@ -0,0 +1,8 @@ +contract test { + function fun(uint256 a) public { + uint256 x = 3 ** a; + } +} +// ---- +// Warning: (61-70): Unused local variable. +// Warning: (20-86): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/external_function.sol b/test/libsolidity/syntaxTests/parsing/external_function.sol new file mode 100644 index 00000000..3aa3ceec --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/external_function.sol @@ -0,0 +1,5 @@ +contract c { + function x() external {} +} +// ---- +// Warning: (17-41): 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 new file mode 100644 index 00000000..054f57de --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/fallback_function.sol @@ -0,0 +1,4 @@ +contract c { + function() external { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol new file mode 100644 index 00000000..fce669dd --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol @@ -0,0 +1,12 @@ +contract test { + function fun(uint256 a) public { + uint256 i =0; + for (i = 0; i < 10; i++) { + uint256 x = i; break; continue; + } + } +} +// ---- +// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. +// 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 new file mode 100644 index 00000000..4adf0948 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol @@ -0,0 +1,12 @@ +contract test { + function fun(uint256 a) public { + uint256 i =0; + for (;;) { + uint256 x = i; break; continue; + } + } + } +// ---- +// Warning: (37-46): Unused function parameter. Remove or comment out the variable name to silence this warning. +// 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 new file mode 100644 index 00000000..c6af519c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol @@ -0,0 +1,10 @@ +contract test { + function fun(uint256 a) public { + uint256 i = 0; + for (i = 0; i < 10; i++) + continue; + } +} +// ---- +// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. +// 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 new file mode 100644 index 00000000..c22ae42f --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol @@ -0,0 +1,11 @@ +contract test { + function fun(uint256 a) public { + for (uint256 i = 0; i < 10; i++) { + uint256 x = i; break; continue; + } + } +} +// ---- +// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (108-117): Unused local variable. +// Warning: (20-155): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol b/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol new file mode 100644 index 00000000..38175572 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol @@ -0,0 +1,3 @@ +// "from" is not a keyword although it is used as a keyword in import directives. +contract from { +} 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 new file mode 100644 index 00000000..94e1e60a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol @@ -0,0 +1,9 @@ +contract test { + uint256 stateVar; + // We won't see this comment + function functionName(bytes32 input) public returns (bytes32 out) {} +} +// ---- +// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning. +// 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_parameter.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol new file mode 100644 index 00000000..4075d74a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol @@ -0,0 +1,5 @@ +contract test { + function f(function(uint) external returns (uint) g) internal returns (uint a) { + return g(1); + } +} diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol new file mode 100644 index 00000000..e3d41f48 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol @@ -0,0 +1,3 @@ +contract test { + function (uint, uint) internal returns (uint) f1; +} 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 new file mode 100644 index 00000000..11e77f25 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol @@ -0,0 +1,9 @@ +contract test { + function f(uint x, uint y) public returns (uint a) {} + function (uint, uint) internal returns (uint) f1 = f; +} +// ---- +// 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: (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 new file mode 100644 index 00000000..3defb5ea --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol @@ -0,0 +1,13 @@ +contract test { + function f(uint x, uint y) public returns (uint a) {} + function g() public { + function (uint, uint) internal returns (uint) f1 = f; + } +} +// ---- +// 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: (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 new file mode 100644 index 00000000..c7703b47 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol @@ -0,0 +1,10 @@ +contract test { + struct S { + function (uint x, uint y) internal returns (uint) f; + function (uint, uint) external returns (uint) g; + uint d; + } +} +// ---- +// Warning: (49-55): Naming function type parameters is deprecated. +// Warning: (57-63): Naming function type parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/parsing/if_statement.sol b/test/libsolidity/syntaxTests/parsing/if_statement.sol new file mode 100644 index 00000000..b3269785 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/if_statement.sol @@ -0,0 +1,8 @@ +contract test { + function fun(uint256 a) public returns (uint) { + if (a >= 8) { return 2; } else { uint b = 7; } + } +} +// ---- +// Warning: (109-115): Unused local variable. +// Warning: (20-128): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/import_complex.sol b/test/libsolidity/syntaxTests/parsing/import_complex.sol new file mode 100644 index 00000000..8bbb0a88 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/import_complex.sol @@ -0,0 +1,3 @@ +import {hello, world} from "hello"; +// ---- +// ParserError: (0-35): Source "hello" not found: File not supplied initially. diff --git a/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol b/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol new file mode 100644 index 00000000..c4667606 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol @@ -0,0 +1,3 @@ +import {hello, world} from function; +// ---- +// ParserError: (27-35): Expected import path. diff --git a/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol b/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol new file mode 100644 index 00000000..961acb22 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol @@ -0,0 +1,3 @@ +import {hello, world}; +// ---- +// ParserError: (21-22): Expected "from". diff --git a/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol b/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol new file mode 100644 index 00000000..df837e28 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol @@ -0,0 +1,3 @@ +import function; +// ---- +// ParserError: (7-15): Expected string literal (path), "*" or alias list. diff --git a/test/libsolidity/syntaxTests/parsing/import_simple.sol b/test/libsolidity/syntaxTests/parsing/import_simple.sol new file mode 100644 index 00000000..5d61a8bb --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/import_simple.sol @@ -0,0 +1,3 @@ +import "hello"; +// ---- +// ParserError: (0-15): Source "hello" not found: File not supplied initially. diff --git a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol new file mode 100644 index 00000000..4730f950 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol @@ -0,0 +1,8 @@ +contract c { + uint[] a; + function f() public returns (uint, uint) { + a = [1,2,3]; + return (a[3], [2,3,4][0]); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/interface_basic.sol b/test/libsolidity/syntaxTests/parsing/interface_basic.sol index c25b48ba..0742c24f 100644 --- a/test/libsolidity/syntaxTests/parsing/interface_basic.sol +++ b/test/libsolidity/syntaxTests/parsing/interface_basic.sol @@ -1,6 +1,4 @@ interface Interface { - function f(); + function f() external; } // ---- -// 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. diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal.sol new file mode 100644 index 00000000..d4d3299f --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + uint d1 = 654_321; + uint d2 = 54_321; + uint d3 = 4_321; + uint d4 = 5_43_21; + uint d5 = 1_2e10; + uint d6 = 12e1_0; + + d1; d2; d3; d4; d5; d6; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol new file mode 100644 index 00000000..8978996d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + uint D1 = 1234_; + uint D2 = 12__34; + uint D3 = 12_e34; + uint D4 = 12e_34; + } +} +// ---- +// SyntaxError: (56-61): Invalid use of underscores in number literal. No trailing underscores allowed. +// SyntaxError: (77-83): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed. +// SyntaxError: (99-105): Invalid use of underscores in number literal. No underscore at the end of the mantissa allowed. +// SyntaxError: (121-127): Invalid use of underscores in number literal. No underscore in front of exponent allowed. diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed.sol new file mode 100644 index 00000000..4910ee82 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + fixed f1 = 3.14_15; + fixed f2 = 3_1.4_15; + + f1; f2; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol new file mode 100644 index 00000000..3b91895d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol @@ -0,0 +1,17 @@ +contract C { + function f() public pure { + fixed F1 = 3.1415_; + fixed F2 = 3__1.4__15; + fixed F3 = 1_.2; + fixed F4 = 1._2; + fixed F5 = 1.2e_12; + fixed F6 = 1._; + } +} +// ---- +// SyntaxError: (57-64): Invalid use of underscores in number literal. No trailing underscores allowed. +// SyntaxError: (81-91): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed. +// SyntaxError: (108-112): Invalid use of underscores in number literal. No underscores in front of the fraction part allowed. +// SyntaxError: (129-133): Invalid use of underscores in number literal. No underscores in front of the fraction part allowed. +// SyntaxError: (150-157): Invalid use of underscores in number literal. No underscore in front of exponent allowed. +// SyntaxError: (174-177): Invalid use of underscores in number literal. No trailing underscores allowed. diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex.sol new file mode 100644 index 00000000..999a4634 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + uint x1 = 0x8765_4321; + uint x2 = 0x765_4321; + uint x3 = 0x65_4321; + uint x4 = 0x5_4321; + uint x5 = 0x123_1234_1234_1234; + uint x6 = 0x123456_1234_1234; + + x1; x2; x3; x4; x5; x6; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol new file mode 100644 index 00000000..a8a488c1 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + uint X1 = 0x1234__1234__1234__123; + } +} +// ---- +// SyntaxError: (56-79): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed. diff --git a/test/libsolidity/syntaxTests/parsing/library_simple.sol b/test/libsolidity/syntaxTests/parsing/library_simple.sol new file mode 100644 index 00000000..006ff307 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/library_simple.sol @@ -0,0 +1,5 @@ +library Lib { + function f() public { } +} +// ---- +// 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 new file mode 100644 index 00000000..64116b88 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol @@ -0,0 +1,15 @@ +contract c { + function f() public + { + a = 1 wei; + b = 2 szabo; + c = 3 finney; + b = 4 ether; + } + uint256 a; + uint256 b; + uint256 c; + uint256 d; +} +// ---- +// 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 new file mode 100644 index 00000000..2f2302ed --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol @@ -0,0 +1,7 @@ +contract c { + constructor() public + { + a = 1 wei * 100 wei + 7 szabo - 3; + } + uint256 a; +} diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol new file mode 100644 index 00000000..38de7b1c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol @@ -0,0 +1,9 @@ +contract Foo { + uint[] m_x; + function f() public view { + uint[] storage x = m_x; + uint[] memory y; + x; y; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol new file mode 100644 index 00000000..d53208ef --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol @@ -0,0 +1,12 @@ +contract Foo { + uint[] m_x; + function f() public view { + uint[] storage memory x = m_x; + uint[] memory storage calldata y; + x; y; + } +} +// ---- +// ParserError: (85-91): Location already specified. +// ParserError: (123-130): Location already specified. +// ParserError: (131-139): Location already specified. diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol new file mode 100644 index 00000000..bf78e59c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol @@ -0,0 +1,7 @@ +contract Foo { + function f(uint[] storage constant x, uint[] memory y) internal { } +} +// ---- +// DeclarationError: (30-55): The "constant" keyword can only be used for state variables. +// TypeError: (30-55): Constants of non-value type not yet implemented. +// TypeError: (30-55): Uninitialized "constant" variable. diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol new file mode 100644 index 00000000..c6155c09 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol @@ -0,0 +1,6 @@ +contract Foo { + function f(uint[] storage memory constant x, uint[] memory calldata y) internal { } +} +// ---- +// ParserError: (45-51): Location already specified. +// ParserError: (78-86): Location already specified. diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol new file mode 100644 index 00000000..e34df2b2 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol @@ -0,0 +1,5 @@ +contract Foo { + uint[] memory storage calldata x; +} +// ---- +// ParserError: (23-29): Expected identifier but got 'memory' diff --git a/test/libsolidity/syntaxTests/parsing/mapping.sol b/test/libsolidity/syntaxTests/parsing/mapping.sol new file mode 100644 index 00000000..d6bf3f14 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping.sol @@ -0,0 +1,3 @@ +contract test { + mapping(address => bytes32) names; +} diff --git a/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol b/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol new file mode 100644 index 00000000..b7cf34e4 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol @@ -0,0 +1,6 @@ +contract test { + mapping (address => function() internal returns (uint)) a; + mapping (address => function() external) b; + mapping (address => function() external[]) c; + function() external[] d; +} diff --git a/test/libsolidity/syntaxTests/parsing/mapping_from_address_payable.sol b/test/libsolidity/syntaxTests/parsing/mapping_from_address_payable.sol new file mode 100644 index 00000000..7e6f98d7 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping_from_address_payable.sol @@ -0,0 +1,5 @@ +contract C { + mapping(address payable => uint) m; +} +// ---- +// ParserError: (33-40): Expected '=>' but got 'payable' diff --git a/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol b/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol new file mode 100644 index 00000000..980d5750 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol @@ -0,0 +1,7 @@ +contract test { + struct test_struct { + address addr; + uint256 count; + mapping(bytes32 => test_struct) self_reference; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_1.sol b/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_1.sol new file mode 100644 index 00000000..ea2d282c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_1.sol @@ -0,0 +1,5 @@ +contract c { + mapping(uint[] => uint) data; +} +// ---- +// ParserError: (26-27): Expected '=>' but got '[' diff --git a/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_2.sol b/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_2.sol new file mode 100644 index 00000000..713cddeb --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_2.sol @@ -0,0 +1,8 @@ +contract c { + struct S { + uint x; + } + mapping(S => uint) data; +} +// ---- +// ParserError: (47-48): Expected elementary type name for mapping key type diff --git a/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_3.sol b/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_3.sol new file mode 100644 index 00000000..655af9de --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_3.sol @@ -0,0 +1,8 @@ +contract c { + struct S { + string s; + } + mapping(S => uint) data; +} +// ---- +// ParserError: (49-50): Expected elementary type name for mapping key type diff --git a/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_4.sol b/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_4.sol new file mode 100644 index 00000000..f4dcb00a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping_nonelementary_key_4.sol @@ -0,0 +1,5 @@ +contract c { + mapping(string[] => uint) data; +} +// ---- +// ParserError: (28-29): Expected '=>' but got '[' diff --git a/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol b/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol new file mode 100644 index 00000000..c06220b7 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol @@ -0,0 +1,6 @@ +contract test { + struct test_struct { + address addr; + mapping (uint64 => mapping (bytes32 => uint)) complex_mapping; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/modifier.sol b/test/libsolidity/syntaxTests/parsing/modifier.sol new file mode 100644 index 00000000..b995ce89 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/modifier.sol @@ -0,0 +1,3 @@ +contract c { + modifier mod { if (msg.sender == 0x0000000000000000000000000000000000000000) _; } +} diff --git a/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol b/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol new file mode 100644 index 00000000..27b5b13b --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol @@ -0,0 +1,3 @@ +contract c { + modifier mod(address a) { if (msg.sender == a) _; } +} diff --git a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol new file mode 100644 index 00000000..cf986efe --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol @@ -0,0 +1,7 @@ +contract c { + modifier mod1(uint a) { if (msg.sender == address(a)) _; } + modifier mod2 { if (msg.sender == address(2)) _; } + function f() public mod1(7) mod2 { } +} +// ---- +// Warning: (135-171): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/parsing/multi_arrays.sol b/test/libsolidity/syntaxTests/parsing/multi_arrays.sol new file mode 100644 index 00000000..ef20ecee --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multi_arrays.sol @@ -0,0 +1,3 @@ +contract c { + mapping(uint => mapping(uint => int8)[8][][9])[] x; +} diff --git a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol index 818999df..56c2e280 100644 --- a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol +++ b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol @@ -1,29 +1,13 @@ 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,4); + (uint h,) = (4,5); + (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 diff --git a/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol new file mode 100644 index 00000000..bfbe7e5c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol @@ -0,0 +1,6 @@ +contract test { + event Test(uint a, uint b,); + function(uint a) {} +} +// ---- +// ParserError: (45-46): Unexpected trailing comma in parameter list. diff --git a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol new file mode 100644 index 00000000..85d9e6a8 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol @@ -0,0 +1,24 @@ +contract test { + uint256 stateVar; + /// This is test function 1 + function functionName1(bytes32 input) public returns (bytes32 out) {} + /// This is test function 2 + function functionName2(bytes32 input) public returns (bytes32 out) {} + // nothing to see here + function functionName3(bytes32 input) public returns (bytes32 out) {} + /// This is test function 4 + function functionName4(bytes32 input) public returns (bytes32 out) {} +} +// ---- +// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning. +// 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/multiple_modifier_arg_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol new file mode 100644 index 00000000..eb206fb7 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol @@ -0,0 +1,6 @@ +contract test { + modifier modTest(uint a, uint b,) { _; } + function(uint a) {} +} +// ---- +// ParserError: (51-52): Unexpected trailing comma in parameter list. diff --git a/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol new file mode 100644 index 00000000..2dd8f196 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol @@ -0,0 +1,5 @@ +contract test { + function() returns (uint a, uint b,) {} +} +// ---- +// ParserError: (54-55): Unexpected trailing comma in parameter list. diff --git a/test/libsolidity/syntaxTests/parsing/new_address_payable.sol b/test/libsolidity/syntaxTests/parsing/new_address_payable.sol new file mode 100644 index 00000000..a52001db --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/new_address_payable.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure returns(address payable[] memory m) { + m = new address payable[](10); + } +}
\ No newline at end of file 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/payable_accessor.sol b/test/libsolidity/syntaxTests/parsing/payable_accessor.sol index 6504004b..0bc85784 100644 --- a/test/libsolidity/syntaxTests/parsing/payable_accessor.sol +++ b/test/libsolidity/syntaxTests/parsing/payable_accessor.sol @@ -2,4 +2,4 @@ contract test { uint payable x; } // ---- -// ParserError: (22-29): Expected identifier but got 'payable' +// ParserError: (22-29): State mutability can only be specified for address types. diff --git a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol new file mode 100644 index 00000000..a50855c0 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol @@ -0,0 +1,8 @@ +contract c { + function fun() public returns (uint r) { + uint _ = 8; + return _ + 1; + } +} +// ---- +// Warning: (17-105): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol b/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol new file mode 100644 index 00000000..3395f6be --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol @@ -0,0 +1,4 @@ +pragma ``; +// ---- +// ParserError: (7-8): Token incompatible with Solidity parser as part of pragma directive. +// ParserError: (8-9): Token incompatible with Solidity parser as part of pragma directive. 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/struct_definition.sol b/test/libsolidity/syntaxTests/parsing/struct_definition.sol new file mode 100644 index 00000000..0c859e5d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/struct_definition.sol @@ -0,0 +1,7 @@ +contract test { + uint256 stateVar; + struct MyStructName { + address addr; + uint256 count; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol new file mode 100644 index 00000000..d91c385a --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol @@ -0,0 +1,7 @@ +contract test { + uint256 a = 2.2e10; + uint256 b = .5E10; + uint256 c = 4.e-2; +} +// ---- +// TypeError: (70-73): Member "e" not found or not visible after argument-dependent lookup in int_const 4. diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol new file mode 100644 index 00000000..38a7ab2d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol @@ -0,0 +1,7 @@ +contract test { + uint256 a = 2.2e10; + uint256 b = .5E10; + uint256 c = 2 + 2.; +} +// ---- +// ParserError: (76-77): Expected identifier but got ';' diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol new file mode 100644 index 00000000..6a126cb3 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol @@ -0,0 +1,4 @@ +contract test { + uint a = 2. +// ---- +// ParserError: (29-29): Expected identifier but got end of source diff --git a/test/libsolidity/syntaxTests/parsing/tuples.sol b/test/libsolidity/syntaxTests/parsing/tuples.sol index 6f739740..875556e9 100644 --- a/test/libsolidity/syntaxTests/parsing/tuples.sol +++ b/test/libsolidity/syntaxTests/parsing/tuples.sol @@ -1,24 +1,11 @@ contract C { - function f() { + function f() public pure { uint a = (1); - var (b,) = (1,); - var (c,d) = (1, 2 + a); - var (e,) = (1, 2, b); + (uint b,) = (1,2); + (uint c, uint d) = (1, 2 + a); + (uint e,) = (1, b); (a) = 3; + a;b;c;d;e; } } // ---- -// 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 diff --git a/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol b/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol new file mode 100644 index 00000000..dba3e7ac --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + (uint a, uint b, uint c); + } +} +// ---- +// ParserError: (76-77): Expected '=' but got ';' diff --git a/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol b/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol new file mode 100644 index 00000000..957740d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol @@ -0,0 +1,9 @@ +// with support of overloaded functions, during parsing, +// we can't determine whether they match exactly, however +// it will throw DeclarationError in following stage. +contract test { + function fun(uint a) public returns(uint r) { return a; } + function fun(uint a) public returns(uint r) { return a; } +} +// ---- +// DeclarationError: (189-246): Function with same name and arguments defined twice. diff --git a/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol b/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol new file mode 100644 index 00000000..5646c43b --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol @@ -0,0 +1,8 @@ +contract test { + function f(uint x) pure public { + uint y = +x; + y; + } +} +// ---- +// SyntaxError: (70-72): Use of unary + is disallowed. diff --git a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol new file mode 100644 index 00000000..db890b37 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol @@ -0,0 +1,14 @@ +contract c { + uint private a; + uint internal b; + uint public c; + uint d; + function f() public {} + function f_priv() private {} + function f_internal() internal {} +} +// ---- +// Warning: (58-71): This declaration shadows an existing declaration. +// 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 new file mode 100644 index 00000000..dbb00a69 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/while_loop.sol @@ -0,0 +1,7 @@ +contract test { + function fun() public pure { + uint256 x; + while (true) { x = 1; break; continue; } x = 9; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/pragma/invalid_pragma.sol b/test/libsolidity/syntaxTests/pragma/invalid_pragma.sol new file mode 100644 index 00000000..cb2585ba --- /dev/null +++ b/test/libsolidity/syntaxTests/pragma/invalid_pragma.sol @@ -0,0 +1,3 @@ +pragma 0; +// ---- +// SyntaxError: (0-9): Invalid pragma "0" diff --git a/test/libsolidity/syntaxTests/pragma/unknown_pragma.sol b/test/libsolidity/syntaxTests/pragma/unknown_pragma.sol new file mode 100644 index 00000000..3a48eddd --- /dev/null +++ b/test/libsolidity/syntaxTests/pragma/unknown_pragma.sol @@ -0,0 +1,3 @@ +pragma thisdoesntexist; +// ---- +// SyntaxError: (0-23): Unknown pragma "thisdoesntexist" diff --git a/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number.sol b/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number.sol new file mode 100644 index 00000000..9741fdfb --- /dev/null +++ b/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number.sol @@ -0,0 +1,14 @@ +contract C +{ + function f() public pure returns (uint) + { + return; + } + function g() public pure returns (uint) + { + return (1, 2); + } +} +// ---- +// TypeError: (71-78): Return arguments required. +// TypeError: (143-156): Different number of arguments in return statement than in returns declaration. diff --git a/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number_named.sol b/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number_named.sol new file mode 100644 index 00000000..53f2d994 --- /dev/null +++ b/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number_named.sol @@ -0,0 +1,14 @@ +contract C +{ + function f() public pure returns (uint a) + { + return; + } + function g() public pure returns (uint a) + { + return (1, 2); + } +} +// ---- +// TypeError: (73-80): Return arguments required. +// TypeError: (147-160): Different number of arguments in return statement than in returns declaration. diff --git a/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number.sol b/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number.sol new file mode 100644 index 00000000..4ea61c68 --- /dev/null +++ b/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number.sol @@ -0,0 +1,19 @@ +contract C +{ + function f() public pure returns (uint, uint) + { + return 1; + } + function g() public pure returns (uint, uint) + { + return (1, 2, 3); + } + function h() public pure returns (uint, uint) + { + return; + } +} +// ---- +// TypeError: (77-85): Different number of arguments in return statement than in returns declaration. +// TypeError: (157-173): Different number of arguments in return statement than in returns declaration. +// TypeError: (245-252): Return arguments required. diff --git a/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number_named.sol b/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number_named.sol new file mode 100644 index 00000000..86049719 --- /dev/null +++ b/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number_named.sol @@ -0,0 +1,19 @@ +contract C +{ + function f() public pure returns (uint a, uint b) + { + return 1; + } + function g() public pure returns (uint a, uint b) + { + return (1, 2, 3); + } + function h() public pure returns (uint a, uint b) + { + return; + } +} +// ---- +// TypeError: (81-89): Different number of arguments in return statement than in returns declaration. +// TypeError: (165-181): Different number of arguments in return statement than in returns declaration. +// TypeError: (257-264): Return arguments required. diff --git a/test/libsolidity/syntaxTests/returnExpressions/valid_returns.sol b/test/libsolidity/syntaxTests/returnExpressions/valid_returns.sol new file mode 100644 index 00000000..e30f9173 --- /dev/null +++ b/test/libsolidity/syntaxTests/returnExpressions/valid_returns.sol @@ -0,0 +1,18 @@ +contract C +{ + function f() public pure { + return; + } + function g() public pure returns (uint) { + return 1; + } + function h() public pure returns (uint a) { + return 1; + } + function i() public pure returns (uint, uint) { + return (1, 2); + } + function j() public pure returns (uint a, uint b) { + return (1, 2); + } +} 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/double_variable_declaration_same_and_disjoint_scope.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_same_and_disjoint_scope.sol new file mode 100644 index 00000000..45c5ff2d --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_same_and_disjoint_scope.sol @@ -0,0 +1,10 @@ +contract test { + function f() pure public { + uint x; + { uint x; } + uint x; + } +} +// ---- +// Warning: (73-79): This declaration shadows an existing declaration. +// DeclarationError: (91-97): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_same_scope.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_same_scope.sol new file mode 100644 index 00000000..72c31f73 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_same_scope.sol @@ -0,0 +1,8 @@ +contract test { + function f() pure public { + uint x; + uint x; + } +} +// ---- +// DeclarationError: (71-77): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol b/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol new file mode 100644 index 00000000..d717981b --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint) public pure {} + uint public f = 0; +} +// ---- +// DeclarationError: (53-70): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/poly_variable_declaration_same_scope.sol b/test/libsolidity/syntaxTests/scoping/poly_variable_declaration_same_scope.sol new file mode 100644 index 00000000..e414f611 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/poly_variable_declaration_same_scope.sol @@ -0,0 +1,16 @@ +contract test { + function f() pure public { + uint x; + uint x; + uint x; + uint x; + uint x; + uint x; + } +} +// ---- +// DeclarationError: (71-77): Identifier already declared. +// DeclarationError: (87-93): Identifier already declared. +// DeclarationError: (103-109): Identifier already declared. +// DeclarationError: (119-125): Identifier already declared. +// DeclarationError: (135-141): Identifier already declared. 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/scoping/state_variable_function_conflict.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol new file mode 100644 index 00000000..0c732f7f --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol @@ -0,0 +1,6 @@ +contract C { + uint public f = 0; + function f(uint) public pure {} +} +// ---- +// DeclarationError: (40-71): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol new file mode 100644 index 00000000..fb9180c6 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol @@ -0,0 +1,14 @@ +// This used to crash with some compiler versions. +contract SomeContract { + + uint public balance = 0; + + function balance(uint number) public {} + + function doSomething() public { + balance(3); + } +} +// ---- +// DeclarationError: (106-145): Identifier already declared. +// TypeError: (185-195): Type is not callable diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_calldata.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_calldata.sol new file mode 100644 index 00000000..28d2f2e7 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_calldata.sol @@ -0,0 +1,8 @@ +// This restriction might be lifted in the future +contract C { + function f() public pure { + abi.decode("abc", (bytes calldata)); + } +} +// ---- +// ParserError: (121-129): Expected ',' but got 'calldata' diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_empty.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_empty.sol new file mode 100644 index 00000000..9972f01d --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_empty.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + abi.decode("abc", ()); + } +} +// ---- +// Warning: (52-73): Statement has no effect. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_invalid_arg_count.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_invalid_arg_count.sol new file mode 100644 index 00000000..f903e1ed --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_invalid_arg_count.sol @@ -0,0 +1,12 @@ +contract C { + function f() public pure { + abi.decode(); + abi.decode(msg.data); + abi.decode(msg.data, uint, uint); + } +} +// ---- +// TypeError: (46-58): This function takes two arguments, but 0 were provided. +// TypeError: (64-84): This function takes two arguments, but 1 were provided. +// TypeError: (90-122): This function takes two arguments, but 3 were provided. +// TypeError: (111-115): The second argument to "abi.decode" has to be a tuple of types. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory.sol new file mode 100644 index 00000000..e4667e34 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + abi.decode("abc", (bytes memory, uint[][2] memory)); + } +} +// ---- +// ParserError: (71-77): Expected ',' but got 'memory' diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory_v2.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory_v2.sol new file mode 100644 index 00000000..8a7462d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory_v2.sol @@ -0,0 +1,10 @@ +pragma experimental "ABIEncoderV2"; + +contract C { + struct S { uint x; uint[] b; } + function f() public pure returns (S memory, bytes memory, uint[][2] memory) { + return abi.decode("abc", (S, bytes, uint[][2])); + } +} +// ---- +// Warning: (0-35): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nontuple.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nontuple.sol new file mode 100644 index 00000000..d813c712 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nontuple.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + abi.decode("abc", uint); + abi.decode("abc", this); + abi.decode("abc", f()); + } +} +// ---- +// TypeError: (64-68): The second argument to "abi.decode" has to be a tuple of types. +// TypeError: (93-97): The second argument to "abi.decode" has to be a tuple of types. +// TypeError: (122-125): The second argument to "abi.decode" has to be a tuple of types. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_simple.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_simple.sol new file mode 100644 index 00000000..356ee91c --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_simple.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure returns (uint, bytes32, C) { + return abi.decode("abc", (uint, bytes32, C)); + } +} diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_single_return.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_single_return.sol new file mode 100644 index 00000000..654b7873 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_single_return.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure returns (bool) { + return abi.decode("abc", (uint)) == 2; + } +} diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_singletontuple.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_singletontuple.sol new file mode 100644 index 00000000..57eccacf --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_singletontuple.sol @@ -0,0 +1,6 @@ +contract C { + function f() public pure returns (uint) { + return abi.decode("abc", (uint)); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_storage.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_storage.sol new file mode 100644 index 00000000..d9910b64 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_storage.sol @@ -0,0 +1,8 @@ +// This restriction might be lifted in the future +contract C { + function f() { + abi.decode("abc", (bytes storage)); + } +} +// ---- +// ParserError: (109-116): Expected ',' but got 'storage' diff --git a/test/libsolidity/syntaxTests/specialFunctions/encodePacked_array_of_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/encodePacked_array_of_structs.sol new file mode 100644 index 00000000..036e108a --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/encodePacked_array_of_structs.sol @@ -0,0 +1,9 @@ +contract C { + struct S { uint x; } + function f() public pure { + S[] memory s; + abi.encodePacked(s); + } +} +// ---- +// TypeError: (116-117): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/encode_array_of_struct.sol b/test/libsolidity/syntaxTests/specialFunctions/encode_array_of_struct.sol new file mode 100644 index 00000000..7a4d8250 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/encode_array_of_struct.sol @@ -0,0 +1,10 @@ +pragma experimental ABIEncoderV2; +contract C { + struct S { uint x; } + function f() public pure { + S[] memory s; + abi.encode(s); + } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. 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..6e0b6db4 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); - a; b; + (bool a,) = address(this).call(abi.encode(address(this).delegatecall, super)); + (a,) = address(this).delegatecall(abi.encode(log0, tx, mulmod)); + a; } } // ---- -// 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: (94-120): This type cannot be encoded. +// TypeError: (122-127): This type cannot be encoded. +// TypeError: (184-188): This type cannot be encoded. +// TypeError: (190-192): This type cannot be encoded. +// TypeError: (194-200): 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/string/string_escapes.sol b/test/libsolidity/syntaxTests/string/string_escapes.sol new file mode 100644 index 00000000..51b90d73 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_escapes.sol @@ -0,0 +1,7 @@ +contract test { + function f() public pure returns (bytes32) { + bytes32 escapeCharacters = "\t\b\n\r\f\'\"\\\b"; + return escapeCharacters; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/string/string_new_line.sol b/test/libsolidity/syntaxTests/string/string_new_line.sol new file mode 100644 index 00000000..da2240f7 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_new_line.sol @@ -0,0 +1,9 @@ +contract test { + function f() public pure returns (bytes32) { + bytes32 escapeCharacters = "This a test + "; + return escapeCharacters; + } +} +// ---- +// ParserError: (100-112): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol b/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol new file mode 100644 index 00000000..3eaba6af --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol @@ -0,0 +1,8 @@ +contract test { + function f() public pure returns (bytes32) { + bytes32 escapeCharacters = "text \"; + return escapeCharacters; + } +} +// ---- +// ParserError: (100-109): Expected primary expression.
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/string/string_unterminated.sol b/test/libsolidity/syntaxTests/string/string_unterminated.sol new file mode 100644 index 00000000..3291781e --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_unterminated.sol @@ -0,0 +1,7 @@ +contract test { + function f() public pure returns (bytes32) { + bytes32 escapeCharacters = "This a test + } +} +// ---- +// ParserError: (100-112): Expected primary expression.
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol b/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol new file mode 100644 index 00000000..e7be50d2 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol @@ -0,0 +1,4 @@ +contract test { + function f() pure public { "abc\ +// ---- +// ParserError: (47-53): Expected primary expression.
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol b/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol index 895bb6c5..e8ece3bc 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol @@ -9,7 +9,7 @@ contract C { struct W { uint x; } - function f(T) public pure { } + function f(T memory) public pure { } } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol index 96362ef0..e9b25453 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol @@ -9,7 +9,7 @@ contract TestContract SubStruct subStruct1; SubStruct subStruct2; } - function addTestStruct(TestStruct) public pure {} + function addTestStruct(TestStruct memory) public pure {} } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol index 4966a731..c8f9185c 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol @@ -1,7 +1,7 @@ contract C { struct S { uint a; S[] sub; } - function f() public pure returns (uint, S) { + function f() public pure returns (uint, S memory) { } } // ---- -// TypeError: (91-92): Internal or recursive type is not allowed for public or external functions. +// TypeError: (91-99): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol index 68113924..a8b7ac75 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol @@ -1,7 +1,7 @@ contract C { struct S { uint a; S[2][] sub; } - function f() public pure returns (uint, S) { + function f() public pure returns (uint, S memory) { } } // ---- -// TypeError: (94-95): Internal or recursive type is not allowed for public or external functions. +// TypeError: (94-102): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol index 47690d9b..0a5b1bc8 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol @@ -1,8 +1,8 @@ contract C { struct S { uint a; S[][][] sub; } struct T { S s; } - function f() public pure returns (uint x, T t) { + function f() public pure returns (uint x, T memory t) { } } // ---- -// TypeError: (119-122): Internal or recursive type is not allowed for public or external functions. +// TypeError: (119-129): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive_dynamic_array.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive_dynamic_array.sol new file mode 100644 index 00000000..d847f17c --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive_dynamic_array.sol @@ -0,0 +1,7 @@ +contract Test { + struct MyStructName { + address addr; + MyStructName[] x; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive_fixed_array.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive_fixed_array.sol new file mode 100644 index 00000000..126dda4f --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive_fixed_array.sol @@ -0,0 +1,8 @@ +contract Test { + struct MyStructName { + address addr; + MyStructName[1] x; + } +} +// ---- +// TypeError: (20-96): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_complex.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_complex.sol new file mode 100644 index 00000000..6d35a5d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_complex.sol @@ -0,0 +1,18 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName4[1] x; + } + struct MyStructName2 { + MyStructName1 x; + } + struct MyStructName3 { + MyStructName2[1] x; + } + struct MyStructName4 { + MyStructName3 x; + } +} +// ---- +// TypeError: (20-121): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array1.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array1.sol new file mode 100644 index 00000000..10d7de2c --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array1.sol @@ -0,0 +1,11 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2[] x; + } + struct MyStructName2 { + MyStructName1 x; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array2.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array2.sol new file mode 100644 index 00000000..f20510ca --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array2.sol @@ -0,0 +1,11 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2 x; + } + struct MyStructName2 { + MyStructName1[] x; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array3.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array3.sol new file mode 100644 index 00000000..69747e71 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_array3.sol @@ -0,0 +1,11 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2[] x; + } + struct MyStructName2 { + MyStructName1[] x; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_multi_array.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_multi_array.sol new file mode 100644 index 00000000..b3507828 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_dynamic_multi_array.sol @@ -0,0 +1,21 @@ +contract Test { + struct S1 { + S2[1][] x; + } + struct S2 { + S1 x; + } + struct T1 { + T2[][1] x; + } + struct T2 { + T1 x; + } + struct R1 { + R2[][] x; + } + struct R2 { + R1 x; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array1.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array1.sol new file mode 100644 index 00000000..2c0b90ec --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array1.sol @@ -0,0 +1,12 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2[1] x; + } + struct MyStructName2 { + MyStructName1 x; + } +} +// ---- +// TypeError: (20-121): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array2.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array2.sol new file mode 100644 index 00000000..3178e569 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array2.sol @@ -0,0 +1,12 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2 x; + } + struct MyStructName2 { + MyStructName1[1] x; + } +} +// ---- +// TypeError: (20-118): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array3.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array3.sol new file mode 100644 index 00000000..e34cf9bc --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_array3.sol @@ -0,0 +1,12 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2[1] x; + } + struct MyStructName2 { + MyStructName1[1] x; + } +} +// ---- +// TypeError: (20-121): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_multi_array.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_multi_array.sol new file mode 100644 index 00000000..ed659b6e --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive_fixed_multi_array.sol @@ -0,0 +1,12 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2[1][1] x; + } + struct MyStructName2 { + MyStructName1 x; + } +} +// ---- +// TypeError: (20-124): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive_array.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive_array.sol new file mode 100644 index 00000000..b2053b8a --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive_array.sol @@ -0,0 +1,4 @@ +contract Test { + struct S1 { uint a; } + struct S2 { S1[1] x; S1[1] y; } +} diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol index a190adc3..0fc1fc08 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) { + function k() pure public returns (bytes memory) { 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. +// TypeError: (99-100): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol deleted file mode 100644 index b7557d2a..00000000 --- a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol +++ /dev/null @@ -1,34 +0,0 @@ -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. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol index 2b9b688a..45fc1f72 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol @@ -1,30 +1,9 @@ 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) { + function k() pure public returns (bytes memory) { return abi.encodePacked(uint8(1)); } - function l() pure public returns (bytes) { + function l() pure public returns (bytes memory) { return abi.encode(1); } } // ---- -// 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/double_storage_crash.sol b/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol new file mode 100644 index 00000000..3cff3a9a --- /dev/null +++ b/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol @@ -0,0 +1,11 @@ +// This used to crash in certain compiler versions. +contract CrashContract { + struct S { uint a; } + S x; + function f() public { + (x, x) = 1(x, x); + } +} +// ---- +// TypeError: (170-177): Type is not callable +// TypeError: (170-177): Type tuple() is not implicitly convertible to expected type tuple(struct CrashContract.S storage ref,struct CrashContract.S storage ref). 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/error_fill.sol b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol index 5b7f870b..32b381bb 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract C { function f() public pure returns (uint, uint, bytes32) { uint a; @@ -8,5 +7,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: (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/large_component_count.sol b/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol index bbf21d7e..f14641cb 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract C { function g() public pure returns ( uint, 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 deleted file mode 100644 index 1d243c7c..00000000 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol +++ /dev/null @@ -1,11 +0,0 @@ -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(); - 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). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol deleted file mode 100644 index b2979804..00000000 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol +++ /dev/null @@ -1,10 +0,0 @@ -contract C { - struct S { uint a; uint b; } - S x; S y; - function f() public { - (,x, y) = (1, 2, y, x); - } -} -// ---- -// 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/warn_multiple_storage_storage_copies_fill_right.sol deleted file mode 100644 index aa35d7d4..00000000 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol +++ /dev/null @@ -1,10 +0,0 @@ -contract C { - struct S { uint a; uint b; } - S x; S y; - function f() public { - (x, y, ) = (y, x, 1, 2); - } -} -// ---- -// 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/types/address/address_abi_decode.sol b/test/libsolidity/syntaxTests/types/address/address_abi_decode.sol new file mode 100644 index 00000000..7be61ad2 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_abi_decode.sol @@ -0,0 +1,6 @@ +contract C { + function f(bytes memory b) public pure returns (address payable) { + (address payable c) = abi.decode(b, (address)); + return c; + } +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/types/address/address_constant.sol b/test/libsolidity/syntaxTests/types/address/address_constant.sol new file mode 100644 index 00000000..0b1af991 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_constant.sol @@ -0,0 +1,7 @@ +contract C { + address constant a = address(0); + address payable constant b = address(0); + function f() public pure returns (address, address) { + return (a,b); + } +} diff --git a/test/libsolidity/syntaxTests/types/address/address_constant_assignment.sol b/test/libsolidity/syntaxTests/types/address/address_constant_assignment.sol new file mode 100644 index 00000000..da17ae33 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_constant_assignment.sol @@ -0,0 +1,11 @@ +contract C { + address constant a = address(0); + address payable constant b = address(0); + function f() public { + a = address(0); + b = address(0); + } +} +// ---- +// TypeError: (129-130): Cannot assign to a constant variable. +// TypeError: (153-154): Cannot assign to a constant variable. diff --git a/test/libsolidity/syntaxTests/types/address/address_in_struct_fail.sol b/test/libsolidity/syntaxTests/types/address/address_in_struct_fail.sol new file mode 100644 index 00000000..9a5b2abb --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_in_struct_fail.sol @@ -0,0 +1,11 @@ +contract A { + struct S { + address payable a; + } + S s; + function f() public { + s.a = address(this); + } +} +// ---- +// TypeError: (110-123): Type address is not implicitly convertible to expected type address payable. diff --git a/test/libsolidity/syntaxTests/types/address/address_in_struct_fine.sol b/test/libsolidity/syntaxTests/types/address/address_in_struct_fine.sol new file mode 100644 index 00000000..5519f0ef --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_in_struct_fine.sol @@ -0,0 +1,20 @@ +contract A { + struct S { + address a; + } + S s; + function f() public { + s.a = address(this); + } +} +contract B { + struct S { + address payable a; + } + S s; + function f() public { + s.a = address(this); + } + function() external payable { + } +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/types/address/address_members_in_contract.sol b/test/libsolidity/syntaxTests/types/address/address_members_in_contract.sol new file mode 100644 index 00000000..eafc8268 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_members_in_contract.sol @@ -0,0 +1,6 @@ +contract C { + function f() public returns (C) { return this; } + function g() public returns (uint) { return f().balance(); } +} +// ---- +// TypeError: (114-125): Member "balance" not found or not visible after argument-dependent lookup in contract C. Use "address(...).balance" to access this address member. diff --git a/test/libsolidity/syntaxTests/types/address/address_nonpayable_selfdestruct.sol b/test/libsolidity/syntaxTests/types/address/address_nonpayable_selfdestruct.sol new file mode 100644 index 00000000..cc680ff3 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_nonpayable_selfdestruct.sol @@ -0,0 +1,7 @@ +contract C { + function f(address a) public { + selfdestruct(a); + } +} +// ---- +// TypeError: (69-70): Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested. diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_external_overload.sol b/test/libsolidity/syntaxTests/types/address/address_payable_external_overload.sol new file mode 100644 index 00000000..875532c4 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_payable_external_overload.sol @@ -0,0 +1,7 @@ +contract C { + function f(address) external pure {} + function f(address payable) external pure {} + +} +// ---- +// TypeError: (58-102): Function overload clash during conversion to external types for arguments. diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_nonpayable.sol b/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_nonpayable.sol new file mode 100644 index 00000000..65600544 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_nonpayable.sol @@ -0,0 +1,10 @@ +contract C { + function f(address payable) internal pure {} + function f(address) internal pure returns (uint) {} + function g() internal pure { + address a = address(0); + uint b = f(a); // TODO: should this be valid? + b; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_payable.sol b/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_payable.sol new file mode 100644 index 00000000..84142a31 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_payable.sol @@ -0,0 +1,10 @@ +contract C { + function f(address payable) internal pure {} + function f(address) internal pure {} + function g() internal pure { + address payable a = address(0); + f(a); + } +} +// ---- +// TypeError: (184-185): No unique declaration found after argument-dependent lookup. diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_memory_array_conversion.sol b/test/libsolidity/syntaxTests/types/address/address_payable_memory_array_conversion.sol new file mode 100644 index 00000000..ec58170b --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_payable_memory_array_conversion.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + address payable[] memory a = new address payable[](4); + address[] memory b = new address[](4); + a = b; + b = a; + } +} +// ---- +// TypeError: (166-167): Type address[] memory is not implicitly convertible to expected type address payable[] memory. +// TypeError: (181-182): Type address payable[] memory is not implicitly convertible to expected type address[] memory. diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_public_overload.sol b/test/libsolidity/syntaxTests/types/address/address_payable_public_overload.sol new file mode 100644 index 00000000..839abc26 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_payable_public_overload.sol @@ -0,0 +1,7 @@ +contract C { + function f(address) public pure {} + function f(address payable) public pure {} + +} +// ---- +// TypeError: (56-98): Function overload clash during conversion to external types for arguments. diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_selfdestruct.sol b/test/libsolidity/syntaxTests/types/address/address_payable_selfdestruct.sol new file mode 100644 index 00000000..bdf43be7 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_payable_selfdestruct.sol @@ -0,0 +1,5 @@ +contract C { + function f(address payable a) public { + selfdestruct(a); + } +} diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion.sol b/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion.sol new file mode 100644 index 00000000..40f85ccc --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion.sol @@ -0,0 +1,11 @@ +contract C { + address payable[] a; + address[] b; + function f() public view { + address payable[] storage c = a; + address[] storage d = b; + d = c; // TODO: this could be allowed in the future + } +} +// ---- +// TypeError: (172-173): Type address payable[] storage pointer is not implicitly convertible to expected type address[] storage pointer. diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion_fail.sol b/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion_fail.sol new file mode 100644 index 00000000..3c3eb859 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion_fail.sol @@ -0,0 +1,11 @@ +contract C { + address payable[] a; + address[] b; + function f() public view { + address payable[] storage c = a; + address[] storage d = b; + c = d; + } +} +// ---- +// TypeError: (172-173): Type address[] storage pointer is not implicitly convertible to expected type address payable[] storage pointer. diff --git a/test/libsolidity/syntaxTests/types/address/address_to_contract.sol b/test/libsolidity/syntaxTests/types/address/address_to_contract.sol new file mode 100644 index 00000000..629a3df0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_to_contract.sol @@ -0,0 +1,6 @@ +contract C { + function f() public pure returns (C c) { + c = C(address(2)); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/address/address_to_contract_implicitly.sol b/test/libsolidity/syntaxTests/types/address/address_to_contract_implicitly.sol new file mode 100644 index 00000000..c9e5ddf6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_to_contract_implicitly.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view { + C c = address(2); + } +} +// ---- +// TypeError: (46-62): Type address payable is not implicitly convertible to expected type contract C. diff --git a/test/libsolidity/syntaxTests/types/address/address_to_contract_payable_fallback.sol b/test/libsolidity/syntaxTests/types/address/address_to_contract_payable_fallback.sol new file mode 100644 index 00000000..6917444b --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_to_contract_payable_fallback.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure returns (C c) { + c = C(address(2)); + } + function() external payable { + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/address/address_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/address_to_payable_address.sol new file mode 100644 index 00000000..1aab9b51 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_to_payable_address.sol @@ -0,0 +1,10 @@ +contract C { + function f(address a) public pure { + address b; + address payable c = a; + c = b; + } +} +// ---- +// TypeError: (80-101): Type address is not implicitly convertible to expected type address payable. +// TypeError: (115-116): Type address is not implicitly convertible to expected type address payable. diff --git a/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol b/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol new file mode 100644 index 00000000..1e755033 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol @@ -0,0 +1,7 @@ +contract C { + function f(address a) public pure returns (address payable) { + return address(address(a)); + } +} +// ---- +// TypeError: (94-113): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable. diff --git a/test/libsolidity/syntaxTests/types/address/address_tuple_fail.sol b/test/libsolidity/syntaxTests/types/address/address_tuple_fail.sol new file mode 100644 index 00000000..17e9e7c1 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_tuple_fail.sol @@ -0,0 +1,8 @@ +contract C { + function f() public view returns (address payable a, address b) { + (address c, address payable d) = (address(this), address(0)); + (a,b) = (c,d); + } +} +// ---- +// TypeError: (169-174): Type tuple(address,address payable) is not implicitly convertible to expected type tuple(address payable,address). diff --git a/test/libsolidity/syntaxTests/types/address/address_tuple_fine.sol b/test/libsolidity/syntaxTests/types/address/address_tuple_fine.sol new file mode 100644 index 00000000..846de1f4 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_tuple_fine.sol @@ -0,0 +1,6 @@ +contract C { + function f() public view returns (address payable a, address b) { + (address c, address payable d) = (address(this), address(0)); + (a,b) = (d,c); + } +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol new file mode 100644 index 00000000..ef87ac55 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol @@ -0,0 +1,8 @@ +contract C { + function f(bytes32 x) public pure returns (address payable) { + return address(x); + } +} +// ---- +// TypeError: (94-104): Explicit type conversion not allowed from "bytes32" to "address". +// TypeError: (94-104): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable. diff --git a/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol new file mode 100644 index 00000000..2aa60251 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol @@ -0,0 +1,8 @@ +contract C { + function f(bytes10 x) public pure returns (address payable) { + return address(x); + } +} +// ---- +// TypeError: (94-104): Explicit type conversion not allowed from "bytes10" to "address". +// TypeError: (94-104): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable. diff --git a/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol new file mode 100644 index 00000000..5b6a6714 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol @@ -0,0 +1,5 @@ +contract C { + function f(bytes20 x) public pure returns (address payable) { + return address(x); + } +} diff --git a/test/libsolidity/syntaxTests/types/address/contract_no_fallback_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/contract_no_fallback_to_payable_address.sol new file mode 100644 index 00000000..777bce00 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/contract_no_fallback_to_payable_address.sol @@ -0,0 +1,8 @@ +contract C { + function f() public view { + address payable a = address(this); + a; + } +} +// ---- +// TypeError: (46-79): Type address is not implicitly convertible to expected type address payable. diff --git a/test/libsolidity/syntaxTests/types/address/contract_non_payable_fallback_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/contract_non_payable_fallback_to_payable_address.sol new file mode 100644 index 00000000..6518eebb --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/contract_non_payable_fallback_to_payable_address.sol @@ -0,0 +1,10 @@ +contract C { + function f() public view { + address payable a = address(this); + a; + } + function() external { + } +} +// ---- +// TypeError: (46-79): Type address is not implicitly convertible to expected type address payable. diff --git a/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address.sol new file mode 100644 index 00000000..359beeb4 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address.sol @@ -0,0 +1,9 @@ +contract C { + function f() public view { + address payable a = address(this); + a; + } + function() external payable { + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address_implicitly.sol b/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address_implicitly.sol new file mode 100644 index 00000000..4b20b1c6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address_implicitly.sol @@ -0,0 +1,10 @@ +contract C { + function f() public view { + address payable a = this; + a; + } + function() external payable { + } +} +// ---- +// TypeError: (46-70): Type contract C is not implicitly convertible to expected type address payable. diff --git a/test/libsolidity/syntaxTests/types/address/contract_to_address.sol b/test/libsolidity/syntaxTests/types/address/contract_to_address.sol new file mode 100644 index 00000000..ec2f8184 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/contract_to_address.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view { + address a = address(this); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/address/contract_to_address_implicitly.sol b/test/libsolidity/syntaxTests/types/address/contract_to_address_implicitly.sol new file mode 100644 index 00000000..8be9daac --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/contract_to_address_implicitly.sol @@ -0,0 +1,8 @@ +contract C { + function f() public view { + address a = this; + a; + } +} +// ---- +// TypeError: (46-62): Type contract C is not implicitly convertible to expected type address. diff --git a/test/libsolidity/syntaxTests/types/address/literal_to_address.sol b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol new file mode 100644 index 00000000..20ee56de --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + address a = address(0); + a = address(1); + address b = 0x0123456789012345678901234567890123456789; + b = 0x9876543210987654321098765432109876543210; + b = 0x9876_5432_1098_7654_3210_9876_5432_1098_7654_3210; + } +} diff --git a/test/libsolidity/syntaxTests/types/address/literal_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/literal_to_payable_address.sol new file mode 100644 index 00000000..97f4d85d --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/literal_to_payable_address.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure { + address payable a = address(0); + a = address(1); + address payable b = 0x0123456789012345678901234567890123456789; + b = 0x9876543210987654321098765432109876543210; + } +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/types/address/nonpayable_address_to_contract_payable_fallback.sol b/test/libsolidity/syntaxTests/types/address/nonpayable_address_to_contract_payable_fallback.sol new file mode 100644 index 00000000..e13a0897 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/nonpayable_address_to_contract_payable_fallback.sol @@ -0,0 +1,10 @@ +contract C { + function f() public pure returns (C c) { + address a = address(2); + c = C(a); + } + function() external payable { + } +} +// ---- +// TypeError: (92-96): Explicit type conversion not allowed from non-payable "address" to "contract C", which has a payable fallback function. diff --git a/test/libsolidity/syntaxTests/types/address/payable_address_to_address.sol b/test/libsolidity/syntaxTests/types/address/payable_address_to_address.sol new file mode 100644 index 00000000..f5dbf937 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/payable_address_to_address.sol @@ -0,0 +1,7 @@ +contract C { + function f(address payable a) public pure { + address payable b; + address c = a; + c = b; + } +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol new file mode 100644 index 00000000..9a33985a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol @@ -0,0 +1,5 @@ +contract C { + function f(uint x) public pure returns (address payable) { + return address(x); + } +} diff --git a/test/libsolidity/syntaxTests/types/array_index_too_large.sol b/test/libsolidity/syntaxTests/types/array_index_too_large.sol new file mode 100644 index 00000000..06b5071f --- /dev/null +++ b/test/libsolidity/syntaxTests/types/array_index_too_large.sol @@ -0,0 +1,8 @@ +contract C { + function f() public returns (string memory) { + // this used to cause an internal error + return (["zeppelin"][123456789012345678901234567890123456789012345678901234567890123456789012345678]); + } +} +// ---- +// TypeError: (140-218): Type int_const 1234...(70 digits omitted)...5678 is not implicitly convertible to expected type uint256.
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/types/bool_ops.sol b/test/libsolidity/syntaxTests/types/bool_ops.sol new file mode 100644 index 00000000..91033906 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/bool_ops.sol @@ -0,0 +1,53 @@ +contract C { + function f(bool a, bool b) public pure { + bool c; + // OK + c = !a; + c = !b; + c = a == b; + c = a != b; + c = a || b; + c = a && b; + + // Not OK + c = a > b; + c = a < b; + c = a >= b; + c = a <= b; + c = a & b; + c = a | b; + c = a ^ b; + c = ~a; + c = ~b; + c = a + b; + c = a - b; + c = -a; + c = -b; + c = a * b; + c = a / b; + c = a ** b; + c = a % b; + c = a << b; + c = a >> b; + } +} +// ---- +// TypeError: (231-236): Operator > not compatible with types bool and bool +// TypeError: (250-255): Operator < not compatible with types bool and bool +// TypeError: (269-275): Operator >= not compatible with types bool and bool +// TypeError: (289-295): Operator <= not compatible with types bool and bool +// TypeError: (309-314): Operator & not compatible with types bool and bool +// TypeError: (328-333): Operator | not compatible with types bool and bool +// TypeError: (347-352): Operator ^ not compatible with types bool and bool +// TypeError: (366-368): Unary operator ~ cannot be applied to type bool +// TypeError: (382-384): Unary operator ~ cannot be applied to type bool +// TypeError: (398-403): Operator + not compatible with types bool and bool +// TypeError: (417-422): Operator - not compatible with types bool and bool +// TypeError: (436-438): Unary operator - cannot be applied to type bool +// TypeError: (452-454): Unary operator - cannot be applied to type bool +// TypeError: (468-473): Operator * not compatible with types bool and bool +// TypeError: (487-492): Operator / not compatible with types bool and bool +// TypeError: (506-512): Operator ** not compatible with types bool and bool +// TypeError: (526-531): Operator % not compatible with types bool and bool +// TypeError: (545-551): Operator << not compatible with types bool and bool +// TypeError: (565-571): Operator >> not compatible with types bool and bool diff --git a/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol b/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol new file mode 100644 index 00000000..58828a62 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure returns(uint256) { + return uint256(bytes1('')); + } +} +// ---- +// TypeError: (76-95): Explicit type conversion not allowed from "bytes1" to "uint256". diff --git a/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol b/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol new file mode 100644 index 00000000..77e813ab --- /dev/null +++ b/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure returns(uint32) { + return uint32(bytes32('')); + } +} +// ---- +// TypeError: (75-94): Explicit type conversion not allowed from "bytes32" to "uint32". diff --git a/test/libsolidity/syntaxTests/types/bytes_to_contract.sol b/test/libsolidity/syntaxTests/types/bytes_to_contract.sol index 2a3219ec..820dbf9b 100644 --- a/test/libsolidity/syntaxTests/types/bytes_to_contract.sol +++ b/test/libsolidity/syntaxTests/types/bytes_to_contract.sol @@ -1,7 +1,7 @@ contract C { function f() public pure { - C(bytes20(0x1234)); + C(bytes20(uint160(0x1234))); } } // ---- -// TypeError: (64-82): Explicit type conversion not allowed from "bytes20" to "contract C". +// TypeError: (64-91): Explicit type conversion not allowed from "bytes20" to "contract C". diff --git a/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol b/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol new file mode 100644 index 00000000..2963cfd2 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol @@ -0,0 +1,20 @@ +contract C { + function f() public pure returns (uint256) { + return uint256(bytes32(uint256(0))); + } + function g() public pure returns (uint128) { + return uint128(bytes16(uint128(0))); + } + function h() public pure returns (uint64) { + return uint64(bytes8(uint64(0))); + } + function i() public pure returns (uint32) { + return uint32(bytes4(uint32(0))); + } + function j() public pure returns (uint16) { + return uint16(bytes2(uint16(0))); + } + function k() public pure returns (uint8) { + return uint8(bytes1(uint8(0))); + } +} diff --git a/test/libsolidity/syntaxTests/types/bytesm.sol b/test/libsolidity/syntaxTests/types/bytesm.sol index 550760b9..77ff7524 100644 --- a/test/libsolidity/syntaxTests/types/bytesm.sol +++ b/test/libsolidity/syntaxTests/types/bytesm.sol @@ -1,5 +1,5 @@ contract C { - byte b = byte(1); + byte b = byte(0x01); bytes1 b1 = b; bytes2 b2 = b1; bytes3 b3 = b2; diff --git a/test/libsolidity/syntaxTests/types/contract_to_base.sol b/test/libsolidity/syntaxTests/types/contract_to_base.sol new file mode 100644 index 00000000..b0a24e62 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_base.sol @@ -0,0 +1,9 @@ +contract A {} +contract B is A {} +contract C { + function f() public { + A a = new B(); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/contract_to_base_base.sol b/test/libsolidity/syntaxTests/types/contract_to_base_base.sol new file mode 100644 index 00000000..e99e5cdc --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_base_base.sol @@ -0,0 +1,10 @@ +contract A {} +contract B is A {} +contract C is B {} +contract D { + function f() public { + A a = new C(); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/contract_to_derived.sol b/test/libsolidity/syntaxTests/types/contract_to_derived.sol new file mode 100644 index 00000000..ac8df5d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_derived.sol @@ -0,0 +1,9 @@ +contract B {} +contract A is B {} +contract C { + function f() public pure { + A a = A(new B()); + } +} +// ---- +// TypeError: (85-95): Explicit type conversion not allowed from "contract B" to "contract A". diff --git a/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol b/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol new file mode 100644 index 00000000..b0a4875f --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol @@ -0,0 +1,9 @@ +contract A {} +contract B {} +contract C { + function f() public pure { + B b = B(new A()); + } +} +// ---- +// TypeError: (80-90): Explicit type conversion not allowed from "contract A" to "contract B". diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol new file mode 100644 index 00000000..c6669746 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol @@ -0,0 +1,262 @@ +contract A {} +contract Main { + A constant B = C; + A constant C = D; + A constant D = E; + A constant E = F; + A constant F = G; + A constant G = H; + A constant H = I; + A constant I = J; + A constant J = K; + A constant K = L; + A constant L = M; + A constant M = N; + A constant N = O; + A constant O = P; + A constant P = Q; + A constant Q = R; + A constant R = S; + A constant S = T; + A constant T = U; + A constant U = V; + A constant V = W; + A constant W = X; + A constant X = Y; + A constant Y = Z; + A constant Z = BA; + A constant BA = BB; + A constant BB = BC; + A constant BC = BD; + A constant BD = BE; + A constant BE = BF; + A constant BF = BG; + A constant BG = BH; + A constant BH = BI; + A constant BI = BJ; + A constant BJ = BK; + A constant BK = BL; + A constant BL = BM; + A constant BM = BN; + A constant BN = BO; + A constant BO = BP; + A constant BP = BQ; + A constant BQ = BR; + A constant BR = BS; + A constant BS = BT; + A constant BT = BU; + A constant BU = BV; + A constant BV = BW; + A constant BW = BX; + A constant BX = BY; + A constant BY = BZ; + A constant BZ = CA; + A constant CA = CB; + A constant CB = CC; + A constant CC = CD; + A constant CD = CE; + A constant CE = CF; + A constant CF = CG; + A constant CG = CH; + A constant CH = CI; + A constant CI = CJ; + A constant CJ = CK; + A constant CK = CL; + A constant CL = CM; + A constant CM = CN; + A constant CN = CO; + A constant CO = CP; + A constant CP = CQ; + A constant CQ = CR; + A constant CR = CS; + A constant CS = CT; + A constant CT = CU; + A constant CU = CV; + A constant CV = CW; + A constant CW = CX; + A constant CX = CY; + A constant CY = CZ; + A constant CZ = DA; + A constant DA = DB; + A constant DB = DC; + A constant DC = DD; + A constant DD = DE; + A constant DE = DF; + A constant DF = DG; + A constant DG = DH; + A constant DH = DI; + A constant DI = DJ; + A constant DJ = DK; + A constant DK = DL; + A constant DL = DM; + A constant DM = DN; + A constant DN = DO; + A constant DO = DP; + A constant DP = DQ; + A constant DQ = DR; + A constant DR = DS; + A constant DS = DT; + A constant DT = DU; + A constant DU = DV; + A constant DV = DW; + A constant DW = DX; + A constant DX = DY; + A constant DY = DZ; + A constant DZ = EA; + A constant EA = EB; + A constant EB = EC; + A constant EC = ED; + A constant ED = EE; + A constant EE = EF; + A constant EF = EG; + A constant EG = EH; + A constant EH = EI; + A constant EI = EJ; + A constant EJ = EK; + A constant EK = EL; + A constant EL = EM; + A constant EM = EN; + A constant EN = EO; + A constant EO = EP; + A constant EP = EQ; + A constant EQ = ER; + A constant ER = ES; + A constant ES = ET; + A constant ET = EU; + A constant EU = EV; + A constant EV = EW; + A constant EW = EX; + A constant EX = EY; + A constant EY = EZ; + A constant EZ = FA; + A constant FA = FB; + A constant FB = FC; + A constant FC = FD; + A constant FD = FE; + A constant FE = FF; + A constant FF = FG; + A constant FG = FH; + A constant FH = FI; + A constant FI = FJ; + A constant FJ = FK; + A constant FK = FL; + A constant FL = FM; + A constant FM = FN; + A constant FN = FO; + A constant FO = FP; + A constant FP = FQ; + A constant FQ = FR; + A constant FR = FS; + A constant FS = FT; + A constant FT = FU; + A constant FU = FV; + A constant FV = FW; + A constant FW = FX; + A constant FX = FY; + A constant FY = FZ; + A constant FZ = GA; + A constant GA = GB; + A constant GB = GC; + A constant GC = GD; + A constant GD = GE; + A constant GE = GF; + A constant GF = GG; + A constant GG = GH; + A constant GH = GI; + A constant GI = GJ; + A constant GJ = GK; + A constant GK = GL; + A constant GL = GM; + A constant GM = GN; + A constant GN = GO; + A constant GO = GP; + A constant GP = GQ; + A constant GQ = GR; + A constant GR = GS; + A constant GS = GT; + A constant GT = GU; + A constant GU = GV; + A constant GV = GW; + A constant GW = GX; + A constant GX = GY; + A constant GY = GZ; + A constant GZ = HA; + A constant HA = HB; + A constant HB = HC; + A constant HC = HD; + A constant HD = HE; + A constant HE = HF; + A constant HF = HG; + A constant HG = HH; + A constant HH = HI; + A constant HI = HJ; + A constant HJ = HK; + A constant HK = HL; + A constant HL = HM; + A constant HM = HN; + A constant HN = HO; + A constant HO = HP; + A constant HP = HQ; + A constant HQ = HR; + A constant HR = HS; + A constant HS = HT; + A constant HT = HU; + A constant HU = HV; + A constant HV = HW; + A constant HW = HX; + A constant HX = HY; + A constant HY = HZ; + A constant HZ = IA; + A constant IA = IB; + A constant IB = IC; + A constant IC = ID; + A constant ID = IE; + A constant IE = IF; + A constant IF = IG; + A constant IG = IH; + A constant IH = II; + A constant II = IJ; + A constant IJ = IK; + A constant IK = IL; + A constant IL = IM; + A constant IM = IN; + A constant IN = IO; + A constant IO = IP; + A constant IP = IQ; + A constant IQ = IR; + A constant IR = IS; + A constant IS = IT; + A constant IT = IU; + A constant IU = IV; + A constant IV = IW; + A constant IW = IX; + A constant IX = IY; + A constant IY = IZ; + A constant IZ = JA; + A constant JA = JB; + A constant JB = JC; + A constant JC = JD; + A constant JD = JE; + A constant JE = JF; + A constant JF = JG; + A constant JG = JH; + A constant JH = JI; + A constant JI = JJ; + A constant JJ = JK; + A constant JK = JL; + A constant JL = JM; + A constant JM = JN; + A constant JN = JO; + A constant JO = JP; + A constant JP = JQ; + A constant JQ = JR; + A constant JR = JS; + A constant JS = JT; + A constant JT = JU; + A constant JU = JV; + A constant JV = JW; + A constant JW = JX; + A constant JX = A(0x00); +} +// ---- +// DeclarationError: (6105-6123): Variable definition exhausting cyclic dependency validator. diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol new file mode 100644 index 00000000..7f8c6189 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol @@ -0,0 +1,135 @@ +contract A {} +contract Main { + A constant B = C; + A constant C = D; + A constant D = E; + A constant E = F; + A constant F = G; + A constant G = H; + A constant H = I; + A constant I = J; + A constant J = K; + A constant K = L; + A constant L = M; + A constant M = N; + A constant N = O; + A constant O = P; + A constant P = Q; + A constant Q = R; + A constant R = S; + A constant S = T; + A constant T = U; + A constant U = V; + A constant V = W; + A constant W = X; + A constant X = Y; + A constant Y = Z; + A constant Z = BA; + A constant BA = BB; + A constant BB = BC; + A constant BC = BD; + A constant BD = BE; + A constant BE = BF; + A constant BF = BG; + A constant BG = BH; + A constant BH = BI; + A constant BI = BJ; + A constant BJ = BK; + A constant BK = BL; + A constant BL = BM; + A constant BM = BN; + A constant BN = BO; + A constant BO = BP; + A constant BP = BQ; + A constant BQ = BR; + A constant BR = BS; + A constant BS = BT; + A constant BT = BU; + A constant BU = BV; + A constant BV = BW; + A constant BW = BX; + A constant BX = BY; + A constant BY = BZ; + A constant BZ = CA; + A constant CA = CB; + A constant CB = CC; + A constant CC = CD; + A constant CD = CE; + A constant CE = CF; + A constant CF = CG; + A constant CG = CH; + A constant CH = CI; + A constant CI = CJ; + A constant CJ = CK; + A constant CK = CL; + A constant CL = CM; + A constant CM = CN; + A constant CN = CO; + A constant CO = CP; + A constant CP = CQ; + A constant CQ = CR; + A constant CR = CS; + A constant CS = CT; + A constant CT = CU; + A constant CU = CV; + A constant CV = CW; + A constant CW = CX; + A constant CX = CY; + A constant CY = CZ; + A constant CZ = DA; + A constant DA = DB; + A constant DB = DC; + A constant DC = DD; + A constant DD = DE; + A constant DE = DF; + A constant DF = DG; + A constant DG = DH; + A constant DH = DI; + A constant DI = DJ; + A constant DJ = DK; + A constant DK = DL; + A constant DL = DM; + A constant DM = DN; + A constant DN = DO; + A constant DO = DP; + A constant DP = DQ; + A constant DQ = DR; + A constant DR = DS; + A constant DS = DT; + A constant DT = DU; + A constant DU = DV; + A constant DV = DW; + A constant DW = DX; + A constant DX = DY; + A constant DY = DZ; + A constant DZ = EA; + A constant EA = EB; + A constant EB = EC; + A constant EC = ED; + A constant ED = EE; + A constant EE = EF; + A constant EF = EG; + A constant EG = EH; + A constant EH = EI; + A constant EI = EJ; + A constant EJ = EK; + A constant EK = EL; + A constant EL = EM; + A constant EM = EN; + A constant EN = EO; + A constant EO = EP; + A constant EP = EQ; + A constant EQ = ER; + A constant ER = ES; + A constant ES = ET; + A constant ET = EU; + A constant EU = EV; + A constant EV = EW; + A constant EW = EX; + A constant EX = EY; + A constant EY = EZ; + A constant EZ = FA; + A constant FA = FB; + A constant FB = FC; + A constant FC = A(0x00); +} diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol new file mode 100644 index 00000000..db0ff4af --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol @@ -0,0 +1,260 @@ +contract Main { + struct B { C m; } + struct C { D m; } + struct D { E m; } + struct E { F m; } + struct F { G m; } + struct G { H m; } + struct H { I m; } + struct I { J m; } + struct J { K m; } + struct K { L m; } + struct L { M m; } + struct M { N m; } + struct N { O m; } + struct O { P m; } + struct P { Q m; } + struct Q { R m; } + struct R { S m; } + struct S { T m; } + struct T { U m; } + struct U { V m; } + struct V { W m; } + struct W { X m; } + struct X { Y m; } + struct Y { Z m; } + struct Z { BA m; } + struct BA { BB m; } + struct BB { BC m; } + struct BC { BD m; } + struct BD { BE m; } + struct BE { BF m; } + struct BF { BG m; } + struct BG { BH m; } + struct BH { BI m; } + struct BI { BJ m; } + struct BJ { BK m; } + struct BK { BL m; } + struct BL { BM m; } + struct BM { BN m; } + struct BN { BO m; } + struct BO { BP m; } + struct BP { BQ m; } + struct BQ { BR m; } + struct BR { BS m; } + struct BS { BT m; } + struct BT { BU m; } + struct BU { BV m; } + struct BV { BW m; } + struct BW { BX m; } + struct BX { BY m; } + struct BY { BZ m; } + struct BZ { CA m; } + struct CA { CB m; } + struct CB { CC m; } + struct CC { CD m; } + struct CD { CE m; } + struct CE { CF m; } + struct CF { CG m; } + struct CG { CH m; } + struct CH { CI m; } + struct CI { CJ m; } + struct CJ { CK m; } + struct CK { CL m; } + struct CL { CM m; } + struct CM { CN m; } + struct CN { CO m; } + struct CO { CP m; } + struct CP { CQ m; } + struct CQ { CR m; } + struct CR { CS m; } + struct CS { CT m; } + struct CT { CU m; } + struct CU { CV m; } + struct CV { CW m; } + struct CW { CX m; } + struct CX { CY m; } + struct CY { CZ m; } + struct CZ { DA m; } + struct DA { DB m; } + struct DB { DC m; } + struct DC { DD m; } + struct DD { DE m; } + struct DE { DF m; } + struct DF { DG m; } + struct DG { DH m; } + struct DH { DI m; } + struct DI { DJ m; } + struct DJ { DK m; } + struct DK { DL m; } + struct DL { DM m; } + struct DM { DN m; } + struct DN { DO m; } + struct DO { DP m; } + struct DP { DQ m; } + struct DQ { DR m; } + struct DR { DS m; } + struct DS { DT m; } + struct DT { DU m; } + struct DU { DV m; } + struct DV { DW m; } + struct DW { DX m; } + struct DX { DY m; } + struct DY { DZ m; } + struct DZ { EA m; } + struct EA { EB m; } + struct EB { EC m; } + struct EC { ED m; } + struct ED { EE m; } + struct EE { EF m; } + struct EF { EG m; } + struct EG { EH m; } + struct EH { EI m; } + struct EI { EJ m; } + struct EJ { EK m; } + struct EK { EL m; } + struct EL { EM m; } + struct EM { EN m; } + struct EN { EO m; } + struct EO { EP m; } + struct EP { EQ m; } + struct EQ { ER m; } + struct ER { ES m; } + struct ES { ET m; } + struct ET { EU m; } + struct EU { EV m; } + struct EV { EW m; } + struct EW { EX m; } + struct EX { EY m; } + struct EY { EZ m; } + struct EZ { FA m; } + struct FA { FB m; } + struct FB { FC m; } + struct FC { FD m; } + struct FD { FE m; } + struct FE { FF m; } + struct FF { FG m; } + struct FG { FH m; } + struct FH { FI m; } + struct FI { FJ m; } + struct FJ { FK m; } + struct FK { FL m; } + struct FL { FM m; } + struct FM { FN m; } + struct FN { FO m; } + struct FO { FP m; } + struct FP { FQ m; } + struct FQ { FR m; } + struct FR { FS m; } + struct FS { FT m; } + struct FT { FU m; } + struct FU { FV m; } + struct FV { FW m; } + struct FW { FX m; } + struct FX { FY m; } + struct FY { FZ m; } + struct FZ { GA m; } + struct GA { GB m; } + struct GB { GC m; } + struct GC { GD m; } + struct GD { GE m; } + struct GE { GF m; } + struct GF { GG m; } + struct GG { GH m; } + struct GH { GI m; } + struct GI { GJ m; } + struct GJ { GK m; } + struct GK { GL m; } + struct GL { GM m; } + struct GM { GN m; } + struct GN { GO m; } + struct GO { GP m; } + struct GP { GQ m; } + struct GQ { GR m; } + struct GR { GS m; } + struct GS { GT m; } + struct GT { GU m; } + struct GU { GV m; } + struct GV { GW m; } + struct GW { GX m; } + struct GX { GY m; } + struct GY { GZ m; } + struct GZ { HA m; } + struct HA { HB m; } + struct HB { HC m; } + struct HC { HD m; } + struct HD { HE m; } + struct HE { HF m; } + struct HF { HG m; } + struct HG { HH m; } + struct HH { HI m; } + struct HI { HJ m; } + struct HJ { HK m; } + struct HK { HL m; } + struct HL { HM m; } + struct HM { HN m; } + struct HN { HO m; } + struct HO { HP m; } + struct HP { HQ m; } + struct HQ { HR m; } + struct HR { HS m; } + struct HS { HT m; } + struct HT { HU m; } + struct HU { HV m; } + struct HV { HW m; } + struct HW { HX m; } + struct HX { HY m; } + struct HY { HZ m; } + struct HZ { IA m; } + struct IA { IB m; } + struct IB { IC m; } + struct IC { ID m; } + struct ID { IE m; } + struct IE { IF m; } + struct IF { IG m; } + struct IG { IH m; } + struct IH { II m; } + struct II { IJ m; } + struct IJ { IK m; } + struct IK { IL m; } + struct IL { IM m; } + struct IM { IN m; } + struct IN { IO m; } + struct IO { IP m; } + struct IP { IQ m; } + struct IQ { IR m; } + struct IR { IS m; } + struct IS { IT m; } + struct IT { IU m; } + struct IU { IV m; } + struct IV { IW m; } + struct IW { IX m; } + struct IX { IY m; } + struct IY { IZ m; } + struct IZ { JA m; } + struct JA { JB m; } + struct JB { JC m; } + struct JC { JD m; } + struct JD { JE m; } + struct JE { JF m; } + struct JF { JG m; } + struct JG { JH m; } + struct JH { JI m; } + struct JI { JJ m; } + struct JJ { JK m; } + struct JK { JL m; } + struct JL { JM m; } + struct JM { JN m; } + struct JN { JO m; } + struct JO { JP m; } + struct JP { JQ m; } + struct JQ { JR m; } + struct JR { JS m; } + struct JS { JT m; } + struct JT { JU m; } + struct JU { JV m; } + struct JV { JW m; } + struct JW { int i; } +} +// ---- +// DeclarationError: (6091-6111): Struct definition exhausting cyclic dependency validator. diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol new file mode 100644 index 00000000..0419bea6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol @@ -0,0 +1,134 @@ +contract Main { + struct B { C m; } + struct C { D m; } + struct D { E m; } + struct E { F m; } + struct F { G m; } + struct G { H m; } + struct H { I m; } + struct I { J m; } + struct J { K m; } + struct K { L m; } + struct L { M m; } + struct M { N m; } + struct N { O m; } + struct O { P m; } + struct P { Q m; } + struct Q { R m; } + struct R { S m; } + struct S { T m; } + struct T { U m; } + struct U { V m; } + struct V { W m; } + struct W { X m; } + struct X { Y m; } + struct Y { Z m; } + struct Z { BA m; } + struct BA { BB m; } + struct BB { BC m; } + struct BC { BD m; } + struct BD { BE m; } + struct BE { BF m; } + struct BF { BG m; } + struct BG { BH m; } + struct BH { BI m; } + struct BI { BJ m; } + struct BJ { BK m; } + struct BK { BL m; } + struct BL { BM m; } + struct BM { BN m; } + struct BN { BO m; } + struct BO { BP m; } + struct BP { BQ m; } + struct BQ { BR m; } + struct BR { BS m; } + struct BS { BT m; } + struct BT { BU m; } + struct BU { BV m; } + struct BV { BW m; } + struct BW { BX m; } + struct BX { BY m; } + struct BY { BZ m; } + struct BZ { CA m; } + struct CA { CB m; } + struct CB { CC m; } + struct CC { CD m; } + struct CD { CE m; } + struct CE { CF m; } + struct CF { CG m; } + struct CG { CH m; } + struct CH { CI m; } + struct CI { CJ m; } + struct CJ { CK m; } + struct CK { CL m; } + struct CL { CM m; } + struct CM { CN m; } + struct CN { CO m; } + struct CO { CP m; } + struct CP { CQ m; } + struct CQ { CR m; } + struct CR { CS m; } + struct CS { CT m; } + struct CT { CU m; } + struct CU { CV m; } + struct CV { CW m; } + struct CW { CX m; } + struct CX { CY m; } + struct CY { CZ m; } + struct CZ { DA m; } + struct DA { DB m; } + struct DB { DC m; } + struct DC { DD m; } + struct DD { DE m; } + struct DE { DF m; } + struct DF { DG m; } + struct DG { DH m; } + struct DH { DI m; } + struct DI { DJ m; } + struct DJ { DK m; } + struct DK { DL m; } + struct DL { DM m; } + struct DM { DN m; } + struct DN { DO m; } + struct DO { DP m; } + struct DP { DQ m; } + struct DQ { DR m; } + struct DR { DS m; } + struct DS { DT m; } + struct DT { DU m; } + struct DU { DV m; } + struct DV { DW m; } + struct DW { DX m; } + struct DX { DY m; } + struct DY { DZ m; } + struct DZ { EA m; } + struct EA { EB m; } + struct EB { EC m; } + struct EC { ED m; } + struct ED { EE m; } + struct EE { EF m; } + struct EF { EG m; } + struct EG { EH m; } + struct EH { EI m; } + struct EI { EJ m; } + struct EJ { EK m; } + struct EK { EL m; } + struct EL { EM m; } + struct EM { EN m; } + struct EN { EO m; } + struct EO { EP m; } + struct EP { EQ m; } + struct EQ { ER m; } + struct ER { ES m; } + struct ES { ET m; } + struct ET { EU m; } + struct EU { EV m; } + struct EV { EW m; } + struct EW { EX m; } + struct EX { EY m; } + struct EY { EZ m; } + struct EZ { FA m; } + struct FA { FB m; } + struct FB { FC m; } + struct FC { int i; } +} diff --git a/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_explicit.sol b/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_explicit.sol new file mode 100644 index 00000000..ff285a07 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_explicit.sol @@ -0,0 +1,23 @@ +contract C { + function f() public pure { + bytes1 b1 = bytes1(1); + bytes2 b2 = bytes2(1); + bytes2 b3 = bytes2(256); + bytes3 b4 = bytes3(1); + bytes3 b5 = bytes3(65536); + bytes4 b6 = bytes4(1); + bytes4 b7 = bytes4(16777216); + bytes16 b8 = bytes16(1); + bytes32 b9 = bytes32(1); + } +} +// ---- +// TypeError: (60-69): Explicit type conversion not allowed from "int_const 1" to "bytes1". +// TypeError: (88-97): Explicit type conversion not allowed from "int_const 1" to "bytes2". +// TypeError: (116-127): Explicit type conversion not allowed from "int_const 256" to "bytes2". +// TypeError: (146-155): Explicit type conversion not allowed from "int_const 1" to "bytes3". +// TypeError: (174-187): Explicit type conversion not allowed from "int_const 65536" to "bytes3". +// TypeError: (206-215): Explicit type conversion not allowed from "int_const 1" to "bytes4". +// TypeError: (234-250): Explicit type conversion not allowed from "int_const 16777216" to "bytes4". +// TypeError: (270-280): Explicit type conversion not allowed from "int_const 1" to "bytes16". +// TypeError: (300-310): Explicit type conversion not allowed from "int_const 1" to "bytes32". diff --git a/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_implicit.sol b/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_implicit.sol new file mode 100644 index 00000000..e472c43b --- /dev/null +++ b/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_implicit.sol @@ -0,0 +1,23 @@ +contract C { + function f() public pure { + bytes1 b1 = 1; + bytes2 b2 = 1; + bytes2 b3 = 256; + bytes3 b4 = 1; + bytes3 b5 = 65536; + bytes4 b6 = 1; + bytes4 b7 = 16777216; + bytes16 b8 = 1; + bytes32 b9 = 1; + } +} +// ---- +// TypeError: (48-61): Type int_const 1 is not implicitly convertible to expected type bytes1. +// TypeError: (68-81): Type int_const 1 is not implicitly convertible to expected type bytes2. +// TypeError: (88-103): Type int_const 256 is not implicitly convertible to expected type bytes2. +// TypeError: (110-123): Type int_const 1 is not implicitly convertible to expected type bytes3. +// TypeError: (130-147): Type int_const 65536 is not implicitly convertible to expected type bytes3. +// TypeError: (154-167): Type int_const 1 is not implicitly convertible to expected type bytes4. +// TypeError: (174-194): Type int_const 16777216 is not implicitly convertible to expected type bytes4. +// TypeError: (201-215): Type int_const 1 is not implicitly convertible to expected type bytes16. +// TypeError: (222-236): Type int_const 1 is not implicitly convertible to expected type bytes32. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol index 3e40b155..898ee8ba 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol @@ -1,10 +1,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: (71-75): 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/types/empty_tuple_function.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol index 05b54442..a898f84a 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public pure { @@ -8,5 +7,5 @@ contract C { } } // ---- -// Warning: (162-165): Tuple component cannot be empty. -// Warning: (181-184): Tuple component cannot be empty. +// TypeError: (138-141): Tuple component cannot be empty. +// TypeError: (157-160): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol deleted file mode 100644 index c4b9e03f..00000000 --- a/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() private pure {} - function a() public pure { - bool x = true; - bool y = true; - (x) ? (f(), y = false) : (f(), y = false); - } -} -// ---- -// TypeError: (168-171): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol index cba30c1b..63b039cd 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public { @@ -8,6 +7,6 @@ contract C { } } // ---- -// Warning: (146-149): Tuple component cannot be empty. -// Warning: (151-154): Tuple component cannot be empty. -// TypeError: (145-155): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256). +// TypeError: (122-125): Tuple component cannot be empty. +// TypeError: (127-130): Tuple component cannot be empty. +// TypeError: (121-131): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256). diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol deleted file mode 100644 index b0691778..00000000 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() private pure {} - function a() public { - uint x; - uint y; - (x, y) = (f(), f()); - } -} -// ---- -// TypeError: (152-155): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol index f8b2ae7e..9bc21561 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public { @@ -8,4 +7,4 @@ contract C { } } // ---- -// TypeError: (146-149): Array component cannot be empty. +// TypeError: (122-125): Array component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/function_call_fail.sol b/test/libsolidity/syntaxTests/types/function_call_fail.sol new file mode 100644 index 00000000..ef52ab44 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_call_fail.sol @@ -0,0 +1,9 @@ +contract C { + function f(uint y) public pure { + (4(y)) = 2; + } +} +// ---- +// TypeError: (59-63): Type is not callable +// TypeError: (59-63): Expression has to be an lvalue. +// TypeError: (67-68): Type int_const 2 is not implicitly convertible to expected type tuple(). diff --git a/test/libsolidity/syntaxTests/types/function_call_fail2.sol b/test/libsolidity/syntaxTests/types/function_call_fail2.sol new file mode 100644 index 00000000..389ffce9 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_call_fail2.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint y) public pure returns (uint) { + (f(y)) = 2; + } +} +// ---- +// TypeError: (74-78): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/types/function_types/function_parameter_return_types_fail.sol b/test/libsolidity/syntaxTests/types/function_types/function_parameter_return_types_fail.sol new file mode 100644 index 00000000..0d4fded1 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/function_parameter_return_types_fail.sol @@ -0,0 +1,42 @@ +contract Test +{ + function uint256_to_uint256(uint256 x) internal pure returns (uint256) { return x; } + function uint256_to_string(uint256 x) internal pure returns (string memory) { return x == 0 ? "a" : "b"; } + function uint256_to_string_storage(uint256) internal pure returns (string storage); + function string_to_uint256(string memory x) internal pure returns (uint256) { return bytes(x).length; } + function string_to_string(string memory x) internal pure returns (string memory) { return x; } + + function uint256_uint256_to_uint256(uint256 x, uint256 y) internal pure returns (uint256) { return x + y; } + function uint256_uint256_to_string(uint256 x, uint256 y) internal pure returns (string memory) { return x == y ? "a" : "b"; } + function string_uint256_to_string(string memory x, uint256 y) internal pure returns (string memory) { return y == 0 ? "a" : x; } + function string_string_to_string(string memory x, string memory y) internal pure returns (string memory) { return bytes(x).length == 0 ? y : x; } + function uint256_string_to_string(uint256 x, string memory y) internal pure returns (string memory) { return x == 0 ? "a" : y; } + + function tests() internal pure + { + function (uint256) internal pure returns (uint256) var_uint256_to_uint256 = uint256_to_string; + function (uint256) internal pure returns (string memory) var_uint256_to_string = uint256_to_string_storage; + function (string memory) internal pure returns (uint256) var_string_to_uint256 = uint256_to_string; + function (string memory) internal pure returns (string memory) var_string_to_string = var_uint256_to_string; + + function (uint256, uint256) internal pure returns (uint256) var_uint256_uint256_to_uint256 = uint256_to_uint256; + function (string memory, uint256) internal pure returns (string memory) var_string_uint256_to_string = string_to_string; + function (string memory, string memory) internal pure returns (string memory) var_string_string_to_string = string_to_string; + + var_uint256_to_uint256(1); + var_uint256_to_string(2); + var_string_to_uint256("a"); + var_string_to_string("b"); + var_uint256_uint256_to_uint256(3, 4); + var_string_uint256_to_string("c", 7); + var_string_string_to_string("d", "e"); + } +} +// ---- +// TypeError: (1218-1311): Type function (uint256) pure returns (string memory) is not implicitly convertible to expected type function (uint256) pure returns (uint256). +// TypeError: (1319-1425): Type function (uint256) pure returns (string storage pointer) is not implicitly convertible to expected type function (uint256) pure returns (string memory). +// TypeError: (1433-1531): Type function (uint256) pure returns (string memory) is not implicitly convertible to expected type function (string memory) pure returns (uint256). +// TypeError: (1539-1646): Type function (uint256) pure returns (string memory) is not implicitly convertible to expected type function (string memory) pure returns (string memory). +// TypeError: (1655-1766): Type function (uint256) pure returns (uint256) is not implicitly convertible to expected type function (uint256,uint256) pure returns (uint256). +// TypeError: (1774-1893): Type function (string memory) pure returns (string memory) is not implicitly convertible to expected type function (string memory,uint256) pure returns (string memory). +// TypeError: (1901-2025): Type function (string memory) pure returns (string memory) is not implicitly convertible to expected type function (string memory,string memory) pure returns (string memory). diff --git a/test/libsolidity/syntaxTests/types/function_types/function_parameter_return_types_success.sol b/test/libsolidity/syntaxTests/types/function_types/function_parameter_return_types_success.sol new file mode 100644 index 00000000..f750632e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/function_parameter_return_types_success.sol @@ -0,0 +1,39 @@ +contract Test +{ + function uint256_to_uint256(uint256 x) internal pure returns (uint256) { return x; } + function uint256_to_string(uint256 x) internal pure returns (string memory) { return x == 0 ? "a" : "b"; } + function string_to_uint256(string memory x) internal pure returns (uint256) { return bytes(x).length; } + function string_to_string(string memory x) internal pure returns (string memory) { return x; } + + function uint256_uint256_to_uint256(uint256 x, uint256 y) internal pure returns (uint256) { return x + y; } + function uint256_uint256_to_string(uint256 x, uint256 y) internal pure returns (string memory) { return x == y ? "a" : "b"; } + function string_uint256_to_string(string memory x, uint256 y) internal pure returns (string memory) { return y == 0 ? "a" : x; } + function string_string_to_string(string memory x, string memory y) internal pure returns (string memory) { return bytes(x).length == 0 ? y : x; } + function uint256_string_to_string(uint256 x, string memory y) internal pure returns (string memory) { return x == 0 ? "a" : y; } + + function tests() internal pure + { + function (uint256) internal pure returns (uint256) var_uint256_to_uint256 = uint256_to_uint256; + function (uint256) internal pure returns (string memory) var_uint256_to_string = uint256_to_string; + function (string memory) internal pure returns (uint256) var_string_to_uint256 = string_to_uint256; + function (string memory) internal pure returns (string memory) var_string_to_string = string_to_string; + + function (uint256, uint256) internal pure returns (uint256) var_uint256_uint256_to_uint256 = uint256_uint256_to_uint256; + function (uint256, uint256) internal pure returns (string memory) var_uint256_uint256_to_string = uint256_uint256_to_string; + function (string memory, uint256) internal pure returns (string memory) var_string_uint256_to_string = string_uint256_to_string; + function (string memory, string memory) internal pure returns (string memory) var_string_string_to_string = string_string_to_string; + function (uint256, string memory) internal pure returns (string memory) var_uint256_string_to_string = uint256_string_to_string; + + // Avoid unused variable warnings: + var_uint256_to_uint256(1); + var_uint256_to_string(2); + var_string_to_uint256("a"); + var_string_to_string("b"); + var_uint256_uint256_to_uint256(3, 4); + var_uint256_uint256_to_string(5, 6); + var_string_uint256_to_string("c", 7); + var_string_string_to_string("d", "e"); + var_uint256_string_to_string(8, "f"); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/function_types/function_state_mutability_fail.sol b/test/libsolidity/syntaxTests/types/function_types/function_state_mutability_fail.sol new file mode 100644 index 00000000..818d7840 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/function_state_mutability_fail.sol @@ -0,0 +1,51 @@ +contract Test +{ + function internalPureFunc(uint256 x) internal pure returns (uint256) { return x; } + function internalViewFunc(uint256 x) internal view returns (uint256) { return x; } + function internalMutableFunc(uint256 x) internal returns (uint256) { return x; } + + function externalPureFunc(uint256 x) external pure returns (uint256) { return x; } + function externalViewFunc(uint256 x) external view returns (uint256) { return x; } + function externalPayableFunc(uint256 x) external payable returns (uint256) { return x; } + function externalMutableFunc(uint256 x) external returns (uint256) { return x; } + + function funcTakesInternalPure(function(uint256) internal pure returns(uint256) a) internal returns (uint256) { return a(4); } + function funcTakesInternalView(function(uint256) internal view returns(uint256) a) internal returns (uint256) { return a(4); } + function funcTakesInternalMutable(function(uint256) internal returns(uint256) a) internal returns (uint256) { return a(4); } + + function funcTakesExternalPure(function(uint256) external pure returns(uint256) a) internal returns (uint256) { return a(4); } + function funcTakesExternalView(function(uint256) external view returns(uint256) a) internal returns (uint256) { return a(4); } + function funcTakesExternalPayable(function(uint256) external payable returns(uint256) a) internal returns (uint256) { return a(4); } + function funcTakesExternalMutable(function(uint256) external returns(uint256) a) internal returns (uint256) { return a(4); } + + function tests() internal + { + funcTakesInternalPure(internalViewFunc); // view -> pure should fail + funcTakesInternalPure(internalMutableFunc); // mutable -> pure should fail + + funcTakesInternalView(internalMutableFunc); // mutable -> view should fail + + funcTakesExternalPure(this.externalViewFunc); // view -> pure should fail + funcTakesExternalPure(this.externalPayableFunc); // payable -> pure should fail + funcTakesExternalPure(this.externalMutableFunc); // mutable -> pure should fail + + funcTakesExternalView(this.externalPayableFunc); // payable -> view should fail + funcTakesExternalView(this.externalMutableFunc); // mutable -> view should fail + + funcTakesExternalPayable(this.externalPureFunc); // pure -> payable should fail + funcTakesExternalPayable(this.externalViewFunc); // view -> payable should fail + funcTakesExternalPayable(this.externalMutableFunc); // mutable -> payable should fail + } +} +// ---- +// TypeError: (1580-1596): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) view returns (uint256) to function (uint256) pure returns (uint256) requested. +// TypeError: (1653-1672): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) returns (uint256) to function (uint256) pure returns (uint256) requested. +// TypeError: (1733-1752): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) returns (uint256) to function (uint256) view returns (uint256) requested. +// TypeError: (1813-1834): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) view external returns (uint256) to function (uint256) pure external returns (uint256) requested. +// TypeError: (1891-1915): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) payable external returns (uint256) to function (uint256) pure external returns (uint256) requested. +// TypeError: (1975-1999): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) external returns (uint256) to function (uint256) pure external returns (uint256) requested. +// TypeError: (2060-2084): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) payable external returns (uint256) to function (uint256) view external returns (uint256) requested. +// TypeError: (2144-2168): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) external returns (uint256) to function (uint256) view external returns (uint256) requested. +// TypeError: (2232-2253): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) pure external returns (uint256) to function (uint256) payable external returns (uint256) requested. +// TypeError: (2316-2337): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) view external returns (uint256) to function (uint256) payable external returns (uint256) requested. +// TypeError: (2400-2424): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) external returns (uint256) to function (uint256) payable external returns (uint256) requested. diff --git a/test/libsolidity/syntaxTests/types/function_types/function_state_mutability_success.sol b/test/libsolidity/syntaxTests/types/function_types/function_state_mutability_success.sol new file mode 100644 index 00000000..4ee515fc --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/function_state_mutability_success.sol @@ -0,0 +1,46 @@ +contract Test +{ + uint y; + function internalPureFunc(uint256 x) internal pure returns (uint256) { return x; } + function internalViewFunc(uint256 x) internal view returns (uint256) { return x + y; } + function internalMutableFunc(uint256 x) internal returns (uint256) { y = x; return x; } + + function externalPureFunc(uint256 x) external pure returns (uint256) { return x; } + function externalViewFunc(uint256 x) external view returns (uint256) { return x + y; } + function externalPayableFunc(uint256 x) external payable returns (uint256) { return x + y; } + function externalMutableFunc(uint256 x) external returns (uint256) { y = x; return x; } + + function funcTakesInternalPure(function(uint256) internal pure returns(uint256) a) internal pure returns (uint256) { return a(4); } + function funcTakesInternalView(function(uint256) internal view returns(uint256) a) internal view returns (uint256) { return a(4); } + function funcTakesInternalMutable(function(uint256) internal returns(uint256) a) internal returns (uint256) { return a(4); } + + function funcTakesExternalPure(function(uint256) external pure returns(uint256) a) internal pure returns (uint256) { return a(4); } + function funcTakesExternalView(function(uint256) external view returns(uint256) a) internal view returns (uint256) { return a(4); } + function funcTakesExternalPayable(function(uint256) external payable returns(uint256) a) internal returns (uint256) { return a(4); } + function funcTakesExternalMutable(function(uint256) external returns(uint256) a) internal returns (uint256) { return a(4); } + + function tests() internal + { + funcTakesInternalPure(internalPureFunc); + + funcTakesInternalView(internalPureFunc); + funcTakesInternalView(internalViewFunc); + + funcTakesInternalMutable(internalPureFunc); + funcTakesInternalMutable(internalViewFunc); + funcTakesInternalMutable(internalMutableFunc); + + funcTakesExternalPure(this.externalPureFunc); + + funcTakesExternalView(this.externalPureFunc); + funcTakesExternalView(this.externalViewFunc); + + funcTakesExternalPayable(this.externalPayableFunc); + + funcTakesExternalMutable(this.externalPureFunc); + funcTakesExternalMutable(this.externalViewFunc); + funcTakesExternalMutable(this.externalPayableFunc); + funcTakesExternalMutable(this.externalMutableFunc); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_explicit.sol b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_explicit.sol new file mode 100644 index 00000000..e1e9850d --- /dev/null +++ b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_explicit.sol @@ -0,0 +1,31 @@ +contract C { + function f() public pure { + bytes1 b1 = bytes1(0x1); + bytes1 b2 = bytes1(0x100); + bytes2 b3 = bytes2(0xFF); + bytes2 b4 = bytes2(0x100); + bytes2 b5 = bytes2(0x10000); + bytes3 b6 = bytes3(0xFFFF); + bytes3 b7 = bytes3(0x10000); + bytes3 b8 = bytes3(0x1000000); + bytes4 b9 = bytes4(0xFFFFFF); + bytes4 b10 = bytes4(0x1000000); + bytes4 b11 = bytes4(0x100000000); + bytes16 b12 = bytes16(0x1); + bytes32 b13 = bytes32(0x1); + } +} +// ---- +// TypeError: (60-71): Explicit type conversion not allowed from "int_const 1" to "bytes1". +// TypeError: (90-103): Explicit type conversion not allowed from "int_const 256" to "bytes1". +// TypeError: (122-134): Explicit type conversion not allowed from "int_const 255" to "bytes2". +// TypeError: (153-166): Explicit type conversion not allowed from "int_const 256" to "bytes2". +// TypeError: (185-200): Explicit type conversion not allowed from "int_const 65536" to "bytes2". +// TypeError: (219-233): Explicit type conversion not allowed from "int_const 65535" to "bytes3". +// TypeError: (252-267): Explicit type conversion not allowed from "int_const 65536" to "bytes3". +// TypeError: (286-303): Explicit type conversion not allowed from "int_const 16777216" to "bytes3". +// TypeError: (322-338): Explicit type conversion not allowed from "int_const 16777215" to "bytes4". +// TypeError: (358-375): Explicit type conversion not allowed from "int_const 16777216" to "bytes4". +// TypeError: (395-414): Explicit type conversion not allowed from "int_const 4294967296" to "bytes4". +// TypeError: (435-447): Explicit type conversion not allowed from "int_const 1" to "bytes16". +// TypeError: (468-480): Explicit type conversion not allowed from "int_const 1" to "bytes32". diff --git a/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_implicit.sol b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_implicit.sol new file mode 100644 index 00000000..44ed9318 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_implicit.sol @@ -0,0 +1,31 @@ +contract C { + function f() public pure { + bytes1 b1 = 0x1; + bytes1 b2 = 0x100; + bytes2 b3 = 0xFF; + bytes2 b4 = 0x100; + bytes2 b5 = 0x10000; + bytes3 b6 = 0xFFFF; + bytes3 b7 = 0x10000; + bytes3 b8 = 0x1000000; + bytes4 b9 = 0xFFFFFF; + bytes4 b10 = 0x1000000; + bytes4 b11 = 0x100000000; + bytes16 b12 = 0x1; + bytes32 b13 = 0x1; + } +} +// ---- +// TypeError: (48-63): Type int_const 1 is not implicitly convertible to expected type bytes1. +// TypeError: (70-87): Type int_const 256 is not implicitly convertible to expected type bytes1. +// TypeError: (94-110): Type int_const 255 is not implicitly convertible to expected type bytes2. +// TypeError: (117-134): Type int_const 256 is not implicitly convertible to expected type bytes2. +// TypeError: (141-160): Type int_const 65536 is not implicitly convertible to expected type bytes2. +// TypeError: (167-185): Type int_const 65535 is not implicitly convertible to expected type bytes3. +// TypeError: (192-211): Type int_const 65536 is not implicitly convertible to expected type bytes3. +// TypeError: (218-239): Type int_const 16777216 is not implicitly convertible to expected type bytes3. +// TypeError: (246-266): Type int_const 16777215 is not implicitly convertible to expected type bytes4. +// TypeError: (273-295): Type int_const 16777216 is not implicitly convertible to expected type bytes4. +// TypeError: (302-326): Type int_const 4294967296 is not implicitly convertible to expected type bytes4. +// TypeError: (333-350): Type int_const 1 is not implicitly convertible to expected type bytes16. +// TypeError: (357-374): Type int_const 1 is not implicitly convertible to expected type bytes32. diff --git a/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_explicit.sol b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_explicit.sol new file mode 100644 index 00000000..4e18640c --- /dev/null +++ b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_explicit.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + bytes1 b1 = bytes1(0x01); + bytes1 b2 = bytes1(0xFF); + bytes2 b3 = bytes2(0x0100); + bytes2 b4 = bytes2(0xFFFF); + bytes3 b5 = bytes3(0x010000); + bytes3 b6 = bytes3(0xFFFFFF); + bytes4 b7 = bytes4(0x01000000); + bytes4 b8 = bytes4(0xFFFFFFFF); + b1; b2; b3; b4; b5; b6; b7; b8; + } +} diff --git a/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_implicit.sol b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_implicit.sol new file mode 100644 index 00000000..daf0bf56 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_implicit.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + bytes1 b1 = 0x01; + bytes1 b2 = 0xFF; + bytes2 b3 = 0x0100; + bytes2 b4 = 0xFFFF; + bytes3 b5 = 0x010000; + bytes3 b6 = 0xFFFFFF; + bytes4 b7 = 0x01000000; + bytes4 b8 = 0xFFFFFFFF; + b1; b2; b3; b4; b5; b6; b7; b8; + } +} diff --git a/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol b/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol new file mode 100644 index 00000000..f31b4cc0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol @@ -0,0 +1,6 @@ +contract C { + bytes20 x; + function f(bytes16 b) public view { + b[uint8(x[2])]; + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/argument_external.sol new file mode 100644 index 00000000..2b5e6b05 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/argument_external.sol @@ -0,0 +1,6 @@ +contract C { + function f(mapping(uint => uint) storage) external pure { + } +} +// ---- +// TypeError: (28-57): Data location must be "calldata" for parameter in external function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/argument_internal.sol new file mode 100644 index 00000000..3c021515 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/argument_internal.sol @@ -0,0 +1,5 @@ +contract C { + function f(mapping(uint => uint) storage) internal pure { + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/argument_private.sol b/test/libsolidity/syntaxTests/types/mapping/argument_private.sol new file mode 100644 index 00000000..63733d71 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/argument_private.sol @@ -0,0 +1,5 @@ +contract C { + function f(mapping(uint => uint) storage) private pure { + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/argument_public.sol new file mode 100644 index 00000000..32f11fe9 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/argument_public.sol @@ -0,0 +1,6 @@ +contract C { + function f(mapping(uint => uint) storage) public pure { + } +} +// ---- +// TypeError: (28-57): Data location must be "memory" for parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/array_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/array_argument_external.sol new file mode 100644 index 00000000..0863653c --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/array_argument_external.sol @@ -0,0 +1,6 @@ +contract C { + function f(mapping(uint => uint)[] storage) external pure { + } +} +// ---- +// TypeError: (28-59): Data location must be "calldata" for parameter in external function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/array_argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/array_argument_internal.sol new file mode 100644 index 00000000..352d0982 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/array_argument_internal.sol @@ -0,0 +1,5 @@ +contract C { + function f(mapping(uint => uint)[] storage) internal pure { + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/array_argument_private.sol b/test/libsolidity/syntaxTests/types/mapping/array_argument_private.sol new file mode 100644 index 00000000..332dbe6c --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/array_argument_private.sol @@ -0,0 +1,5 @@ +contract C { + function f(mapping(uint => uint)[] storage) private pure { + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/array_argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/array_argument_public.sol new file mode 100644 index 00000000..99c83d8a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/array_argument_public.sol @@ -0,0 +1,6 @@ +contract C { + function f(mapping(uint => uint)[] storage) public pure { + } +} +// ---- +// TypeError: (28-59): Data location must be "memory" for parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol new file mode 100644 index 00000000..a329c91e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol @@ -0,0 +1,11 @@ +contract test { + mapping(uint=>uint) map; + function fun() public view { + mapping(uint=>uint) storage a = map; + mapping(uint=>uint) storage b = map; + b = a; + (b) = a; + (b, b) = (a, a); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol new file mode 100644 index 00000000..1323afe6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol @@ -0,0 +1,14 @@ +contract test { + mapping(uint=>uint) map; + function fun() public { + mapping(uint=>uint) storage a = map; + map = a; + (map) = a; + (map, map) = (a, a); + } +} +// ---- +// TypeError: (126-129): Mappings cannot be assigned to. +// TypeError: (144-147): Mappings cannot be assigned to. +// TypeError: (163-166): Mappings cannot be assigned to. +// TypeError: (168-171): Mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol new file mode 100644 index 00000000..b89241ed --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol @@ -0,0 +1,17 @@ +contract test { + struct str { + mapping(uint=>uint) map; + } + str data; + function fun() public { + mapping(uint=>uint) storage a = data.map; + data.map = a; + (data.map) = a; + (data.map, data.map) = (a, a); + } +} +// ---- +// TypeError: (172-180): Mappings cannot be assigned to. +// TypeError: (195-203): Mappings cannot be assigned to. +// TypeError: (219-227): Mappings cannot be assigned to. +// TypeError: (229-237): Mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_external.sol new file mode 100644 index 00000000..34f95701 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_external.sol @@ -0,0 +1,7 @@ +contract C { + function f(function(mapping(uint=>uint) storage) external) public pure { + } +} +// ---- +// TypeError: (37-64): Data location must be "memory" for parameter in function, but "storage" was given. +// TypeError: (37-64): Internal type cannot be used for external function type. diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_internal.sol new file mode 100644 index 00000000..01e2322e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_internal.sol @@ -0,0 +1,4 @@ +contract C { + function f(function(mapping(uint=>uint) storage) internal) internal pure { + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_return_external.sol new file mode 100644 index 00000000..aed9b387 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/function_type_return_external.sol @@ -0,0 +1,7 @@ +contract C { + function f(function() external returns (mapping(uint=>uint) storage)) public pure { + } +} +// ---- +// TypeError: (57-84): Data location must be "memory" for return parameter in function, but "storage" was given. +// TypeError: (57-84): Internal type cannot be used for external function type. diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_return_internal.sol new file mode 100644 index 00000000..bd298e5d --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/function_type_return_internal.sol @@ -0,0 +1,4 @@ +contract C { + function f(function() internal returns (mapping(uint=>uint) storage)) internal pure { + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_external.sol new file mode 100644 index 00000000..1098008d --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_external.sol @@ -0,0 +1,6 @@ +library L { + function f(mapping(uint => uint) storage) external pure { + } +} +// ---- +// TypeError: (27-56): Type is required to live outside storage. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_internal.sol new file mode 100644 index 00000000..1228b6b6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_internal.sol @@ -0,0 +1,4 @@ +library L { + function f(mapping(uint => uint) storage) internal pure { + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_private.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_private.sol new file mode 100644 index 00000000..5eaff16b --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_private.sol @@ -0,0 +1,4 @@ +library L { + function f(mapping(uint => uint) storage) private pure { + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_public.sol new file mode 100644 index 00000000..dedd4f68 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_public.sol @@ -0,0 +1,6 @@ +library L { + function f(mapping(uint => uint) storage) public pure { + } +} +// ---- +// TypeError: (27-56): Type is required to live outside storage. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol new file mode 100644 index 00000000..da5a911b --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol @@ -0,0 +1,6 @@ +library L { + function f(mapping(uint => uint)[] storage) external pure { + } +} +// ---- +// TypeError: (27-58): Type is required to live outside storage. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_internal.sol new file mode 100644 index 00000000..55c1cea0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_internal.sol @@ -0,0 +1,4 @@ +library L { + function f(mapping(uint => uint)[] storage) internal pure { + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_private.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_private.sol new file mode 100644 index 00000000..d37d6504 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_private.sol @@ -0,0 +1,4 @@ +library L { + function f(mapping(uint => uint)[] storage) private pure { + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol new file mode 100644 index 00000000..adb62203 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol @@ -0,0 +1,6 @@ +library L { + function f(mapping(uint => uint)[] storage) public pure { + } +} +// ---- +// TypeError: (27-58): Type is required to live outside storage. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/library_return_external.sol new file mode 100644 index 00000000..1e756819 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_return_external.sol @@ -0,0 +1,10 @@ +library L +{ + function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) external pure returns(mapping(uint => uint) storage) { + return c ? a : b; + } +} +// ---- +// TypeError: (27-58): Type is required to live outside storage. +// TypeError: (60-91): Type is required to live outside storage. +// TypeError: (123-152): Type is required to live outside storage. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/library_return_internal.sol new file mode 100644 index 00000000..d0fca6bf --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_return_internal.sol @@ -0,0 +1,6 @@ +library L +{ + function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) internal pure returns(mapping(uint => uint) storage) { + return c ? a : b; + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/library_return_private.sol b/test/libsolidity/syntaxTests/types/mapping/library_return_private.sol new file mode 100644 index 00000000..13c2000f --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_return_private.sol @@ -0,0 +1,6 @@ +library L +{ + function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) private pure returns(mapping(uint => uint) storage) { + return c ? a : b; + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/library_return_public.sol b/test/libsolidity/syntaxTests/types/mapping/library_return_public.sol new file mode 100644 index 00000000..357751a0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_return_public.sol @@ -0,0 +1,10 @@ +library L +{ + function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) public pure returns(mapping(uint => uint) storage) { + return c ? a : b; + } +} +// ---- +// TypeError: (27-58): Type is required to live outside storage. +// TypeError: (60-91): Type is required to live outside storage. +// TypeError: (121-150): Type is required to live outside storage. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol new file mode 100644 index 00000000..0c29ebd8 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol @@ -0,0 +1,6 @@ +contract c { + function f1(mapping(uint => uint)[] calldata) pure external {} +} +// ---- +// TypeError: (29-61): Type is required to live outside storage. +// TypeError: (29-61): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_external.sol new file mode 100644 index 00000000..fe021bd0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_external.sol @@ -0,0 +1,6 @@ +contract C { + function f() external pure returns (mapping(uint=>uint)[] storage m) { + } +} +// ---- +// TypeError: (53-84): Data location must be "memory" for return parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_internal.sol new file mode 100644 index 00000000..8837c745 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_internal.sol @@ -0,0 +1,16 @@ +contract C { + mapping(uint=>uint)[] m; + function f() internal view returns (mapping(uint=>uint)[] storage) { + return m; + } + function g() private view returns (mapping(uint=>uint)[] storage) { + return m; + } + function h() internal view returns (mapping(uint=>uint)[] storage r) { + r = m; + } + function i() private view returns (mapping(uint=>uint)[] storage r) { + (r,r) = (m,m); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_public.sol new file mode 100644 index 00000000..1eb9d03b --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_public.sol @@ -0,0 +1,6 @@ +contract C { + function f() public pure returns (mapping(uint=>uint)[] storage m) { + } +} +// ---- +// TypeError: (51-82): Data location must be "memory" for return parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol new file mode 100644 index 00000000..deff7c14 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol @@ -0,0 +1,9 @@ +contract c { + mapping(uint => uint) y; + function f() view public { + mapping(uint => uint) calldata x = y; + x; + } +} +// ---- +// TypeError: (81-113): Data location must be "storage" for variable, but "calldata" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol new file mode 100644 index 00000000..e5253f00 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol @@ -0,0 +1,9 @@ +contract c { + mapping(uint => uint) y; + function f() view public { + mapping(uint => uint) x = y; + x; + } +} +// ---- +// TypeError: (81-104): Data location must be "storage" for variable, but none was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol new file mode 100644 index 00000000..c050f8e9 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol @@ -0,0 +1,6 @@ +contract c { + function f1(mapping(uint => uint) calldata) pure external returns (mapping(uint => uint) memory) {} +} +// ---- +// TypeError: (29-59): Type is required to live outside storage. +// TypeError: (29-59): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_internal.sol new file mode 100644 index 00000000..17f2f712 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_internal.sol @@ -0,0 +1,4 @@ +contract c { + function f4(mapping(uint => uint) memory) pure internal {} +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol new file mode 100644 index 00000000..b63868b8 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol @@ -0,0 +1,6 @@ +contract c { + function f3(mapping(uint => uint) memory) view public {} +} +// ---- +// TypeError: (29-57): Type is required to live outside storage. +// TypeError: (29-57): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol new file mode 100644 index 00000000..600ae669 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol @@ -0,0 +1,9 @@ +contract c { + mapping(uint => uint) y; + function f() view public { + mapping(uint => uint) memory x = y; + x; + } +} +// ---- +// TypeError: (81-111): Data location must be "storage" for variable, but "memory" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_dynamic_key.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_dynamic_key.sol new file mode 100644 index 00000000..825ee09a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_dynamic_key.sol @@ -0,0 +1,3 @@ +contract c { + mapping(string => uint) data; +} diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_dynamic_key_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_dynamic_key_public.sol new file mode 100644 index 00000000..9fb575af --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_dynamic_key_public.sol @@ -0,0 +1,5 @@ +contract c { + mapping(string => uint) public data; +} +// ---- +// TypeError: (14-49): Dynamically-sized keys for public mappings are not supported. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol new file mode 100644 index 00000000..17e646ce --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol @@ -0,0 +1,6 @@ +contract C { + function f() external pure returns (mapping(uint=>uint) storage m) { + } +} +// ---- +// TypeError: (53-82): Data location must be "memory" for return parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol new file mode 100644 index 00000000..4912836e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol @@ -0,0 +1,16 @@ +contract C { + mapping(uint=>uint) m; + function f() internal view returns (mapping(uint=>uint) storage) { + return m; + } + function g() private view returns (mapping(uint=>uint) storage) { + return m; + } + function h() internal view returns (mapping(uint=>uint) storage r) { + r = m; + } + function i() private view returns (mapping(uint=>uint) storage r) { + (r,r) = (m,m); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol new file mode 100644 index 00000000..cf5ec4ff --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol @@ -0,0 +1,6 @@ +contract C { + function f() public pure returns (mapping(uint=>uint) storage m) { + } +} +// ---- +// TypeError: (51-80): Data location must be "memory" for return parameter in function, but "storage" was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol new file mode 100644 index 00000000..35c3abc9 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure returns (mapping(uint=>uint) memory m) { + } +} +// ---- +// TypeError: (51-79): Type is required to live outside storage. +// TypeError: (51-79): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/types/no_singleton_tuple.sol b/test/libsolidity/syntaxTests/types/no_singleton_tuple.sol new file mode 100644 index 00000000..62a58f83 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/no_singleton_tuple.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure { + uint a; + (a,) = (uint(1),); + } +} +// ---- +// TypeError: (60-70): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/rational_negative_numerator_negative_exp.sol b/test/libsolidity/syntaxTests/types/rational_negative_numerator_negative_exp.sol new file mode 100644 index 00000000..b694992c --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_negative_numerator_negative_exp.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure returns (int) { + return (-1 / 2) ** -1; + } +} diff --git a/test/libsolidity/syntaxTests/types/rational_number_exp_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol index 6785f580..058db2e9 100644 --- a/test/libsolidity/syntaxTests/types/rational_number_exp_limit.sol +++ b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol @@ -4,9 +4,6 @@ contract c { a = 4 ** 4 ** 2 ** 4 ** 4 ** 4 ** 4; a = -4 ** 4 ** 2 ** 4 ** 4 ** 4 ** 4 ** 4; a = 4 ** (-(2 ** 4 ** 4 ** 4 ** 4 ** 4)); - a = 0 ** 1E1233; // fine - a = 1 ** 1E1233; // fine - a = -1 ** 1E1233; // fine a = 2 ** 1E1233; a = -2 ** 1E1233; a = 2 ** -1E1233; @@ -28,23 +25,23 @@ contract c { // TypeError: (116-153): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 // TypeError: (116-153): Type int_const 1797...(301 digits omitted)...7216 is not implicitly convertible to expected type int256. // TypeError: (167-203): Operator ** not compatible with types int_const 4 and int_const -179...(302 digits omitted)...7216 -// TypeError: (317-328): Operator ** not compatible with types int_const 2 and int_const 1000...(1226 digits omitted)...0000 -// TypeError: (342-354): Operator ** not compatible with types int_const -2 and int_const 1000...(1226 digits omitted)...0000 -// TypeError: (368-380): Operator ** not compatible with types int_const 2 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (394-407): Operator ** not compatible with types int_const -2 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (421-432): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 -// TypeError: (421-432): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (446-458): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2 -// TypeError: (446-458): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (472-484): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2 -// TypeError: (472-484): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (498-511): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2 -// TypeError: (498-511): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (525-541): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 -// TypeError: (525-541): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (555-572): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (555-572): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (586-603): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 -// TypeError: (586-603): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (617-635): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (617-635): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (217-228): Operator ** not compatible with types int_const 2 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (242-254): Operator ** not compatible with types int_const -2 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (268-280): Operator ** not compatible with types int_const 2 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (294-307): Operator ** not compatible with types int_const -2 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (321-332): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 +// TypeError: (321-332): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (346-358): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2 +// TypeError: (346-358): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (372-384): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2 +// TypeError: (372-384): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (398-411): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2 +// TypeError: (398-411): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (425-441): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (425-441): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (455-472): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (455-472): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (486-503): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (486-503): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (517-535): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (517-535): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. diff --git a/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fine.sol b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fine.sol new file mode 100644 index 00000000..66d02eb9 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fine.sol @@ -0,0 +1,9 @@ +contract c { + function f() public pure { + int a; + a = 0 ** 1E1233; + a = 1 ** 1E1233; + a = -1 ** 1E1233; + a = 0E123456789; + } +} diff --git a/test/libsolidity/syntaxTests/types/rational_number_huge.sol b/test/libsolidity/syntaxTests/types/rational_number_huge.sol new file mode 100644 index 00000000..378de201 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_huge.sol @@ -0,0 +1,10 @@ +contract C { + function f(uint y) public pure { + // fits FixedBytes with exactly 32-bytes + y = 0xffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000; // FixedBytes (32) + + // fits exactly into FixedBytes (32), ensures underscored literals won't hurt + y = 0xffffffff00000000ffffffff00000000ffffffff00000000ffffffff_00000000; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/rational_number_huge_fail.sol b/test/libsolidity/syntaxTests/types/rational_number_huge_fail.sol new file mode 100644 index 00000000..08e50656 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_huge_fail.sol @@ -0,0 +1,8 @@ +contract C { + function f(uint y) public pure { + // one byte too long for storing in Fixedbytes (would require 33 bytes) + y = 0xffffffff00000000ffffffff00000000ffffffff00000000ffffffff000000001; + } +} +// ---- +// TypeError: (142-209): Type int_const 1852...(71 digits omitted)...7281 is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/types/too_small_negative_numbers.sol b/test/libsolidity/syntaxTests/types/too_small_negative_numbers.sol new file mode 100644 index 00000000..66bd9a8e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/too_small_negative_numbers.sol @@ -0,0 +1,4 @@ +contract C { + fixed8x80 a = -1e-100; +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol b/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol new file mode 100644 index 00000000..f70c89ed --- /dev/null +++ b/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure returns(bytes1) { + return bytes1(uint256(0)); + } +} +// ---- +// TypeError: (75-93): Explicit type conversion not allowed from "uint256" to "bytes1". diff --git a/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol b/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol new file mode 100644 index 00000000..4153c5c3 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure returns(bytes32) { + return bytes32(uint32(0)); + } +} +// ---- +// TypeError: (76-94): Explicit type conversion not allowed from "uint32" to "bytes32". diff --git a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol new file mode 100644 index 00000000..36b3df9f --- /dev/null +++ b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol @@ -0,0 +1,16 @@ +contract C { + function f() internal pure {} + function g() internal pure returns (uint) { return 1; } + function h() internal pure returns (uint, uint) { return (1, 2); } + + function test() internal pure { + var () = f(); + var () = g(); + var (,) = h(); + } +} + +// ---- +// SyntaxError: (223-235): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (245-257): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (267-280): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol new file mode 100644 index 00000000..51b949de --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + var (); + var (,); + } +} +// ---- +// SyntaxError: (52-58): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (68-75): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol new file mode 100644 index 00000000..20a004ff --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure { + var a; + a.NeverReachedByParser(); + } +} +// ---- +// TypeError: (52-57): Use of the "var" keyword is disallowed. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol new file mode 100644 index 00000000..de2abc9a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + var (b, c); + b.WeMustNotReachHere(); + c.FailsToLookupToo(); + } +} +// ---- +// TypeError: (52-62): Use of the "var" keyword is disallowed. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol new file mode 100644 index 00000000..26ee824e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + var (d, e,); + } +} +// ---- +// TypeError: (52-63): Use of the "var" keyword is disallowed. diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol new file mode 100644 index 00000000..cc35fdd6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol @@ -0,0 +1,35 @@ +contract C { + function h() internal pure returns (uint, uint, uint) { + return (1, 2, 4); + } + function g(uint x) internal pure returns (uint) { + return x; + } + function f() internal pure { + var i = 31415; + var t = "string"; + var g2 = g; + var myblockhash = block.blockhash; + var (a, b) = (2, "troi"); + var (x,, z) = h(); + var (c, d) = (""); + var (k, l) = (2); + var (m, n) = 1; + var (o, p) = ""; + } +} +// ---- +// SyntaxError: (224-237): Use of the "var" keyword is disallowed. Use explicit declaration `uint16 i = ...´ instead. +// SyntaxError: (247-263): Use of the "var" keyword is disallowed. Use explicit declaration `string memory t = ...´ instead. +// SyntaxError: (273-283): Use of the "var" keyword is disallowed. Use explicit declaration `function (uint256) pure returns (uint256) g2 = ...´ instead. +// SyntaxError: (293-326): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// SyntaxError: (336-360): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead. +// SyntaxError: (370-387): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead. +// TypeError: (397-414): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (397-414): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (424-440): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (424-440): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (450-464): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (450-464): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (474-489): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (474-489): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. diff --git a/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_explicit.sol b/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_explicit.sol new file mode 100644 index 00000000..5d606089 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_explicit.sol @@ -0,0 +1,30 @@ +contract C { + function f() public pure { + bytes1 b1 = bytes1(0); + bytes2 b2 = bytes2(0); + bytes3 b3 = bytes3(0); + bytes4 b4 = bytes4(0); + bytes8 b8 = bytes8(0); + bytes16 b16 = bytes16(0); + bytes32 b32 = bytes32(0); + b1; b2; b3; b4; b8; b16; b32; + } + function g() public pure { + bytes1 b1 = bytes1(0x000); + bytes2 b2 = bytes2(0x00000); + bytes3 b3 = bytes3(0x0000000); + bytes4 b4 = bytes4(0x000000000); + bytes8 b8 = bytes8(0x00000000000000000); + b1; b2; b3; b4; b8; + } + function h() public pure { + bytes1 b1 = bytes1(0x0); + bytes2 b2 = bytes2(0x0); + bytes3 b3 = bytes3(0x0); + bytes4 b4 = bytes4(0x0); + bytes8 b8 = bytes8(0x0); + bytes16 b16 = bytes16(0x0); + bytes32 b32 = bytes32(0x0); + b1; b2; b3; b4; b8; b16; b32; + } +} diff --git a/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_implicit.sol b/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_implicit.sol new file mode 100644 index 00000000..48be0655 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_implicit.sol @@ -0,0 +1,30 @@ +contract C { + function f() public pure { + bytes1 b1 = 0; + bytes2 b2 = 0; + bytes3 b3 = 0; + bytes4 b4 = 0; + bytes8 b8 = 0; + bytes16 b16 = 0; + bytes32 b32 = 0; + b1; b2; b3; b4; b8; b16; b32; + } + function g() public pure { + bytes1 b1 = 0x000; + bytes2 b2 = 0x00000; + bytes3 b3 = 0x0000000; + bytes4 b4 = 0x000000000; + bytes8 b8 = 0x00000000000000000; + b1; b2; b3; b4; b8; + } + function h() public pure { + bytes1 b1 = 0x0; + bytes2 b2 = 0x0; + bytes3 b3 = 0x0; + bytes4 b4 = 0x0; + bytes8 b8 = 0x0; + bytes16 b16 = 0x0; + bytes32 b32 = 0x0; + b1; b2; b3; b4; b8; b16; b32; + } +} diff --git a/test/libsolidity/syntaxTests/unicode_escape_literals.sol b/test/libsolidity/syntaxTests/unicode_escape_literals.sol new file mode 100644 index 00000000..a340487b --- /dev/null +++ b/test/libsolidity/syntaxTests/unicode_escape_literals.sol @@ -0,0 +1,31 @@ +contract test { + + function oneByteUTF8() public pure returns (bytes32) { + bytes32 usdollar = "aaa\u0024aaa"; + return usdollar; + } + + function twoBytesUTF8() public pure returns (bytes32) { + bytes32 cent = "aaa\u00A2aaa"; + return cent; + } + + function threeBytesUTF8() public pure returns (bytes32) { + bytes32 eur = "aaa\u20ACaaa"; + return eur; + } + + function together() public pure returns (bytes32) { + bytes32 res = "\u0024\u00A2\u20AC"; + return res; + } + + // this function returns an invalid unicode character + function invalidLiteral() public pure returns(bytes32) { + bytes32 invalid = "\u00xx"; + return invalid; + } + +} +// ---- +// ParserError: (678-681): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol new file mode 100644 index 00000000..a678f004 --- /dev/null +++ b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol @@ -0,0 +1,4 @@ +contract c { + function f() pure public { 1. +// ---- +// ParserError: (47-47): Expected identifier but got end of source
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol new file mode 100644 index 00000000..3cc59374 --- /dev/null +++ b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol @@ -0,0 +1,5 @@ +contract test { + function f() pure public { 1.x; } +} +// ---- +// TypeError: (47-50): Member "x" not found or not visible after argument-dependent lookup in int_const 1.
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol new file mode 100644 index 00000000..6ba2b4c2 --- /dev/null +++ b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol @@ -0,0 +1,4 @@ +contract c { + function f() pure public { 0. +// ---- +// ParserError: (47-47): Expected identifier but got end of source
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol new file mode 100644 index 00000000..8648bce2 --- /dev/null +++ b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol @@ -0,0 +1,5 @@ +contract test { + function f() pure public { 0.x; } +} +// ---- +// TypeError: (47-50): Member "x" not found or not visible after argument-dependent lookup in int_const 0.
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/upper_case_hex_literals.sol b/test/libsolidity/syntaxTests/upper_case_hex_literals.sol new file mode 100644 index 00000000..0842c2ec --- /dev/null +++ b/test/libsolidity/syntaxTests/upper_case_hex_literals.sol @@ -0,0 +1,9 @@ +contract test { + + function f() public pure returns (uint256) { + uint256 a = 0x1234aAbcC; + uint256 b = 0x1234ABCDEF; + return a + b; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/variableDeclaration/do_while.sol b/test/libsolidity/syntaxTests/variableDeclaration/do_while.sol new file mode 100644 index 00000000..8fc48b33 --- /dev/null +++ b/test/libsolidity/syntaxTests/variableDeclaration/do_while.sol @@ -0,0 +1,12 @@ +pragma solidity >0.4.24; + +contract C +{ + function f(uint x) public pure { + do + uint y; + while (x > 0); + } +} +// ---- +// SyntaxError: (81-87): Variable declarations can only be used inside blocks. diff --git a/test/libsolidity/syntaxTests/variableDeclaration/else.sol b/test/libsolidity/syntaxTests/variableDeclaration/else.sol new file mode 100644 index 00000000..914e0c0c --- /dev/null +++ b/test/libsolidity/syntaxTests/variableDeclaration/else.sol @@ -0,0 +1,13 @@ +pragma solidity >0.4.24; + +contract C +{ + function f(uint x) public pure { + if (x > 0) + {uint y;} + else + uint z; + } +} +// ---- +// SyntaxError: (109-115): Variable declarations can only be used inside blocks. diff --git a/test/libsolidity/syntaxTests/variableDeclaration/for.sol b/test/libsolidity/syntaxTests/variableDeclaration/for.sol new file mode 100644 index 00000000..bc137f93 --- /dev/null +++ b/test/libsolidity/syntaxTests/variableDeclaration/for.sol @@ -0,0 +1,11 @@ +pragma solidity >0.4.24; + +contract C +{ + function f(uint x) public pure { + for (uint i = 0; i < x; ++i) + uint y; + } +} +// ---- +// SyntaxError: (107-113): Variable declarations can only be used inside blocks. diff --git a/test/libsolidity/syntaxTests/variableDeclaration/if.sol b/test/libsolidity/syntaxTests/variableDeclaration/if.sol new file mode 100644 index 00000000..75ab2026 --- /dev/null +++ b/test/libsolidity/syntaxTests/variableDeclaration/if.sol @@ -0,0 +1,11 @@ +pragma solidity >0.4.24; + +contract C +{ + function f(uint x) public pure { + if (x > 0) + uint y; + } +} +// ---- +// SyntaxError: (89-95): Variable declarations can only be used inside blocks. diff --git a/test/libsolidity/syntaxTests/variableDeclaration/while.sol b/test/libsolidity/syntaxTests/variableDeclaration/while.sol new file mode 100644 index 00000000..2997d80c --- /dev/null +++ b/test/libsolidity/syntaxTests/variableDeclaration/while.sol @@ -0,0 +1,11 @@ +pragma solidity >0.4.24; + +contract C +{ + function f(uint x) public pure { + while (x > 0) + uint y; + } +} +// ---- +// SyntaxError: (92-98): Variable declarations can only be used inside blocks. diff --git a/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode.sol b/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode.sol index ca7db42e..e0e031c2 100644 --- a/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode.sol +++ b/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode.sol @@ -1,5 +1,5 @@ contract C { - function f() pure public returns (bytes r) { + function f() pure public returns (bytes memory r) { r = abi.encode(1, 2); r = abi.encodePacked(f()); r = abi.encodeWithSelector(0x12345678, 1); diff --git a/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode_arguments.sol b/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode_arguments.sol index 547362c3..cc845d51 100644 --- a/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode_arguments.sol +++ b/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode_arguments.sol @@ -3,34 +3,34 @@ contract C { function gView() public view returns (uint) { return x; } function gNonPayable() public returns (uint) { x = 4; return 0; } - function f1() view public returns (bytes) { + function f1() view public returns (bytes memory) { return abi.encode(gView()); } - function f2() view public returns (bytes) { + function f2() view public returns (bytes memory) { return abi.encodePacked(gView()); } - function f3() view public returns (bytes) { + function f3() view public returns (bytes memory) { return abi.encodeWithSelector(0x12345678, gView()); } - function f4() view public returns (bytes) { + function f4() view public returns (bytes memory) { return abi.encodeWithSignature("f(uint256)", gView()); } - function g1() public returns (bytes) { + function g1() public returns (bytes memory) { return abi.encode(gNonPayable()); } - function g2() public returns (bytes) { + function g2() public returns (bytes memory) { return abi.encodePacked(gNonPayable()); } - function g3() public returns (bytes) { + function g3() public returns (bytes memory) { return abi.encodeWithSelector(0x12345678, gNonPayable()); } - function g4() public returns (bytes) { + function g4() public returns (bytes memory) { return abi.encodeWithSignature("f(uint256)", gNonPayable()); } // This will generate the only warning. - function check() public returns (bytes) { + function check() public returns (bytes memory) { return abi.encode(2); } } // ---- -// Warning: (1044-1121): Function state mutability can be restricted to pure +// Warning: (1100-1184): Function state mutability can be restricted to pure 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/builtin_functions.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol new file mode 100644 index 00000000..2503a319 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol @@ -0,0 +1,20 @@ +contract C { + function f() public { + address(this).transfer(1); + require(address(this).send(2)); + selfdestruct(address(this)); + (bool success,) = address(this).delegatecall(""); + require(success); + (success,) = address(this).call(""); + require(success); + } + function g() pure public { + bytes32 x = keccak256("abc"); + bytes32 y = sha256("abc"); + address z = ecrecover(bytes32(uint256(1)), uint8(2), bytes32(uint256(3)), bytes32(uint256(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..4a651d21 --- /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(uint256(1)), uint8(2), bytes32(uint256(3)), bytes32(uint256(4))); + require(true); + assert(true); + x; y; z; + } + function g() public { + bytes32 x = keccak256("abc"); + bytes32 y = sha256("abc"); + address z = ecrecover(bytes32(uint256(1)), uint8(2), bytes32(uint256(3)), bytes32(uint256(4))); + require(true); + assert(true); + x; y; z; + } +} +// ---- +// Warning: (17-288): Function state mutability can be restricted to pure +// Warning: (293-559): 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..5356f0b8 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol @@ -0,0 +1,27 @@ +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 { + (bool success,) = address(this).delegatecall(""); + require(success); + } + function j() view public { + (bool success,) = address(this).call(""); + require(success); + } + function() payable external { + } +} +// ---- +// 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: (293-323): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError: (414-436): 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/msg_value_modifier.sol b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier.sol new file mode 100644 index 00000000..160b20a7 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier.sol @@ -0,0 +1,6 @@ +contract C { + modifier m(uint _amount, uint _avail) { require(_avail >= _amount); _; } + function f() m(1 ether, msg.value) public pure {} +} +// ---- +// TypeError: (118-127): 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/msg_value_modifier_view.sol b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol new file mode 100644 index 00000000..613b0198 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol @@ -0,0 +1,6 @@ +contract C { + modifier m(uint _amount, uint _avail) { require(_avail >= _amount); _; } + function f() m(1 ether, msg.value) public view {} +} +// ---- +// TypeError: (118-127): "msg.value" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error. 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..4fc7900f --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/function_no_visibility.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure { } +} +// ---- +// SyntaxError: (17-38): No visibility specified. Did you intend to add "public"? diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol index 72ce3b40..b7e96e5e 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol @@ -2,5 +2,5 @@ interface I { function f(); } // ---- -// Warning: (15-28): Functions in interfaces should be declared external. -// Warning: (15-28): No visibility specified. Defaulting to "public". In interfaces it defaults to external. +// SyntaxError: (15-28): No visibility specified. Did you intend to add "external"? +// TypeError: (15-28): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol deleted file mode 100644 index 513df26b..00000000 --- a/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol +++ /dev/null @@ -1,7 +0,0 @@ -pragma experimental "v0.5.0"; -interface I { - function f(); -} -// ---- -// SyntaxError: (45-58): No visibility specified. -// TypeError: (45-58): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_external.sol index 3f0a9aca..ed409e58 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_external.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; interface I { function f() external; } diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol index ac62e69b..06c1547a 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol @@ -2,4 +2,4 @@ interface I { function f() internal; } // ---- -// TypeError: (15-37): Functions in interfaces cannot be internal or private. +// TypeError: (15-37): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol index 881e647e..98198c3d 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol @@ -2,4 +2,4 @@ interface I { function f() private; } // ---- -// TypeError: (15-36): Functions in interfaces cannot be internal or private. +// TypeError: (15-36): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol index 891d9fdf..a8cea199 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol @@ -2,4 +2,4 @@ interface I { function f() public; } // ---- -// Warning: (15-35): Functions in interfaces should be declared external. +// TypeError: (15-35): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol deleted file mode 100644 index e0c04095..00000000 --- a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -interface I { - function f() public; -} -// ---- -// TypeError: (45-65): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/interface_contract_function_default.sol b/test/libsolidity/syntaxTests/visibility/interface/interface_contract_function_default.sol new file mode 100644 index 00000000..b1a820ed --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/interface/interface_contract_function_default.sol @@ -0,0 +1,12 @@ +// State of the syntax checker has to be reset after the interface +// was visited. The suggested visibility for g() should not be external. +interface I { + function f(); +} +contract C { + function g(); +} +// ---- +// SyntaxError: (158-171): No visibility specified. Did you intend to add "external"? +// SyntaxError: (191-204): No visibility specified. Did you intend to add "public"? +// TypeError: (158-171): Functions in interfaces must be declared external. |