1

The following code compiled successfully with Soldity 0.4.21. With 0.5.0 it triggers a fatal compilation error as follows:

UnimplementedFeatureError: Encoding type "struct TestNestedStructInMapping.structNested memory" not yet implemented.
Compilation failed. See above.
Truffle v5.0.0-beta.2 (core: 5.0.0-beta.2)
Solidity v0.5.0 (solc-js)
Node v8.11.1

Here is the code:

pragma solidity ^0.5.0;

contract TestNestedStructInMapping {

    // The struct that is nested.
    struct structNested {
        uint dummy;
    }

    // The struct that holds the nested struct.
    struct structMain {
        structNested gamePaymentsSummary;
    }

    // The map that maps a game ID to a specific game.
    mapping(uint256 => structMain) public s_mapOfNestedStructs;
}

Here is a link to a Truffle project that you can pull and test with:

https://github.com/roschler/nested-structs-tests.git

Does anyone know how to solve this?

3

You can solve it by removing the word public from the mapping.

The storage structure itself is acceptable and can be expected to work. However, the "free" getter for such a structure is not implemented in the compiler.

It appears you are right about a breaking change, given that it compiles without complaint under 0.4.25. Possibly another kind soul will chime in with a precise answer about the limitation and where we go from here. In any case, I expect you should be able to carry on with your own explicit getter functions.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.