I am using solidity ^0.8.7. When I try to create a Struct that contains mapping, I revied an error: "Struct containing a (nested) mapping cannot be constructed." I think it is something to do with documentation changes in version 0.7.0. But I cannot find a solution.
The code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
...
struct Transaction {
address to;
uint value;
bytes data;
bool executed;
mapping(address => bool) isConfirmed;
uint numConfirmations;
}
...
function submitTransaction (address _to, uint _value, bytes memory _data) public onlyOwner{
uint txIndex = transactions.length;
transactions.push(Transaction({to: _to, value: _value, data: _data, executed: false, numConfirmations: 0}));
emit SubmitTransaction(msg.sender, txIndex, _to, _value, _data);
}
...
Using an older version of Solidity compiles it with no problems.