using complex data types in mapping isn't working

jyounanjyounan Member Posts: 1
edited May 2016 in Solidity
Hi guys, can someone shed some light on following scenario:
struct Dealership {
    bool exists;
    uint id;
    string location;
    string name;
}

event logs(uint date, string detail);
mapping (uint => mapping (uint => Dealership)) subDealerships;

function registerDealerComplexType() returns(true) {
//this does not work
Dealership dealer = Dealership({exists: true, id: 100, location: "SYD" , name: "FOO"});
subDealerships[1][100] = dealer;

logs(now, "here");
return true;
}


//but this works
//note that mapping type is NOT complex now
mapping (uint => mapping (uint => uint)) subDealershipsNew;

function registerDealerSimple() returns(true) {
subDealershipsNew[1][100] = 1;

logs(now, "here");
return true;
}


The registerDealerComplexType() doesn't work and by that i mean the line logs(now, "here"); never gets executed and the event isn't present. If i remove the line subDealerships[1][100] = dealer; i can see the event being generated which leads me to believe that there is a problem with setting mapping key to value of type struct.

The call to registerDealerSimple() is good and event appears.


The documentation says that i can use any type in mapping but practically it doesn't seem to be the case. Is anyone able to point out the issue here? Is this a bug or am i missing something?
Post edited by jyounan on
Sign In or Register to comment.