You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the 5.0 version of solc, if a host struct nests another struct, and the host struct is the value in a mapping, the compiler emits a fatal compilation error using the UnimplementedFeature error code. This code did work in version v0.4.21.
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 a link to a public repo with a minimal project that demonstrates the error:
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;
}
and it indeed seems to work in 0.4.25. Adding another variable to the struct, though, still not makes 0.4.25 complain, but the generated code is wrong - it only returns 32 bytes instead of 64.
I would propose to fix the internal compiler error by another check in the type checker - if possible.
So to summarize: The reason this worked in 0.4.25 was by mere coincidence, looking at the code, nested structs in public getter functions were never meant to be supported.
With the 5.0 version of
solc
, if a host struct nests another struct, and the host struct is the value in a mapping, the compiler emits a fatal compilation error using the UnimplementedFeature error code. This code did work in version v0.4.21.Here is a link to a public repo with a minimal project that demonstrates the error:
https://github.com/roschler/nested-structs-tests.git
The text was updated successfully, but these errors were encountered: