-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comprehensive tests for invalid array indexing
- Loading branch information
Showing
12 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
test/libsolidity/syntaxTests/array/length/bytes32_too_large.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
contract C { | ||
bytes32[8**90] ids; | ||
} | ||
// ---- | ||
// TypeError: (25-30): Invalid array length, expected integer literal or constant expression. |
5 changes: 5 additions & 0 deletions
5
test/libsolidity/syntaxTests/array/length/bytes32_too_large_multidim.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
contract C { | ||
bytes32[8**90][500] ids; | ||
} | ||
// ---- | ||
// TypeError: (25-30): Invalid array length, expected integer literal or constant expression. |
5 changes: 5 additions & 0 deletions
5
test/libsolidity/syntaxTests/array/length/parameter_too_large.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
contract C { | ||
function f(bytes32[1263941234127518272] memory) public pure {} | ||
} | ||
// ---- | ||
// TypeError: (26-61): Array is too large to be encoded. |
5 changes: 5 additions & 0 deletions
5
test/libsolidity/syntaxTests/array/length/parameter_too_large_multidim.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
contract C { | ||
function f(bytes32[1263941234127518272][500] memory) public pure {} | ||
} | ||
// ---- | ||
// TypeError: (26-61): Array is too large to be encoded. |
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
test/libsolidity/syntaxTests/array/length/uint_too_large_multidim.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
contract C { | ||
uint[8**90][500] ids; | ||
} | ||
// ---- | ||
// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. |
6 changes: 6 additions & 0 deletions
6
test/libsolidity/syntaxTests/indexing/array_multidim_overflow_index.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
contract C { | ||
function f() public { | ||
bytes[32] memory a; | ||
a[8**90][8**90][1 - 8**90]; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
test/libsolidity/syntaxTests/indexing/array_multidim_rational.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
contract C { | ||
function f() public { | ||
bytes[32] memory a; | ||
a[8**90][8**90][8**90*0.1]; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/indexing/array_negative_index.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/indexing/array_nontinteger_index.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/syntaxTests/indexing/fixedbytes_negative_index.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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): Out of bounds array access. |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/indexing/fixedbytes_noninteger_index.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
contract C { | ||
function f() public { | ||
bytes32 b; | ||
b[888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888]; | ||
} | ||
} | ||
// ---- | ||
// TypeError: (56-61): Out of bounds array access. |