solidity/test/libsolidity/smtCheckerTests/types/array_mapping_aliasing_1.sol

30 lines
963 B
Solidity
Raw Normal View History

2019-02-21 12:01:58 +00:00
pragma experimental SMTChecker;
contract C
{
mapping (uint => uint) singleMap;
mapping (uint => uint)[] severalMaps;
mapping (uint => uint8)[] severalMaps8;
mapping (uint => uint)[][] severalMaps3d;
function f(mapping (uint => uint) storage map) internal {
2020-02-12 02:21:42 +00:00
severalMaps[0][0] = 42;
severalMaps8[0][0] = 42;
severalMaps3d[0][0][0] = 42;
2019-02-21 12:01:58 +00:00
map[0] = 2;
// Should fail since map == severalMaps[0] is possible.
assert(severalMaps[0][0] == 42);
// Should not fail since knowledge is erased only for mapping (uint => uint).
2019-02-21 12:01:58 +00:00
assert(severalMaps8[0][0] == 42);
// Should fail since map == severalMaps3d[0][0] is possible.
assert(severalMaps3d[0][0][0] == 42);
}
2020-02-12 02:21:42 +00:00
function g(uint x) public {
f(severalMaps[x]);
}
2019-02-21 12:01:58 +00:00
}
// ----
2020-02-12 02:21:42 +00:00
// Warning: (421-452): Assertion violation happens here
// Warning: (635-671): Assertion violation happens here
// Warning: (421-452): Assertion violation happens here
// Warning: (635-671): Assertion violation happens here