Currently we translate storage structures to SMT datatypes. Assignments between them are simply translated to assignments between the datatypes, which will make a deep copy. However, in Solidity there is an exception: mappings are not copied.
pragma solidity >=0.5.0;
contract StructsMaps {
struct A {
mapping(address=>int) m;
}
A a1;
A a2;
function() external payable {
a1.m[address(this)] = 2;
a1 = a2; // Mapping should not be overwritten
assert(a1.m[address(this)] == 2);
}
}
Output:
$ solc-verify.py StructsMaps.sol
StructsMaps::[fallback]: ERROR
- StructsMaps.sol:15:5: Assertion might not hold.
StructsMaps::[implicit_constructor]: OK
Errors were found by the verifier.
Currently we translate storage structures to SMT datatypes. Assignments between them are simply translated to assignments between the datatypes, which will make a deep copy. However, in Solidity there is an exception: mappings are not copied.
Output:
(The assert should hold.)