Skip to content

Commit

Permalink
Add comprehensive tests for invalid array indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Sep 26, 2018
1 parent 13cd7c3 commit c9eaccb
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 0 deletions.
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.
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.
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.
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.
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.
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];
}
}
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];
}
}
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.
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.
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.
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.

0 comments on commit c9eaccb

Please sign in to comment.