mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5195 from ethereum/unsigned-array-index
Do not crash on non-unsigned array index
This commit is contained in:
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user