mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #7431 from ethereum/fix_array_mapping
Fix ICE when pop dyn storage array of mapping
This commit is contained in:
commit
34a84f3a4f
@ -13,6 +13,7 @@ Compiler Features:
|
|||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
* Fix internal error when popping a dynamic storage array of mappings.
|
||||||
|
|
||||||
|
|
||||||
### 0.5.11 (2019-08-12)
|
### 0.5.11 (2019-08-12)
|
||||||
|
@ -896,11 +896,16 @@ void ArrayUtils::popStorageArrayElement(ArrayType const& _type) const
|
|||||||
// Stack: ArrayReference oldLength
|
// Stack: ArrayReference oldLength
|
||||||
m_context << u256(1) << Instruction::SWAP1 << Instruction::SUB;
|
m_context << u256(1) << Instruction::SWAP1 << Instruction::SUB;
|
||||||
// Stack ArrayReference newLength
|
// Stack ArrayReference newLength
|
||||||
|
|
||||||
|
if (_type.baseType()->category() != Type::Category::Mapping)
|
||||||
|
{
|
||||||
m_context << Instruction::DUP2 << Instruction::DUP2;
|
m_context << Instruction::DUP2 << Instruction::DUP2;
|
||||||
// Stack ArrayReference newLength ArrayReference newLength;
|
// Stack ArrayReference newLength ArrayReference newLength;
|
||||||
accessIndex(_type, false);
|
accessIndex(_type, false);
|
||||||
// Stack: ArrayReference newLength storage_slot byte_offset
|
// Stack: ArrayReference newLength storage_slot byte_offset
|
||||||
StorageItem(m_context, *_type.baseType()).setToZero(SourceLocation(), true);
|
StorageItem(m_context, *_type.baseType()).setToZero(SourceLocation(), true);
|
||||||
|
}
|
||||||
|
|
||||||
// Stack: ArrayReference newLength
|
// Stack: ArrayReference newLength
|
||||||
m_context << Instruction::SWAP1 << Instruction::SSTORE;
|
m_context << Instruction::SWAP1 << Instruction::SSTORE;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
contract C {
|
||||||
|
mapping (uint => uint)[][] a;
|
||||||
|
|
||||||
|
function n1(uint key, uint value) public {
|
||||||
|
a.length++;
|
||||||
|
mapping (uint => uint)[] storage b = a[a.length - 1];
|
||||||
|
b.length++;
|
||||||
|
b[b.length - 1][key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function n2() public {
|
||||||
|
a.length++;
|
||||||
|
mapping (uint => uint)[] storage b = a[a.length - 1];
|
||||||
|
b.length++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function map(uint key) public view returns (uint) {
|
||||||
|
mapping (uint => uint)[] storage b = a[a.length - 1];
|
||||||
|
return b[b.length - 1][key];
|
||||||
|
}
|
||||||
|
|
||||||
|
function p() public {
|
||||||
|
a.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
function d() public returns (uint) {
|
||||||
|
delete a;
|
||||||
|
return a.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// n1(uint256,uint256): 42, 64 ->
|
||||||
|
// map(uint256): 42 -> 64
|
||||||
|
// p() ->
|
||||||
|
// n2() ->
|
||||||
|
// map(uint256): 42 -> 64
|
||||||
|
// d() -> 0
|
||||||
|
// n2() ->
|
||||||
|
// map(uint256): 42 -> 64
|
@ -0,0 +1,34 @@
|
|||||||
|
contract C {
|
||||||
|
mapping (uint => uint)[] a;
|
||||||
|
|
||||||
|
function n1(uint key, uint value) public {
|
||||||
|
a.length++;
|
||||||
|
a[a.length - 1][key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function n2() public {
|
||||||
|
a.length++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function map(uint key) public view returns (uint) {
|
||||||
|
return a[a.length - 1][key];
|
||||||
|
}
|
||||||
|
|
||||||
|
function p() public {
|
||||||
|
a.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
function d() public returns (uint) {
|
||||||
|
delete a;
|
||||||
|
return a.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// n1(uint256,uint256): 42, 64 ->
|
||||||
|
// map(uint256): 42 -> 64
|
||||||
|
// p() ->
|
||||||
|
// n2() ->
|
||||||
|
// map(uint256): 42 -> 64
|
||||||
|
// d() -> 0
|
||||||
|
// n2() ->
|
||||||
|
// map(uint256): 42 -> 64
|
Loading…
Reference in New Issue
Block a user