From 98d52beba3f989b3a5eeaba2d257de8de5df60a7 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 16 May 2018 17:18:30 +0200 Subject: Adds syntax tests, documentation and changelog entry. Refines comment for array utility function. --- Changelog.md | 2 ++ docs/types.rst | 4 +++- libsolidity/codegen/ArrayUtils.cpp | 2 +- libsolidity/codegen/ArrayUtils.h | 2 +- test/libsolidity/syntaxTests/array/array_pop.sol | 7 ++++++ .../syntaxTests/array/array_pop_arg.sol | 8 +++++++ test/libsolidity/syntaxTests/array/bytes_pop.sol | 7 ++++++ .../syntaxTests/array/dynamic_memory_array_pop.sol | 8 +++++++ ...ength_cannot_be_constant_function_parameter.sol | 7 ++++++ .../array/length/can_be_constant_in_function.sol | 8 +++++++ .../array/length/can_be_constant_in_struct.sol | 7 ++++++ .../array/length/can_be_recursive_constant.sol | 6 ++++++ .../array/length/cannot_be_function.sol | 6 ++++++ .../array/length/cannot_be_function_call.sol | 7 ++++++ .../array/length/complex_cyclic_constant.sol | 10 +++++++++ .../array/length/const_cannot_be_fractional.sol | 6 ++++++ .../syntaxTests/array/length/constant_var.sol | 5 +++++ .../syntaxTests/array/length/cyclic_constant.sol | 8 +++++++ .../syntaxTests/array/length/inline_array.sol | 5 +++++ .../array/length/invalid_expression_1.sol | 5 +++++ .../array/length/invalid_expression_2.sol | 5 +++++ .../array/length/invalid_expression_3.sol | 5 +++++ .../array/length/invalid_expression_4.sol | 5 +++++ .../array/length/invalid_expression_5.sol | 5 +++++ .../array/length/non_integer_constant_var.sol | 6 ++++++ .../array/length/not_convertible_to_integer.sol | 5 +++++ .../syntaxTests/array/length/parentheses.sol | 25 ++++++++++++++++++++++ .../syntaxTests/array/length/pure_functions.sol | 6 ++++++ .../syntaxTests/array/length/too_large.sol | 5 +++++ .../syntaxTests/array/length/tuples.sol | 5 +++++ .../libsolidity/syntaxTests/array/no_array_pop.sol | 8 +++++++ .../syntaxTests/array/static_storage_array_pop.sol | 8 +++++++ test/libsolidity/syntaxTests/array/string_pop.sol | 8 +++++++ ...ength_cannot_be_constant_function_parameter.sol | 7 ------ .../arrayLength/can_be_constant_in_function.sol | 8 ------- .../arrayLength/can_be_constant_in_struct.sol | 7 ------ .../arrayLength/can_be_recursive_constant.sol | 6 ------ .../syntaxTests/arrayLength/cannot_be_function.sol | 6 ------ .../arrayLength/cannot_be_function_call.sol | 7 ------ .../arrayLength/complex_cyclic_constant.sol | 10 --------- .../arrayLength/const_cannot_be_fractional.sol | 6 ------ .../syntaxTests/arrayLength/constant_var.sol | 5 ----- .../syntaxTests/arrayLength/cyclic_constant.sol | 8 ------- .../syntaxTests/arrayLength/inline_array.sol | 5 ----- .../arrayLength/invalid_expression_1.sol | 5 ----- .../arrayLength/invalid_expression_2.sol | 5 ----- .../arrayLength/invalid_expression_3.sol | 5 ----- .../arrayLength/invalid_expression_4.sol | 5 ----- .../arrayLength/invalid_expression_5.sol | 5 ----- .../arrayLength/non_integer_constant_var.sol | 6 ------ .../arrayLength/not_convertible_to_integer.sol | 5 ----- .../syntaxTests/arrayLength/parentheses.sol | 25 ---------------------- .../syntaxTests/arrayLength/pure_functions.sol | 6 ------ .../syntaxTests/arrayLength/too_large.sol | 5 ----- .../libsolidity/syntaxTests/arrayLength/tuples.sol | 5 ----- 55 files changed, 213 insertions(+), 155 deletions(-) create mode 100644 test/libsolidity/syntaxTests/array/array_pop.sol create mode 100644 test/libsolidity/syntaxTests/array/array_pop_arg.sol create mode 100644 test/libsolidity/syntaxTests/array/bytes_pop.sol create mode 100644 test/libsolidity/syntaxTests/array/dynamic_memory_array_pop.sol create mode 100644 test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol create mode 100644 test/libsolidity/syntaxTests/array/length/can_be_constant_in_function.sol create mode 100644 test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol create mode 100644 test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol create mode 100644 test/libsolidity/syntaxTests/array/length/cannot_be_function.sol create mode 100644 test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol create mode 100644 test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol create mode 100644 test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol create mode 100644 test/libsolidity/syntaxTests/array/length/constant_var.sol create mode 100644 test/libsolidity/syntaxTests/array/length/cyclic_constant.sol create mode 100644 test/libsolidity/syntaxTests/array/length/inline_array.sol create mode 100644 test/libsolidity/syntaxTests/array/length/invalid_expression_1.sol create mode 100644 test/libsolidity/syntaxTests/array/length/invalid_expression_2.sol create mode 100644 test/libsolidity/syntaxTests/array/length/invalid_expression_3.sol create mode 100644 test/libsolidity/syntaxTests/array/length/invalid_expression_4.sol create mode 100644 test/libsolidity/syntaxTests/array/length/invalid_expression_5.sol create mode 100644 test/libsolidity/syntaxTests/array/length/non_integer_constant_var.sol create mode 100644 test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol create mode 100644 test/libsolidity/syntaxTests/array/length/parentheses.sol create mode 100644 test/libsolidity/syntaxTests/array/length/pure_functions.sol create mode 100644 test/libsolidity/syntaxTests/array/length/too_large.sol create mode 100644 test/libsolidity/syntaxTests/array/length/tuples.sol create mode 100644 test/libsolidity/syntaxTests/array/no_array_pop.sol create mode 100644 test/libsolidity/syntaxTests/array/static_storage_array_pop.sol create mode 100644 test/libsolidity/syntaxTests/array/string_pop.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/constant_var.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/inline_array.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/parentheses.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/pure_functions.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/too_large.sol delete mode 100644 test/libsolidity/syntaxTests/arrayLength/tuples.sol diff --git a/Changelog.md b/Changelog.md index c31aced2..a1248868 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ ### 0.5.0 (unreleased) +Language Features: + * General: Support ``pop()`` for storage arrays. Breaking Changes: * Disallow conversions between bytesX and uintY of different size. diff --git a/docs/types.rst b/docs/types.rst index 794a70de..b3631f74 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -682,7 +682,7 @@ possible: It is planned to remove this restriction in the future but currently creates some complications because of how arrays are passed in the ABI. -.. index:: ! array;length, length, push, !array;push +.. index:: ! array;length, length, push, pop, !array;push, !array;pop Members ^^^^^^^ @@ -693,6 +693,8 @@ Members ``.length`` member. This does not happen automatically when attempting to access elements outside the current length. The size of memory arrays is fixed (but dynamic, i.e. it can depend on runtime parameters) once they are created. **push**: Dynamic storage arrays and ``bytes`` (not ``string``) have a member function called ``push`` that can be used to append an element at the end of the array. The function returns the new length. +**pop**: + Dynamic storage arrays and ``bytes`` (not ``string``) have a member function called ``pop`` that can be used to remove an element from the end of the array. .. warning:: It is not yet possible to use arrays of arrays in external functions. diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index d78e64a9..6bb9a961 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -840,7 +840,7 @@ void ArrayUtils::popStorageArrayElement(ArrayType const& _type) const let length := and(div(slot_value, 2), 0x1f) if iszero(length) { invalid() } - // Zero-out the suffix inlcluding the least significant byte. + // Zero-out the suffix including the least significant byte. let mask := sub(exp(0x100, sub(33, length)), 1) length := sub(length, 1) slot_value := or(and(not(mask), slot_value), mul(length, 2)) diff --git a/libsolidity/codegen/ArrayUtils.h b/libsolidity/codegen/ArrayUtils.h index 84d591d7..daf50bf5 100644 --- a/libsolidity/codegen/ArrayUtils.h +++ b/libsolidity/codegen/ArrayUtils.h @@ -73,7 +73,7 @@ public: /// Stack pre: reference (excludes byte offset) /// Stack post: new_length void incrementDynamicArraySize(ArrayType const& _type) const; - /// Decrements the size of a dynamic array by one if length is nonzero. Returns otherwise. + /// Decrements the size of a dynamic array by one if length is nonzero. Causes an invalid instruction otherwise. /// Clears the removed data element. In case of a byte array, this might move the data. /// Stack pre: reference /// Stack post: 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..11d40f26 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol @@ -0,0 +1,7 @@ +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/array/length/can_be_constant_in_function.sol b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_function.sol new file mode 100644 index 00000000..92536dd5 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_function.sol @@ -0,0 +1,8 @@ +contract C { + uint constant LEN = 10; + function f() public pure { + uint[LEN] memory a; + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol new file mode 100644 index 00000000..89e174f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol @@ -0,0 +1,7 @@ +contract C { + uint constant LEN = 10; + struct Test { + uint[LEN] ids; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol b/test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol new file mode 100644 index 00000000..6810a9d6 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol @@ -0,0 +1,6 @@ +contract C { + uint constant L = 5; + uint constant LEN = L + 4 * L; + uint[LEN] ids; +} +// ---- 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..ac3abc4c --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol @@ -0,0 +1,6 @@ +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/array/length/cannot_be_function_call.sol b/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol new file mode 100644 index 00000000..a6863955 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint x) {} + uint constant LEN = f(); + uint[LEN] ids; +} +// ---- +// TypeError: (77-80): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol b/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol new file mode 100644 index 00000000..254f9f02 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol @@ -0,0 +1,10 @@ +contract C { + uint constant L2 = LEN - 10; + uint constant L1 = L2 / 10; + uint constant LEN = 10 + L1 * 5; + function f() { + uint[LEN] a; + } +} +// ---- +// TypeError: (36-39): Cyclic constant definition (or maximum recursion depth exhausted). diff --git a/test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol b/test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol new file mode 100644 index 00000000..397bbbcd --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol @@ -0,0 +1,6 @@ +contract C { + fixed constant L = 10.5; + uint[L] ids; +} +// ---- +// TypeError: (51-52): Array with fractional length specified. diff --git a/test/libsolidity/syntaxTests/array/length/constant_var.sol b/test/libsolidity/syntaxTests/array/length/constant_var.sol new file mode 100644 index 00000000..41750250 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/constant_var.sol @@ -0,0 +1,5 @@ +contract C { + uint constant LEN = 10; + uint[LEN] ids; +} +// ---- \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol b/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol new file mode 100644 index 00000000..91ba9045 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol @@ -0,0 +1,8 @@ +contract C { + uint constant LEN = LEN; + function f() { + uint[LEN] a; + } +} +// ---- +// TypeError: (37-40): Cyclic constant definition (or maximum recursion depth exhausted). diff --git a/test/libsolidity/syntaxTests/array/length/inline_array.sol b/test/libsolidity/syntaxTests/array/length/inline_array.sol new file mode 100644 index 00000000..a30745d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/inline_array.sol @@ -0,0 +1,5 @@ +contract C { + uint[[2]] a15; +} +// ---- +// TypeError: (22-25): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/invalid_expression_1.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_1.sol new file mode 100644 index 00000000..c92861eb --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_1.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/array/length/invalid_expression_2.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_2.sol new file mode 100644 index 00000000..92e3c3cf --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_2.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/array/length/invalid_expression_3.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_3.sol new file mode 100644 index 00000000..26add45c --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_3.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/array/length/invalid_expression_4.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_4.sol new file mode 100644 index 00000000..a0d58f4a --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_4.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/array/length/invalid_expression_5.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_5.sol new file mode 100644 index 00000000..38a80867 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_5.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/array/length/non_integer_constant_var.sol b/test/libsolidity/syntaxTests/array/length/non_integer_constant_var.sol new file mode 100644 index 00000000..7a853a34 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/non_integer_constant_var.sol @@ -0,0 +1,6 @@ +contract C { + bool constant LEN = true; + uint[LEN] ids; +} +// ---- +// TypeError: (52-55): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol b/test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol new file mode 100644 index 00000000..b44ccfe9 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol @@ -0,0 +1,5 @@ +contract C { + uint[true] ids; +} +// ---- +// TypeError: (22-26): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/parentheses.sol b/test/libsolidity/syntaxTests/array/length/parentheses.sol new file mode 100644 index 00000000..40f55ad6 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/parentheses.sol @@ -0,0 +1,25 @@ +contract C { + uint constant L1 = (2); + uint constant L2 = ((2)); + uint constant L3 = ((((2)))); + uint constant L4 = (2 + 1); + uint constant L5 = ((2 + 1)); + uint constant L6 = (((2) + ((1)))); + uint constant L7 = (2 + 1) / 1; + uint constant L8 = (2 + ((1))) / (1); + uint[L1] a1; + uint[L2] a2; + uint[L3] a3; + uint[L4] a4; + uint[L5] a5; + uint[L6] a6; + uint[L7] a7; + uint[L8] a8; + uint[(2)] a9; + uint[(2 + 1)] a10; + uint[(2 + 1) + 1] a11; + uint[((2) + 1) + 1] a12; + uint[(2 + 1) + ((1))] a13; + uint[(((2) + 1)) + (((1)))] a14; + uint[((((2) + 1)) + (((1))))%1] a15; +} diff --git a/test/libsolidity/syntaxTests/array/length/pure_functions.sol b/test/libsolidity/syntaxTests/array/length/pure_functions.sol new file mode 100644 index 00000000..b620db76 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/pure_functions.sol @@ -0,0 +1,6 @@ +contract C { + uint constant LEN = keccak256(ripemd160(33)); + uint[LEN] ids; +} +// ---- +// TypeError: (72-75): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/too_large.sol b/test/libsolidity/syntaxTests/array/length/too_large.sol new file mode 100644 index 00000000..c90a7494 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/too_large.sol @@ -0,0 +1,5 @@ +contract C { + uint[8**90] ids; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/array/length/tuples.sol b/test/libsolidity/syntaxTests/array/length/tuples.sol new file mode 100644 index 00000000..bc10b3b5 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/length/tuples.sol @@ -0,0 +1,5 @@ +contract C { + uint[(1,2)] a15; +} +// ---- +// 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..44e54ad2 --- /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..0af171ad --- /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..2a46d0c3 --- /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/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/can_be_constant_in_function.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol deleted file mode 100644 index 92536dd5..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract C { - uint constant LEN = 10; - function f() public pure { - uint[LEN] memory a; - a; - } -} -// ---- diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol deleted file mode 100644 index 89e174f2..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract C { - uint constant LEN = 10; - struct Test { - uint[LEN] ids; - } -} -// ---- diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol deleted file mode 100644 index 6810a9d6..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - uint constant L = 5; - uint constant LEN = L + 4 * L; - uint[LEN] ids; -} -// ---- 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/arrayLength/cannot_be_function_call.sol b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol deleted file mode 100644 index a6863955..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract C { - function f(uint x) {} - uint constant LEN = f(); - uint[LEN] ids; -} -// ---- -// TypeError: (77-80): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol b/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol deleted file mode 100644 index 254f9f02..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol +++ /dev/null @@ -1,10 +0,0 @@ -contract C { - uint constant L2 = LEN - 10; - uint constant L1 = L2 / 10; - uint constant LEN = 10 + L1 * 5; - function f() { - uint[LEN] a; - } -} -// ---- -// TypeError: (36-39): Cyclic constant definition (or maximum recursion depth exhausted). diff --git a/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol b/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol deleted file mode 100644 index 397bbbcd..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - fixed constant L = 10.5; - uint[L] ids; -} -// ---- -// TypeError: (51-52): Array with fractional length specified. diff --git a/test/libsolidity/syntaxTests/arrayLength/constant_var.sol b/test/libsolidity/syntaxTests/arrayLength/constant_var.sol deleted file mode 100644 index 41750250..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/constant_var.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint constant LEN = 10; - uint[LEN] ids; -} -// ---- \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol b/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol deleted file mode 100644 index 91ba9045..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract C { - uint constant LEN = LEN; - function f() { - uint[LEN] a; - } -} -// ---- -// TypeError: (37-40): Cyclic constant definition (or maximum recursion depth exhausted). diff --git a/test/libsolidity/syntaxTests/arrayLength/inline_array.sol b/test/libsolidity/syntaxTests/arrayLength/inline_array.sol deleted file mode 100644 index a30745d3..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/inline_array.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint[[2]] a15; -} -// ---- -// TypeError: (22-25): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol deleted file mode 100644 index c92861eb..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint[-true] ids; -} -// ---- -// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol deleted file mode 100644 index 92e3c3cf..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint[true/1] ids; -} -// ---- -// TypeError: (22-28): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol deleted file mode 100644 index 26add45c..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint[1/true] ids; -} -// ---- -// TypeError: (22-28): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol deleted file mode 100644 index a0d58f4a..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint[1.111111E1111111111111] ids; -} -// ---- -// TypeError: (22-44): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol deleted file mode 100644 index 38a80867..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol +++ /dev/null @@ -1,5 +0,0 @@ -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/arrayLength/non_integer_constant_var.sol b/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol deleted file mode 100644 index 7a853a34..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - bool constant LEN = true; - uint[LEN] ids; -} -// ---- -// TypeError: (52-55): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol b/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol deleted file mode 100644 index b44ccfe9..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint[true] ids; -} -// ---- -// TypeError: (22-26): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/parentheses.sol b/test/libsolidity/syntaxTests/arrayLength/parentheses.sol deleted file mode 100644 index 40f55ad6..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/parentheses.sol +++ /dev/null @@ -1,25 +0,0 @@ -contract C { - uint constant L1 = (2); - uint constant L2 = ((2)); - uint constant L3 = ((((2)))); - uint constant L4 = (2 + 1); - uint constant L5 = ((2 + 1)); - uint constant L6 = (((2) + ((1)))); - uint constant L7 = (2 + 1) / 1; - uint constant L8 = (2 + ((1))) / (1); - uint[L1] a1; - uint[L2] a2; - uint[L3] a3; - uint[L4] a4; - uint[L5] a5; - uint[L6] a6; - uint[L7] a7; - uint[L8] a8; - uint[(2)] a9; - uint[(2 + 1)] a10; - uint[(2 + 1) + 1] a11; - uint[((2) + 1) + 1] a12; - uint[(2 + 1) + ((1))] a13; - uint[(((2) + 1)) + (((1)))] a14; - uint[((((2) + 1)) + (((1))))%1] a15; -} diff --git a/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol b/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol deleted file mode 100644 index b620db76..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - uint constant LEN = keccak256(ripemd160(33)); - uint[LEN] ids; -} -// ---- -// TypeError: (72-75): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/too_large.sol b/test/libsolidity/syntaxTests/arrayLength/too_large.sol deleted file mode 100644 index c90a7494..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/too_large.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint[8**90] ids; -} -// ---- -// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/tuples.sol b/test/libsolidity/syntaxTests/arrayLength/tuples.sol deleted file mode 100644 index bc10b3b5..00000000 --- a/test/libsolidity/syntaxTests/arrayLength/tuples.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { - uint[(1,2)] a15; -} -// ---- -// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. -- cgit v1.2.3