Skip to content

can not get value from complex struct  #4419

Closed
@Colonel86

Description

@Colonel86
contract Complex {
    struct Data {
        uint a;
        bytes3 b;
        mapping (uint => uint) map;
    }
    Data public tempData = Data({a:123,b:"abc"});
    
    mapping (uint => mapping(bool => Data[])) public data;
    
    function setData() public{
        tempData.map[0] = 456;
    }
    
    function getValue() public returns(uint){
        return tempData.map[0];
    }
    
    function setComplex() public {
        data[0][false].push(tempData);
    }
    
    function getData(uint arg1, bool arg2, uint arg3) public returns (uint a, bytes3 b, uint value,uint tempInt) {
        // a = data[arg1][arg2][arg3].a;
        // b = data[arg1][arg2][arg3].b;
        Data mdata = data[arg1][arg2][arg3];
        a = mdata.a;
        b = mdata.b;
        mapping (uint => uint) tempMap = mdata.map;
        value = tempMap[0];
        tempInt = mdata.map[0];
    }
}

In remix ,Current version:0.4.24+commit.e67f0147.Emscripten.clang
setData()
getValue()
setComplex()

but call getData(0, false, 0).

 a = 123
b  = 0x616263
value  = 0
tempInt = 0

why "value" and "tempInt" = 0
Logically it should value = 456 and tempInt = 456
What's the reason?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions