npm으로 설치한 Solc version 0.7.0을 쓰고 있어요. 안에 mapping이 있는 Struct를 만들면 "Struct containing a (nested) mapping cannot be constructed."라는 메시지가 나옵니다.
코드를 봐 주세요:
// SPDX-License-Identifier: MIT
pragma solidity 0.7.0;
contract Store {
struct Submission {
uint256 amount;
mapping(address => bool) votes;
}
Submission[] public submissions;
...
function addSubmission(
uint256 amount
) public {
Submission memory fresh = Submission({ // compiler reports the error here
amount: amount
});
submissions.push(fresh);
}
}
이전 solc 버전에서는 같은 코드가 문제없이 빌드됩니다.
살펴봐 주셔서 감사합니다!
영어에서 번역·원문 보기My npm installation provides Solc version 0.7.0. Creating a Struct with a mapping inside emits the message: "Struct containing a (nested) mapping cannot be constructed."
Here is the code to look at:
// SPDX-License-Identifier: MIT
pragma solidity 0.7.0;
contract Store {
struct Submission {
uint256 amount;
mapping(address => bool) votes;
}
Submission[] public submissions;
...
function addSubmission(
uint256 amount
) public {
Submission memory fresh = Submission({ // compiler reports the error here
amount: amount
});
submissions.push(fresh);
}
}
With earlier solc versions, this same code builds successfully.
Thanks for taking a look!