From ff5be1799088ca51fb51e9c86031bd2d88fe3bce Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Fri, 21 Sep 2018 18:26:19 +0200 Subject: Disallows fixed-size multidim. arrays with zero-length. --- test/libsolidity/syntaxTests/array/multi_dim_zero_length.sol | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 test/libsolidity/syntaxTests/array/multi_dim_zero_length.sol (limited to 'test/libsolidity') diff --git a/test/libsolidity/syntaxTests/array/multi_dim_zero_length.sol b/test/libsolidity/syntaxTests/array/multi_dim_zero_length.sol new file mode 100644 index 00000000..2f487cde --- /dev/null +++ b/test/libsolidity/syntaxTests/array/multi_dim_zero_length.sol @@ -0,0 +1,6 @@ +contract C { + bytes[0] a; + function f() public pure returns(bytes32[0][500] memory) {} +} +// ---- +// TypeError: (62-84): Fixed-size multidimensional arrays are not allowed to have zero length. -- cgit From d821cbdff5a483b3f7a7bd07758bf5e11a7cd762 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Sat, 22 Sep 2018 00:18:22 +0200 Subject: Moves length check to reference resolver. --- .../array/length/fixed_size_multidim_zero_length.sol | 15 +++++++++++++++ .../syntaxTests/array/length/fixed_size_zero_length.sol | 15 +++++++++++++++ test/libsolidity/syntaxTests/array/length/parentheses.sol | 2 +- .../syntaxTests/array/multi_dim_zero_length.sol | 6 ------ .../libsolidity/syntaxTests/parsing/arrays_in_storage.sol | 2 +- 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol create mode 100644 test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol delete mode 100644 test/libsolidity/syntaxTests/array/multi_dim_zero_length.sol (limited to 'test/libsolidity') 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/array/length/parentheses.sol b/test/libsolidity/syntaxTests/array/length/parentheses.sol index 40f55ad6..8dbcc0a4 100644 --- a/test/libsolidity/syntaxTests/array/length/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/array/multi_dim_zero_length.sol b/test/libsolidity/syntaxTests/array/multi_dim_zero_length.sol deleted file mode 100644 index 2f487cde..00000000 --- a/test/libsolidity/syntaxTests/array/multi_dim_zero_length.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - bytes[0] a; - function f() public pure returns(bytes32[0][500] memory) {} -} -// ---- -// TypeError: (62-84): Fixed-size multidimensional arrays are not allowed to have zero length. diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol index 9181222e..9adf6f12 100644 --- a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol +++ b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol @@ -1,6 +1,6 @@ contract c { uint[10] a; uint[] a2; - struct x { uint[2**20] b; y[0] c; } + struct x { uint[2**20] b; y[1] c; } struct y { uint d; mapping(uint=>x)[] e; } } -- cgit