Is the tool support mapping with struct to wasm ?
BigMonsterYY opened this issue · 6 comments
such as mapping(uint=>struct{}) ?
i tested this contract:
`
pragma solidity ^0.6.12;
contract map_t {
struct Message {
uint8 head;
uint8 body;
uint8 end;
}
mapping(uint8 => Message) private mms;
uint64 maxIndex;
function add_message(
uint8 index,
uint8 a,
uint8 b,
uint8 c
) public {
Message memory d= Message({
head:a,
body:b,
end:c
});
mms[index]=d;
if (index > maxIndex) {
maxIndex = index;
}
}
function get_message_size() public view returns (uint64) {
return maxIndex;
}
function get_message_body(uint8 index) public view returns (uint8 ) {
return mms[index].body;
}
}
`
but i got a err:
ch@ubuntu:~/gopath/src/github.com/second-state/soll/test/solidity$ sudo ../../../soll/build/tools/soll/soll ./map.sol soll: /home/ch/gopath/src/github.com/second-state/soll/lib/AST/Expr.cpp:90: void soll::Identifier::updateTypeFromCurrentDecl(): Assertion
false && "unknown decl"' failed.
Aborted`
Hi @BigMonsterYY,
Thanks for addressing this issue. The structs
as mapping's ValueType is not yet supported by our solidity frontend in current stage. We would add an error message to point out this unimplemented feature.
Here is a workaround for your contract. Try to use mapping(uint8 => uint8)
or mapping(string => uint8)
instead of using struct
as ValueType.
mapping(uint8 => mapping(string => uint8)) private mms;
mms[index]["head"] = a;
@hydai thanks ,i got it.
fixed
Hi @BigMonsterYY
This issue is resolved on the master branch. Could you give it a try on it? If there is still an issue, we are happy to figure out and fix it.